* Split kondo ratchet budgets into separate prod and test files Prod and test kondo suppressions shared one .clj-kondo/ratchets.edn budget per linter, so a pile of test-code ignores could mask a prod-code regression (or vice versa) inside the same number. Adds .clj-kondo/ratchets-test.edn, tracking :ignore-counts for anything under a `test` directory, independent of the prod file's budget. :config-counts (.clj-kondo/config.edn suppressions) stays combined in the prod file -- config.edn's own scoping mixes test and prod namespaces in several groups, so it can't be reliably split per suppression. Updates every consumer: dev.kondo-ratchet's fix!/check, bin/merge-kondo-ratchets, the backport and release-cut disable scripts, the shrink workflow, and file-paths.yaml/.gitignore. * Fix test-ratchets validation and exemption-suggestion bugs from roborev fix!/check read the test ratchets file with *ratchets-file* rebound to *test-ratchets-file*, but validated it after that binding ended, so an unknown linter there was reported against the prod path instead. Validation now runs inside the binding, and both now reject a nonempty :config-counts on the test file instead of letting fix! silently drop it. kondo-insert-ignores also only ever suggested adding a new linter's :comment-exempt to the prod file, even when every unjustified occurrence was test-only. It now checks prod and test occurrences against each file's own exemptions independently and names whichever file(s) actually need it. * Dedupe test-ratchets read+validate, simplify test-occurrence? fix! and check each rebuilt the same read-validate-test-file sequence inline; extracted into read-validated-test-ratchets. test-occurrence? no longer builds a throwaway set just to check one membership. * Note what splitting :config-counts later would actually cost * Fix Eastwood reflection warning in new test helper empty-test-ratchets-file! returned an untyped value, so .getPath on it needed reflection at each call site. Hinting the return type as java.io.File fixes it -- CI's changed-tests Eastwood run caught this. * Move return type hint onto the arg vector Clj-Kondo prefers the hint on the arg vector to the one on the fn name. * Move shrink PR body file reading into dev.kondo-ratchet The bb task only parses its arguments now; reading and combining the ratchet files lives next to shrink-pr-body, with a test. * Give the test ratchets file its own header and drop its :config-counts The test file was rendered with the prod header, whose last lines point readers at ratchets-test.edn and say :config-counts "stays here" -- both wrong inside the test file. It also carried an empty :config-counts that the check rejects whenever it's nonempty. render-test writes the test file with its own header and no :config-counts, and throws on a nonempty one rather than dropping it. fix!, the normalization check, and the three-way merge (a new "test" kind) all use it.
80 lines
5.6 KiB
Clojure
80 lines
5.6 KiB
Clojure
;; Budgets for kondo suppressions: inline `:clj-kondo/ignore` forms per linter (:ignore-counts), and
|
|
;; config-level waivers in .clj-kondo/config.edn (:config-counts -- :off switches and :exclude entries).
|
|
;; Each :ignore-counts value is a non-negative integer budget, or :unlimited for no ceiling.
|
|
;; Checks fail when a count exceeds its numeric budget; unused budget is allowed.
|
|
;; Any ignore outside :comment-exempt needs an explanatory comment directly above or trailing on its line.
|
|
;; `./bin/mage kondo-ratchets-shrink` lowers budgets unless `--seed` explicitly adds or raises one.
|
|
;; The workflow runs it on master, so feature branches do not need to record reductions.
|
|
;; Raising or adding a budget (`--seed` for inline ignores, a manual edit otherwise) or widening the
|
|
;; exemptions must be explained in the PR.
|
|
;; :all is the vector-less ignore form, which suppresses every linter on the next form.
|
|
;;
|
|
;; Test code's :ignore-counts has its own budget in .clj-kondo/ratchets-test.edn.
|
|
;; :config-counts stays here either way -- config.edn's scoping doesn't cleanly split.
|
|
{:ignore-counts {:aliased-namespace-symbol 3
|
|
:clojure-lsp/unused-public-var 8
|
|
:consistent-alias 2
|
|
:def-fn 1
|
|
:deprecated-namespace 29
|
|
:deprecated-var 53
|
|
:discouraged-java-method 4
|
|
:discouraged-namespace 60
|
|
:discouraged-var 73
|
|
:duplicate-require 1
|
|
:main-without-gen-class 1
|
|
:metabase/discourage-dynamic-vars 325
|
|
:metabase/discourage-millis-duration 1
|
|
:metabase/modules 23
|
|
:metabase/namespace-name 3
|
|
:metabase/validate-defendpoint-has-response-schema 427
|
|
:metabase/validate-defendpoint-query-params-use-kebab-case 48
|
|
:metabase/validate-defendpoint-route-uses-kebab-case 44
|
|
:missing-docstring 4
|
|
:non-arg-vec-return-type-hint 1
|
|
:reduce-without-init 3
|
|
:redundant-do 1
|
|
:syntax 2
|
|
:type-mismatch 2
|
|
:unquote-not-syntax-quoted 1
|
|
:unresolved-namespace 3
|
|
:unresolved-symbol 9
|
|
:unsorted-required-namespaces :unlimited
|
|
:unused-alias 2
|
|
:unused-binding 3
|
|
:unused-excluded-var 2
|
|
:unused-namespace 2
|
|
:unused-private-var 6
|
|
:unused-value 1}
|
|
:config-counts {:constant-condition 1
|
|
:deprecated-namespace 7
|
|
:deprecated-var 16
|
|
:discouraged-namespace 14
|
|
:discouraged-var 14
|
|
:inline-def 1
|
|
:main-without-gen-class 1
|
|
:metabase/defsetting-must-specify-export 1
|
|
:metabase/defsetting-namespace 1
|
|
:metabase/discourage-dynamic-vars 1
|
|
:metabase/prefer-with-dynamic-fn-redefs 4
|
|
:metabase/t2-query-namespace 2
|
|
:metabase/table-or-field-query 1
|
|
:metabase/unsafe-app-db-query 1
|
|
:missing-docstring 1
|
|
:private-call 1
|
|
:redundant-ignore 1
|
|
:redundant-primitive-coercion 1
|
|
:refer-all 1
|
|
:type-mismatch 1
|
|
:unexpected-recur 1
|
|
:unresolved-symbol 15
|
|
:unresolved-var 1
|
|
:unused-referred-var 4}
|
|
:comment-exempt #{:deprecated-namespace
|
|
:discouraged-namespace
|
|
:discouraged-var
|
|
:metabase/discourage-dynamic-vars
|
|
:metabase/modules
|
|
:metabase/validate-defendpoint-has-response-schema
|
|
:metabase/validate-defendpoint-query-params-use-kebab-case
|
|
:metabase/validate-defendpoint-route-uses-kebab-case}}
|