Bladeren bron

fix: invalid throws and remove unused values

Caught by updating to latest kondo
Gabriel Horner 11 maanden geleden
bovenliggende
commit
0036a5d9de

+ 1 - 1
bb.edn

@@ -12,7 +12,7 @@
   org.clj-commons/digest
   {:mvn/version "1.4.100"}}
  :pods
- {clj-kondo/clj-kondo {:version "2023.05.26"}
+ {clj-kondo/clj-kondo {:version "2024.09.27"}
   org.babashka/fswatcher {:version "0.0.3"}
   org.babashka/go-sqlite3 {:version "0.1.0"}}
  :tasks

+ 1 - 1
deps.edn

@@ -77,5 +77,5 @@
                    :main-opts ["-m" "cljs-test-runner.main" "-d" "src/bench" "-n" "frontend.benchmark-test-runner"]}
 
            ;; Use :replace-deps for tools. See https://github.com/clj-kondo/clj-kondo/issues/1536#issuecomment-1013006889
-           :clj-kondo {:replace-deps {clj-kondo/clj-kondo {:mvn/version "2023.05.26"}}
+           :clj-kondo {:replace-deps {clj-kondo/clj-kondo {:mvn/version "2024.09.27"}}
                        :main-opts  ["-m" "clj-kondo.main"]}}}

+ 1 - 1
deps/common/bb.edn

@@ -6,7 +6,7 @@
    :git/sha "70d3edeb287f5cec7192e642549a401f7d6d4263"}}
 
  :pods
- {clj-kondo/clj-kondo {:version "2023.05.26"}}
+ {clj-kondo/clj-kondo {:version "2024.09.27"}}
 
  :tasks
  {test:load-all-namespaces-with-nbb

+ 1 - 1
deps/common/deps.edn

@@ -8,5 +8,5 @@
                        org.clojure/clojurescript {:mvn/version "1.11.132"}}
          :main-opts   ["-m" "cljs-test-runner.main"]}
   :clj-kondo
-  {:replace-deps {clj-kondo/clj-kondo {:mvn/version "2023.05.26"}}
+  {:replace-deps {clj-kondo/clj-kondo {:mvn/version "2024.09.27"}}
    :main-opts  ["-m" "clj-kondo.main"]}}}

+ 1 - 1
deps/common/src/logseq/common/util.cljs

@@ -372,5 +372,5 @@ return: [{:id 3} {:id 2 :depend-on 3} {:id 1 :depend-on 2}]"
 
 (defn clear-markdown-heading
   [content]
-  [:pre (string? content)]
+  {:pre [(string? content)]}
   (string/replace-first content markdown-heading-pattern ""))

+ 1 - 1
deps/db/bb.edn

@@ -7,7 +7,7 @@
    :git/sha "1d429e223baeade426d30a4ed1c8a110173a2402"}}
 
  :pods
- {clj-kondo/clj-kondo {:version "2023.05.26"}}
+ {clj-kondo/clj-kondo {:version "2024.09.27"}}
 
  :tasks
  {test:load-all-namespaces-with-nbb

+ 1 - 1
deps/db/deps.edn

@@ -16,5 +16,5 @@
 
  :aliases
  {:clj-kondo
-  {:replace-deps {clj-kondo/clj-kondo {:mvn/version "2023.05.26"}}
+  {:replace-deps {clj-kondo/clj-kondo {:mvn/version "2024.09.27"}}
    :main-opts  ["-m" "clj-kondo.main"]}}}

+ 1 - 1
deps/graph-parser/bb.edn

@@ -6,7 +6,7 @@
    :git/sha "70d3edeb287f5cec7192e642549a401f7d6d4263"}}
  
  :pods
- {clj-kondo/clj-kondo {:version "2023.05.26"}}
+ {clj-kondo/clj-kondo {:version "2024.09.27"}}
 
  :tasks
  {test:load-all-namespaces-with-nbb

+ 1 - 1
deps/graph-parser/deps.edn

@@ -22,5 +22,5 @@
                        logseq/outliner {:local/root "../outliner"}}
          :main-opts   ["-m" "cljs-test-runner.main"]}
 
-  :clj-kondo {:replace-deps {clj-kondo/clj-kondo {:mvn/version "2023.05.26"}}
+  :clj-kondo {:replace-deps {clj-kondo/clj-kondo {:mvn/version "2024.09.27"}}
               :main-opts    ["-m" "clj-kondo.main"]}}}

+ 1 - 1
deps/outliner/bb.edn

@@ -6,7 +6,7 @@
    :git/sha "70d3edeb287f5cec7192e642549a401f7d6d4263"}}
 
  :pods
- {clj-kondo/clj-kondo {:version "2023.05.26"}}
+ {clj-kondo/clj-kondo {:version "2024.09.27"}}
 
  :tasks
  {test:load-all-namespaces-with-nbb

+ 1 - 1
deps/outliner/deps.edn

@@ -8,5 +8,5 @@
   metosin/malli {:mvn/version "0.16.1"}}
  :aliases
  {:clj-kondo
-  {:replace-deps {clj-kondo/clj-kondo {:mvn/version "2023.05.26"}}
+  {:replace-deps {clj-kondo/clj-kondo {:mvn/version "2024.09.27"}}
    :main-opts  ["-m" "clj-kondo.main"]}}}

