mirror of
https://github.com/logseq/logseq.git
synced 2026-04-24 14:14:55 +00:00
Mark most vars as cleanup-todo
Fixed a few that I knew how to QA and were low risk
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
"This script detects vars that are too large and that make it difficult for
|
||||
the team to maintain and understand them."
|
||||
(:require [babashka.pods :as pods]
|
||||
[clojure.pprint :as pprint]
|
||||
[clojure.set :as set]))
|
||||
|
||||
(pods/load-pod 'clj-kondo/clj-kondo "2021.12.19")
|
||||
@@ -14,7 +15,11 @@
|
||||
{:max-lines-count 100
|
||||
;; Vars with these metadata flags are allowed. Name should indicate the reason
|
||||
;; it is allowed
|
||||
:metadata-exceptions #{::data-var}})
|
||||
:metadata-exceptions #{::data-var
|
||||
;; TODO: Address vars tagged with cleanup-todo. These
|
||||
;; are left mostly because they are not high priority
|
||||
;; or not well understood
|
||||
::cleanup-todo}})
|
||||
|
||||
(defn -main
|
||||
[args]
|
||||
@@ -34,7 +39,10 @@
|
||||
:filename (:filename m)}))))
|
||||
(sort-by :lines-count (fn [x y] (compare y x))))]
|
||||
(if (seq vars)
|
||||
(do (prn vars)
|
||||
(do
|
||||
(println (format "The following vars exceed the line count max of %s:"
|
||||
(:max-lines-count config)))
|
||||
(pprint/print-table vars)
|
||||
(System/exit 1))
|
||||
(println "All vars are below the max size!"))))
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
(defn- get-en-categories
|
||||
[]
|
||||
(->> (rewrite-clj/var-sexp
|
||||
(->> (rewrite-clj/metadata-var-sexp
|
||||
"src/main/frontend/modules/shortcut/config.cljs"
|
||||
"category")
|
||||
(map (fn [[k v]] (vector k (:doc (meta v)))))
|
||||
|
||||
@@ -817,7 +817,7 @@
|
||||
(page-cp config {:block/name namespace})]
|
||||
(namespace-hierarchy-aux config namespace children)])
|
||||
|
||||
(defn inline
|
||||
(defn ^:large-vars/cleanup-todo inline
|
||||
[{:keys [html-export?] :as config} item]
|
||||
(match item
|
||||
["Plain" s]
|
||||
@@ -2171,7 +2171,7 @@
|
||||
children)
|
||||
(distinct @refs)))
|
||||
|
||||
(rum/defcs block-container < rum/reactive
|
||||
(rum/defcs ^:large-vars/cleanup-todo block-container < rum/reactive
|
||||
{:init (fn [state]
|
||||
(let [[config block] (:rum/args state)]
|
||||
(when (and (not (some? (state/sub-collapsed (:block/uuid block))))
|
||||
@@ -2468,7 +2468,7 @@
|
||||
result-atom)]
|
||||
(assoc state :query-atom query-atom)))
|
||||
|
||||
(rum/defcs custom-query < rum/reactive
|
||||
(rum/defcs ^:large-vars/cleanup-todo custom-query < rum/reactive
|
||||
{:will-mount trigger-custom-query!
|
||||
:did-mount (fn [state]
|
||||
(when-let [query (last (:rum/args state))]
|
||||
@@ -2652,7 +2652,7 @@
|
||||
(when (and (= language "clojure") (contains? (set options) ":results"))
|
||||
(sci/eval-result code)))]))))))
|
||||
|
||||
(defn markup-element-cp
|
||||
(defn ^:large-vars/cleanup-todo markup-element-cp
|
||||
[{:keys [html-export?] :as config} item]
|
||||
(let [format (or (:block/format config)
|
||||
:markdown)]
|
||||
|
||||
@@ -146,7 +146,7 @@
|
||||
(reset! edit? true))}
|
||||
"Make template"))))
|
||||
|
||||
(rum/defc block-context-menu-content
|
||||
(rum/defc ^:large-vars/cleanup-todo block-context-menu-content
|
||||
[_target block-id]
|
||||
|
||||
(let [*el-ref (rum/use-ref nil)]
|
||||
|
||||
@@ -227,7 +227,7 @@
|
||||
template)
|
||||
:class "black"}))))))
|
||||
|
||||
(rum/defc mobile-bar < rum/reactive
|
||||
(rum/defc ^:large-vars/cleanup-todo mobile-bar < rum/reactive
|
||||
[_parent-state parent-id]
|
||||
(let [vw-state (state/sub :ui/visual-viewport-state)
|
||||
vw-pending? (state/sub :ui/visual-viewport-pending?)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
[rum.core :as rum]
|
||||
[frontend.ui :as ui]))
|
||||
|
||||
(rum/defc intro
|
||||
(rum/defc ^:large-vars/cleanup-todo intro
|
||||
[]
|
||||
(rum/with-context [[t] i18n/*tongue-context*]
|
||||
[:div#logseq-intro.pl-1
|
||||
|
||||
@@ -359,7 +359,7 @@
|
||||
(defonce *orphan-pages? (atom true))
|
||||
(defonce *builtin-pages? (atom nil))
|
||||
|
||||
(rum/defc graph-filters < rum/reactive
|
||||
(rum/defc ^:large-vars/cleanup-todo graph-filters < rum/reactive
|
||||
[graph settings n-hops]
|
||||
(let [{:keys [journal? orphan-pages? builtin-pages?]
|
||||
:or {orphan-pages? true}} settings
|
||||
@@ -662,7 +662,7 @@
|
||||
(notification/show! (str (t :tips/all-done) "!") :success)
|
||||
(js/setTimeout #(refresh-fn) 200)))]])))
|
||||
|
||||
(rum/defcs all-pages < rum/reactive
|
||||
(rum/defcs ^:large-vars/cleanup-todo all-pages < rum/reactive
|
||||
(rum/local nil ::pages)
|
||||
(rum/local nil ::search-key)
|
||||
(rum/local nil ::results-all)
|
||||
|
||||
@@ -155,7 +155,7 @@
|
||||
Meanwhile, make sure you have regular backups of your graphs and only install the plugins when you can read and
|
||||
understand the source code."]))
|
||||
|
||||
(rum/defc plugin-item-card < rum/static
|
||||
(rum/defc ^:large-vars/cleanup-todo plugin-item-card < rum/static
|
||||
[{:keys [id name title settings version url description author icon usf iir repo sponsors] :as item}
|
||||
market? *search-key has-other-pending?
|
||||
installing-or-updating? installed? stat coming-update]
|
||||
@@ -295,7 +295,7 @@
|
||||
(page-handler/init-commands!))
|
||||
true)]])]])))
|
||||
|
||||
(rum/defc panel-control-tabs
|
||||
(rum/defc ^:large-vars/cleanup-todo panel-control-tabs
|
||||
< rum/static
|
||||
[t search-key *search-key category *category
|
||||
sort-or-filter-by *sort-or-filter-by selected-unpacked-pkg
|
||||
|
||||
@@ -54,6 +54,28 @@
|
||||
(map #(medley/dissoc-in % ks) result)
|
||||
result)))
|
||||
|
||||
(defn- sort-by-fn [sort-by-item item]
|
||||
(case sort-by-item
|
||||
:created-at
|
||||
(:block/created-at item)
|
||||
:updated-at
|
||||
(:block/updated-at item)
|
||||
:block
|
||||
(:block/content item)
|
||||
:page
|
||||
(:block/name item)
|
||||
(get-in item [:block/properties key])))
|
||||
|
||||
(defn- desc?
|
||||
[*desc? p-desc?]
|
||||
(cond
|
||||
(some? @*desc?)
|
||||
@*desc?
|
||||
(some? p-desc?)
|
||||
p-desc?
|
||||
:else
|
||||
true))
|
||||
|
||||
(rum/defcs result-table < rum/reactive
|
||||
(rum/local nil ::sort-by-item)
|
||||
(rum/local nil ::desc?)
|
||||
@@ -66,13 +88,6 @@
|
||||
*sort-by-item (get state ::sort-by-item)
|
||||
*desc? (get state ::desc?)
|
||||
sort-by-item (or @*sort-by-item (some-> p-sort-by keyword) :updated-at)
|
||||
desc? (cond
|
||||
(some? @*desc?)
|
||||
@*desc?
|
||||
(some? p-desc?)
|
||||
p-desc?
|
||||
:else
|
||||
true)
|
||||
;; remove templates
|
||||
result (remove (fn [b] (some? (get-in b [:block/properties :template]))) result)
|
||||
result (if page? result (attach-clock-property result))
|
||||
@@ -91,19 +106,9 @@
|
||||
(filter included-keys keys)
|
||||
included-keys)
|
||||
keys))
|
||||
sort-by-fn (fn [item]
|
||||
(let [key sort-by-item]
|
||||
(case key
|
||||
:created-at
|
||||
(:block/created-at item)
|
||||
:updated-at
|
||||
(:block/updated-at item)
|
||||
:block
|
||||
(:block/content item)
|
||||
:page
|
||||
(:block/name item)
|
||||
(get-in item [:block/properties key]))))
|
||||
result (sort-result-by sort-by-fn desc? result)]
|
||||
result (sort-result-by (partial sort-by-fn sort-by-item)
|
||||
(desc? *desc? p-desc?)
|
||||
result)]
|
||||
[:div.overflow-x-auto {:on-mouse-down (fn [e] (.stopPropagation e))
|
||||
:style {:width "100%"}}
|
||||
[:table.table-auto
|
||||
|
||||
@@ -185,23 +185,24 @@
|
||||
(p/let [multiple-windows? (ipc/ipc "graphHasMultipleWindows" (state/get-current-repo))]
|
||||
(reset! (::electron-multiple-windows? state) multiple-windows?))))
|
||||
|
||||
(defn- get-repo-name [repo]
|
||||
(cond
|
||||
(mobile-util/is-native-platform?)
|
||||
(text/get-graph-name-from-path repo)
|
||||
|
||||
(config/local-db? repo)
|
||||
(config/get-local-dir repo)
|
||||
|
||||
:else
|
||||
(db/get-repo-path repo)))
|
||||
|
||||
(rum/defcs repos-dropdown < rum/reactive
|
||||
(rum/local false ::electron-multiple-windows?)
|
||||
[state]
|
||||
(let [multiple-windows? (::electron-multiple-windows? state)]
|
||||
(when-let [current-repo (state/sub :git/current-repo)]
|
||||
(rum/with-context [[t] i18n/*tongue-context*]
|
||||
(let [get-repo-name (fn [repo]
|
||||
(cond
|
||||
(mobile-util/is-native-platform?)
|
||||
(text/get-graph-name-from-path repo)
|
||||
|
||||
(config/local-db? repo)
|
||||
(config/get-local-dir repo)
|
||||
|
||||
:else
|
||||
(db/get-repo-path repo)))
|
||||
repos (state/sub [:me :repos])
|
||||
(let [repos (state/sub [:me :repos])
|
||||
repos (remove (fn [r] (= config/local-repo (:url r))) repos)
|
||||
switch-repos (remove (fn [repo]
|
||||
(= current-repo (:url repo)))
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
|
||||
(defonce search-timeout (atom nil))
|
||||
|
||||
(rum/defc search-auto-complete
|
||||
(rum/defc ^:large-vars/cleanup-todo search-auto-complete
|
||||
[{:keys [pages files blocks has-more?] :as result} search-q all?]
|
||||
(rum/with-context [[t] i18n/*tongue-context*]
|
||||
(let [pages (when-not all? (map (fn [page]
|
||||
|
||||
@@ -517,7 +517,7 @@
|
||||
{:left-label "Plug-in system"
|
||||
:action (plugin-enabled-switcher t)}))
|
||||
|
||||
(rum/defcs settings
|
||||
(rum/defcs ^:large-vars/cleanup-todo settings
|
||||
< (rum/local :general ::active)
|
||||
{:will-mount
|
||||
(fn [state]
|
||||
|
||||
@@ -141,7 +141,7 @@
|
||||
l)
|
||||
@vars))
|
||||
|
||||
(defn build-query
|
||||
(defn ^:large-vars/cleanup-todo build-query
|
||||
([repo e env]
|
||||
(build-query repo e (assoc env :vars (atom {})) 0))
|
||||
([repo e {:keys [sort-by blocks? sample counter current-filter vars] :as env} level]
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
(defonce version 1)
|
||||
(defonce ast-version 1)
|
||||
;; A page is a special block, a page can corresponds to multiple files with the same ":block/name".
|
||||
(def schema
|
||||
(def ^:large-vars/data-var schema
|
||||
{:schema/version {}
|
||||
:ast/version {}
|
||||
:db/type {}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
(str (hiccup-without-style hiccup))))
|
||||
|
||||
(defn hiccup->doc-inner
|
||||
(defn ^:large-vars/cleanup-todo hiccup->doc-inner
|
||||
[format hiccup]
|
||||
(let [transform-fn (fn [hiccup]
|
||||
(hiccup->doc-inner format hiccup))
|
||||
|
||||
@@ -199,7 +199,7 @@
|
||||
:data-color color}])
|
||||
rects)]))
|
||||
|
||||
(rum/defc pdf-highlight-area-region
|
||||
(rum/defc ^:large-vars/cleanup-todo pdf-highlight-area-region
|
||||
[^js viewer vw-hl hl
|
||||
{:keys [show-ctx-tip! upd-hl!]}]
|
||||
|
||||
@@ -314,7 +314,7 @@
|
||||
(:id hl))
|
||||
))])
|
||||
|
||||
(rum/defc pdf-highlight-area-selection
|
||||
(rum/defc ^:large-vars/cleanup-todo pdf-highlight-area-selection
|
||||
[^js viewer {:keys [show-ctx-tip!]}]
|
||||
|
||||
(let [^js viewer-clt (.. viewer -viewer -classList)
|
||||
@@ -439,7 +439,7 @@
|
||||
(when (and start-coord end-coord)
|
||||
[:div.shadow-rect {:style (calc-pos start-coord end-coord)}])]))
|
||||
|
||||
(rum/defc pdf-highlights
|
||||
(rum/defc ^:large-vars/cleanup-todo pdf-highlights
|
||||
[^js el ^js viewer initial-hls loaded-pages {:keys [set-dirty-hls!]}]
|
||||
|
||||
(let [^js doc (.-ownerDocument el)
|
||||
@@ -791,7 +791,7 @@
|
||||
(fn [close-fn!]
|
||||
(docinfo-display info close-fn!)))
|
||||
|
||||
(rum/defc pdf-toolbar
|
||||
(rum/defc ^:large-vars/cleanup-todo pdf-toolbar
|
||||
[^js viewer]
|
||||
(let [[area-mode? set-area-mode!] (use-atom *area-mode?)
|
||||
[outline-visible?, set-outline-visible!] (rum/use-state false)
|
||||
|
||||
@@ -501,7 +501,7 @@
|
||||
blocks (map (fn [block] (dissoc block :block/anchor)) blocks)]
|
||||
(with-path-refs blocks)))
|
||||
|
||||
(defn extract-blocks
|
||||
(defn ^:large-vars/cleanup-todo extract-blocks
|
||||
[blocks content with-id? format]
|
||||
(try
|
||||
(let [encoded-content (utf8/encode content)
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
(= (string/trim decrypted-content) (string/trim db-content)))
|
||||
(p/resolved (= (string/trim disk-content) (string/trim db-content))))))
|
||||
|
||||
(defrecord Nfs []
|
||||
(defrecord ^:large-vars/cleanup-todo Nfs []
|
||||
protocol/Fs
|
||||
(mkdir! [_this dir]
|
||||
(let [parts (->> (string/split dir "/")
|
||||
|
||||
@@ -3003,7 +3003,7 @@
|
||||
:else
|
||||
nil))))
|
||||
|
||||
(defn keyup-handler
|
||||
(defn ^:large-vars/cleanup-todo keyup-handler
|
||||
[_state input input-id search-timeout]
|
||||
(fn [e key-code]
|
||||
(when-not (util/event-is-composing? e)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
[rum.core :as rum]
|
||||
[frontend.mobile.util :as mobile-util]))
|
||||
|
||||
(defonce state
|
||||
(defonce ^:large-vars/data-var state
|
||||
(let [document-mode? (or (storage/get :document/mode?) false)
|
||||
current-graph (let [graph (storage/get :git/current-repo)]
|
||||
(when graph (ipc/ipc "setCurrentGraph" graph))
|
||||
|
||||
@@ -94,7 +94,7 @@ last-modified-at:: 1609084800002"}]]
|
||||
|
||||
(defonce empty-result {:query nil :result nil})
|
||||
|
||||
(deftest test-parse
|
||||
(deftest ^:large-vars/cleanup-todo test-parse
|
||||
[]
|
||||
(testing "nil or blank strings should be ignored"
|
||||
(are [x y] (= (q x) y)
|
||||
|
||||
Reference in New Issue
Block a user