Setup carve and ignore all unused vars by default

Also split out lint jobs to their own step
pull/4023/head
Gabriel Horner 2022-01-24 16:41:07 -05:00
parent f02c6d3605
commit 8b428796bc
5 changed files with 305 additions and 5 deletions

5
.carve/config.edn Normal file
View File

@ -0,0 +1,5 @@
{:paths ["src/main" "src/electron" "src/test"]
:api-namespaces [
;; Ignore b/c too many false positives
frontend.db]
:report {:format :ignore}}

226
.carve/ignore Normal file
View File

@ -0,0 +1,226 @@
electron.configs/del-item!
electron.core/ROOT_PATH
electron.core/main
electron.core/start
electron.core/stop
electron.git/dot-git-exists?
electron.search/error
electron.search/query
frontend.blob/blob
frontend.commands/insert-before!
frontend.commands/get-command-input
frontend.components.block/selection-range-in-block?
frontend.components.block/blocks-cp
frontend.components.export/export-page
frontend.components.page/get-page-format
frontend.components.page/show-journal?
frontend.components.settings/set-cors
frontend.components.sidebar/nav-item
frontend.components.svg/arrow-left
frontend.components.svg/arrow-right
frontend.components.svg/big-arrow-right
frontend.components.svg/big-arrow-left
frontend.components.svg/arrow-narrow-left
frontend.components.svg/arrow-narrow-right
frontend.components.svg/minus
frontend.components.svg/rectangle
frontend.components.svg/user
frontend.components.svg/plus
frontend.components.svg/plus-circle
frontend.components.svg/graph-sm
frontend.components.svg/folder-add
frontend.components.svg/folder-add-large
frontend.components.svg/folder-sm
frontend.components.svg/pages-sm
frontend.components.svg/repos-sm
frontend.components.svg/calendar-sm
frontend.components.svg/import-sm
frontend.components.svg/sort-asc-sm
frontend.components.svg/vertical-dots
frontend.components.svg/horizontal-dots
frontend.components.svg/save
frontend.components.svg/menu
frontend.components.svg/excalidraw-logo
frontend.components.svg/discord
frontend.components.svg/slideshow
frontend.components.svg/indent-block
frontend.components.svg/outdent-block
frontend.components.svg/move-up-block
frontend.components.svg/move-down-block
frontend.components.svg/multi-line-input
frontend.components.svg/checkbox
frontend.components.svg/online
frontend.components.svg/collapse-right
frontend.components.svg/git
frontend.components.svg/home
frontend.components.svg/icon-cmd
frontend.components.svg/icon-editor
frontend.components.svg/icon-cli
frontend.components.svg/settings
frontend.components.svg/arrow-expand
frontend.config/git-repo-status-secs
frontend.config/get-subscript
frontend.config/get-superscript
frontend.config/properties-wrapper
frontend.config/get-file-format
frontend.config/default-empty-block
frontend.config/with-code-wrapper
frontend.context.i18n/use-tongue
frontend.core/stop
frontend.date/ISO-string
frontend.date/get-local-date-time-string
frontend.date/get-month-last-day
frontend.date/int->local-time
frontend.db.debug/qb
frontend.db.debug/check-left-id-conflicts
frontend.db.debug/block-uuid-nil?
frontend.db.model/get-file-by-path
frontend.db.model/get-page-ids-by-names
frontend.db.model/remove-children!
frontend.db.model/with-children-refs
frontend.db.model/db-graph?
frontend.db.model/remove-all-aliases!
frontend.db.model/get-latest-changed-pages
frontend.db.model/remove-orphaned-pages!
frontend.db.outliner/save-block
frontend.db.outliner/remove-non-existed-refs!
frontend.db.react/add-rules-to-inputs
frontend.db.utils/q
frontend.debug/defn
frontend.debug/print
frontend.diff/diffs
frontend.diff/get-patches
frontend.diff/apply-patches!
frontend.extensions.age-encryption/keygen
frontend.extensions.age-encryption/encrypt-with-x25519
frontend.extensions.age-encryption/decrypt-with-x25519
frontend.extensions.age-encryption/encrypt-with-user-passphrase
frontend.extensions.age-encryption/decrypt-with-user-passphrase
frontend.extensions.code/editor
frontend.extensions.excalidraw/*bounding-width
frontend.extensions.excalidraw/draw
frontend.extensions.graph/reset-graph!
frontend.extensions.graph.pixi/*dark?
frontend.extensions.pdf.assets/*asset-uploading?
frontend.extensions.pdf.utils/get-page-bounding
frontend.extensions.pdf.utils/gen-id
frontend.extensions.zotero.api/item
frontend.external.roam/reset-state!
frontend.format.block/extract-title
frontend.format.block/hiccup-block?
frontend.format.block/definition-list-block?
frontend.format.block/src-block?
frontend.format.mldoc/ast-export-markdown
frontend.fs/readdir
frontend.git/log
frontend.git/pull
frontend.git/commit-non-empty
frontend.git/add-commit
frontend.git/find-common-base
frontend.git/read-blob
frontend.github/get-repo-permission
frontend.handler.block/get-block-ids
frontend.handler.editor/edit-last-block-for-new-page!
frontend.handler.editor/input-start-or-end?
frontend.handler.editor/reversed-delete-map
frontend.handler.editor/get-previous-input-char
frontend.handler.editor/get-previous-input-chars
frontend.handler.editor/append-paste-doc!
frontend.handler.editor/save!
frontend.handler.editor/expand-all?
frontend.handler.editor/collapse-all?
frontend.handler.export/export-repo-as-json!
frontend.handler.export/export-git-repo-as-zip!
frontend.handler.export/convert-page-markdown-unordered-list-or-heading!
frontend.handler.file/create!
frontend.handler.metadata/update-properties!
frontend.handler.notification/clear-all!
frontend.handler.repo/get-repo-name
frontend.handler.route/toggle-between-page-and-file!
frontend.handler.shell/run-pandoc-command!
frontend.handler.ui/hide-right-sidebar
frontend.handler.ui/show-right-sidebar
frontend.image/get-orientation
frontend.mixins/resize-layout
frontend.mixins/will-mount-effect
frontend.mixins/perf-measure-mixin
frontend.mobile.util/is-plugin-available?
frontend.mobile.util/get-idevice-statusbar-height
frontend.modules.outliner.datascript/transact!
frontend.modules.outliner.utils/->db-id
frontend.modules.shortcut.before/only-enable-when-dev!
frontend.page/route-view
frontend.publishing/stop
frontend.rum/use-atom-in
frontend.search.db/empty?
frontend.state/sub-current-route
frontend.state/hide-file?
frontend.state/cycle-collapse!
frontend.state/get-last-edit-input-id
frontend.state/get-editor-show-zotero
frontend.state/clear-selection-blocks!
frontend.state/set-github-token!
frontend.state/get-sidebar-blocks
frontend.state/update-sync-status!
frontend.state/set-draw!
frontend.state/get-current-project
frontend.state/update-current-project
frontend.state/remove-current-project
frontend.state/get-changed-files
frontend.state/online?
frontend.state/reset-published-pages
frontend.state/set-db-persisted!
frontend.state/persist-transaction!
frontend.state/get-repo-latest-txs
frontend.state/get-editor-cp
frontend.state/get-favorites-name
frontend.state/remove-watch-state
frontend.state/get-visual-viewport-state
frontend.storage/get-json
frontend.storage/set-json
frontend.text/remove-lines-level-spaces
frontend.tools.html-export/export-page
frontend.ui/reset-ios-whole-page-offset!
frontend.ui/badge
frontend.ui/get-doc-scroll-top
frontend.ui/modal-show?
frontend.ui.date-picker/date-format
frontend.ui.date-picker/iso8601->date
frontend.utf8/delete!
frontend.util/indexed
frontend.util/dissoc-in
frontend.util/remove-nils-or-empty
frontend.util/index-by
frontend.util/patch
frontend.util/minimize-html
frontend.util/speed
frontend.util/moving-frequency
frontend.util/lock-global-scroll
frontend.util/scroll-to-element-v2
frontend.util/scroll-to-bottom
frontend.util/drop-first-line
frontend.util/safe-split-first
frontend.util/trim-only-newlines
frontend.util/join-newline
frontend.util/replace-first-ignore-case
frontend.util/node-in-viewpoint?
frontend.util/input-selected?
frontend.util/extract-uuid
frontend.util/file-page?
frontend.util/d
frontend.util/get-prev-block-with-same-level
frontend.util/get-next-block-with-same-level
frontend.util/sort-by-value
frontend.util/encode-str
frontend.util/->system-modifier
frontend.util/safe-search-normalize
frontend.util/get-element-width
frontend.util/trace!
frontend.util/unquote-string-if-wrapped
frontend.util.cursor/end-of-line?
frontend.util.cursor/move-cursor-to-beginning
frontend.util.pool/terminate-parser-pool!
frontend.util.property/goto-properties-beginning
frontend.util.property/add-page-properties
frontend.worker.parser/init
frontend.react/auto-clean-state

View File

@ -27,5 +27,4 @@
frontend.namespaces/import-vars potemkin/import-vars
;; src/test
frontend.react/defc clojure.core/defn}
:skip-comments true
:output {:progress true}}
:skip-comments true}

View File

@ -17,6 +17,7 @@ env:
JAVA_VERSION: '8'
# This is the latest node version we can run.
NODE_VERSION: '16'
BABASHKA_VERSION: '0.7.3'
jobs:
@ -60,13 +61,11 @@ jobs:
~/.gitlibs
key: ${{ runner.os }}-clojure-deps-${{ hashFiles('deps.edn') }}
restore-keys: ${{ runner.os }}-clojure-deps-
- name: Fetch Clojure deps
if: steps.clojure-deps.outputs.cache-hit != 'true'
run: clojure -A:cljs -P
- name: Run clj-kondo lint
run: clojure -M:clj-kondo --lint src
- name: Fetch yarn deps
run: yarn install
@ -75,6 +74,35 @@ jobs:
yarn cljs:test
node static/tests.js
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Java
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: ${{ env.JAVA_VERSION }}
- name: Set up Clojure
uses: DeLaGuardo/setup-clojure@master
with:
cli: ${{ env.CLOJURE_VERSION }}
- name: Setup Babashka
uses: turtlequeue/setup-babashka@v1.3.0
with:
babashka-version: ${{ env.BABASHKA_VERSION }}
- name: Run clj-kondo lint
run: clojure -M:clj-kondo --parallel --lint src
- name: Carve lint for unused vars
run: scripts/carve.clj
e2e-test:
runs-on: ubuntu-latest

42
scripts/carve.clj Executable file
View File

@ -0,0 +1,42 @@
#!/usr/bin/env bb
;; This file is copied from
;; https://github.com/borkdude/carve/blob/df552797a198b6701fb2d92390fce7c59205ea77/carve.clj
;; and thus this file is under the same EPL license.
;; The script is modified to run latest clj-kondo and carve versions and to add
;; a more friendly commandline interface through -main
(require '[babashka.pods :as pods])
(pods/load-pod 'clj-kondo/clj-kondo "2021.12.19")
(require '[pod.borkdude.clj-kondo :as clj-kondo])
;; define clj-kondo.core ns which is used by carve
(intern (create-ns 'clj-kondo.core) 'run! clj-kondo/run!)
(require '[babashka.deps :as deps])
(deps/add-deps '{:deps {borkdude/carve ;; {:local/root "."}
{:git/url "https://github.com/borkdude/carve"
:git/sha "df552797a198b6701fb2d92390fce7c59205ea77"}
borkdude/spartan.spec {:git/url "https://github.com/borkdude/spartan.spec"
:sha "12947185b4f8b8ff8ee3bc0f19c98dbde54d4c90"}}})
(require '[spartan.spec]) ;; defines clojure.spec
(with-out-str ;; silence warnings about spartan.spec + with-gen
(binding [*err* *out*]
(require '[carve.api :as carve])))
;; again to make clj-kondo happy
(require '[carve.main])
(require '[clojure.edn :as edn])
(defn -main
"Wrapper around carve.main that defaults to .carve/config.edn and merges
in an optional string of options"
[args]
(let [default-opts (slurp ".carve/config.edn")
opts (if-let [more-opts (first args)]
(pr-str (merge (edn/read-string default-opts) (edn/read-string more-opts)))
default-opts)]
(apply carve.main/-main ["--opts" opts])))
(-main *command-line-args*)