+ 0 - 2
deps/outliner/src/logseq/outliner/core.cljs

@@ -563,7 +563,6 @@
                      (d/entity db (:db/id target-block))
                      (when (:block/uuid target-block)
                        (d/entity db [:block/uuid (:block/uuid target-block)])))]
-    [block sibling?]
     (let [linked (:block/link block)
           up-down? (= outliner-op :move-blocks-up-down)
           [block sibling?] (cond
@@ -723,7 +722,6 @@
   "Delete blocks from the tree.
   `blocks` need to be sorted by left&parent(from top to bottom)"
   [conn blocks]
-  [:pre [(seq blocks)]]
   (let [top-level-blocks (filter-top-level-blocks @conn blocks)
         non-consecutive? (and (> (count top-level-blocks) 1) (seq (ldb/get-non-consecutive-blocks @conn top-level-blocks)))
         top-level-blocks (->> (get-top-level-blocks top-level-blocks non-consecutive?)

+ 1 - 1
deps/publishing/bb.edn

@@ -6,7 +6,7 @@
    :git/sha "70d3edeb287f5cec7192e642549a401f7d6d4263"}}
 
  :pods
- {clj-kondo/clj-kondo {:version "2023.05.26"}}
+ {clj-kondo/clj-kondo {:version "2024.09.27"}}
 
  :tasks
  {test:load-all-namespaces-with-nbb

+ 1 - 1
deps/publishing/deps.edn

@@ -3,5 +3,5 @@
  {logseq/db {:local/root "../db"}}
 
  :aliases
- {:clj-kondo {:replace-deps {clj-kondo/clj-kondo {:mvn/version "2023.05.26"}}
+ {:clj-kondo {:replace-deps {clj-kondo/clj-kondo {:mvn/version "2024.09.27"}}
               :main-opts    ["-m" "clj-kondo.main"]}}}

+ 2 - 2
src/electron/electron/updater.cljs

@@ -62,10 +62,10 @@
                         (when (and (. semver valid remote-version)
                                    (. semver lt electron-version remote-version)) artifact))
 
-             url (if-not artifact (do (emit "update-not-available" nil) (throw nil)) (:url artifact))
+             url (if-not artifact (do (emit "update-not-available" nil) (throw (js/Error. "update not available"))) (:url artifact))
              _ (if url (emit "update-available" (bean/->js artifact)) (throw (js/Error. "download url not exists")))
                ;; start download FIXME: user's preference about auto download
-             _ (when-not auto-download (throw nil))
+             _ (when-not auto-download (throw (js/Error. "no auto download")))
              ^js dl-res (fetch url)
              _ (when-not (.-ok dl-res) (throw (js/Error. "download resource not available")))
              dest-info (p/create

+ 1 - 1
src/main/frontend/handler/plugin.cljs

@@ -518,7 +518,7 @@
       ;; local
       (-> (p/let [content (invoke-exported-api "load_plugin_readme" url)
                   content (parse-user-md-content content item)]
-            (and (string/blank? (string/trim content)) (throw nil))
+            (and (string/blank? (string/trim content)) (throw (js/Error. "blank readme content")))
             (state/set-state! :plugin/active-readme [content item])
             (shui/dialog-open! (fn [_] (display)) {:label "plugin-readme"}))
         (p/catch #(do (js/console.warn %)

+ 5 - 5
src/main/logseq/api.cljs

@@ -239,7 +239,7 @@
           sub-dir?       (string/starts-with? user-path path)
           _              (when-not sub-dir?
                            (log/info :debug user-path)
-                           (throw "write file denied"))
+                           (throw (js/Error. "write file denied")))
           user-path-root (util/node-path.dirname user-path)
           exist?         (fs/file-exists? user-path-root "")
           _              (when-not exist? (fs/mkdir-recur! user-path-root))
@@ -262,9 +262,9 @@
   (p/let [path      (util/node-path.join root-dir sub-root)
           user-path (util/node-path.join path file)
           sub-dir?  (string/starts-with? user-path path)
-          _         (when-not sub-dir? (log/info :debug user-path) (throw "read file denied"))
+          _         (when-not sub-dir? (log/info :debug user-path) (throw (js/Error. "read file denied")))
           exist?    (fs/file-exists? "" user-path)
-          _         (when-not exist? (log/info :debug user-path) (throw "file not existed"))
+          _         (when-not exist? (log/info :debug user-path) (throw (js/Error. "file not existed")))
           content   (fs/read-file "" user-path)]
     content))
 
@@ -284,9 +284,9 @@
           path      (util/node-path.join root-dir sub-root)
           user-path (util/node-path.join path file)
           sub-dir?  (string/starts-with? user-path path)
-          _         (when-not sub-dir? (log/info :debug user-path) (throw "access file denied"))
+          _         (when-not sub-dir? (log/info :debug user-path) (throw (js/Error. "access file denied")))
           exist?    (fs/file-exists? "" user-path)
-          _         (when-not exist? (log/info :debug user-path) (throw "file not existed"))
+          _         (when-not exist? (log/info :debug user-path) (throw (js/Error. "file not existed")))
           _         (fs/unlink! repo user-path {})]))
 
 (defn ^:private unlink_dotdir_file!