jonase / eastwood

Clojure lint tool
1.09k stars 66 forks source link

Exception when analyzing `use-fixtures` form that isn't plain symbol #412

Closed camsaul closed 3 years ago

camsaul commented 3 years ago

Our codebase has forms like

(use-fixtures :once (fixtures/initialize :db))

and those seem to cause errors:

Exception thrown during phase :analyze+eval of linting namespace metabase.test.util
UnsupportedOperationException count not supported on this type: Symbol
    clojure.lang.RT.countFrom (RT.java:671)
    clojure.lang.RT.count (RT.java:643)
    clojure.core/count (core.clj:880)
    clojure.core/count (core.clj:874)
    clojure.core/sort-by/fn--5978 (core.clj:3131)
    clojure.lang.AFunction.compare (AFunction.java:51)
    java.util.TimSort.countRunAndMakeAscending (TimSort.java:355)
    java.util.TimSort.sort (TimSort.java:220)
    java.util.Arrays.sort (Arrays.java:1441)
    clojure.core/sort (core.clj:3115)
    clojure.core/sort-by (core.clj:3119)
    clojure.core/sort-by (core.clj:3119)
    clojure.core/sort-by (core.clj:3119)
    eastwood.copieddeps.dep1.clojure.tools.analyzer.utils/arglist-for-arity (utils.clj:177)
    eastwood.copieddeps.dep1.clojure.tools.analyzer.utils/arglist-for-arity (utils.clj:174)
    eastwood.copieddeps.dep2.clojure.tools.analyzer.passes.jvm.infer-tag/eval70567/fn--70569 (infer_tag.clj:226)
    clojure.lang.MultiFn.invoke (MultiFn.java:229)
    eastwood.copieddeps.dep2.clojure.tools.analyzer.passes.jvm.infer-tag/infer-tag (infer_tag.clj:275)
    eastwood.copieddeps.dep2.clojure.tools.analyzer.passes.jvm.infer-tag/infer-tag (infer_tag.clj:255)
    clojure.lang.Var.invoke (Var.java:384)
    eastwood.copieddeps.dep1.clojure.tools.analyzer.passes/compile-passes/fn--67898/fn--67903 (passes.clj:166)
    eastwood.copieddeps.dep1.clojure.tools.analyzer.passes/compile-passes/fn--67898/fn--67905 (passes.clj:168)
    eastwood.copieddeps.dep1.clojure.tools.analyzer.passes/compile-passes/fn--67898/fn--67905 (passes.clj:168)
    eastwood.copieddeps.dep1.clojure.tools.analyzer.passes/compile-passes/fn--67898/fn--67905 (passes.clj:168)
    eastwood.copieddeps.dep1.clojure.tools.analyzer.passes/compile-passes/fn--67898/fn--67905 (passes.clj:168)
    clojure.core/partial/fn--5841 (core.clj:2631)
    eastwood.copieddeps.dep1.clojure.tools.analyzer.ast/walk/walk--67779 (ast.clj:102)
    eastwood.copieddeps.dep1.clojure.tools.analyzer.ast/walk/walk--67779/walk--67780 (ast.clj:96)
    eastwood.copieddeps.dep1.clojure.tools.analyzer.utils/mapv' (utils.clj:208)
    eastwood.copieddeps.dep1.clojure.tools.analyzer.utils/mapv' (utils.clj:202)
    eastwood.copieddeps.dep1.clojure.tools.analyzer.ast/-update-children/fn--67768 (ast.clj:51)
    clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
    clojure.core/reduce (core.clj:6827)
    clojure.core/reduce (core.clj:6810)
    eastwood.copieddeps.dep1.clojure.tools.analyzer.ast/-update-children (ast.clj:49)
    eastwood.copieddeps.dep1.clojure.tools.analyzer.ast/-update-children (ast.clj:46)
    eastwood.copieddeps.dep1.clojure.tools.analyzer.ast/update-children-reduced (ast.clj:64)
    eastwood.copieddeps.dep1.clojure.tools.analyzer.ast/update-children-reduced (ast.clj:58)
    eastwood.copieddeps.dep1.clojure.tools.analyzer.ast/walk/walk--67779 (ast.clj:99)
    eastwood.copieddeps.dep1.clojure.tools.analyzer.ast/walk (ast.clj:95)
    eastwood.copieddeps.dep1.clojure.tools.analyzer.ast/walk (ast.clj:84)
    eastwood.copieddeps.dep1.clojure.tools.analyzer.ast/postwalk (ast.clj:115)
    eastwood.copieddeps.dep1.clojure.tools.analyzer.ast/postwalk (ast.clj:110)
    eastwood.copieddeps.dep1.clojure.tools.analyzer.ast/postwalk (ast.clj:113)
    eastwood.copieddeps.dep1.clojure.tools.analyzer.ast/postwalk (ast.clj:110)
    eastwood.copieddeps.dep1.clojure.tools.analyzer.passes/compile-passes/analyze--67910 (passes.clj:170)
    clojure.core/comp/fn--5807 (core.clj:2569)
    clojure.core/comp/fn--5807 (core.clj:2569)
    eastwood.analyze-ns/run-passes (analyze_ns.clj:206)
    eastwood.analyze-ns/run-passes (analyze_ns.clj:202)
    eastwood.copieddeps.dep2.clojure.tools.analyzer.jvm/analyze/fn--71639/fn--71641 (jvm.clj:521)
    eastwood.copieddeps.dep2.clojure.tools.analyzer.jvm/analyze/fn--71639 (jvm.clj:519)
    clojure.core/apply (core.clj:665)
    clojure.core/with-bindings* (core.clj:1973)
    clojure.core/with-bindings* (core.clj:1973)
    eastwood.copieddeps.dep2.clojure.tools.analyzer.jvm/analyze (jvm.clj:508)
    eastwood.copieddeps.dep2.clojure.tools.analyzer.jvm/analyze (jvm.clj:488)
    eastwood.copieddeps.dep2.clojure.tools.analyzer.jvm/analyze+eval (jvm.clj:584)
    eastwood.copieddeps.dep2.clojure.tools.analyzer.jvm/analyze+eval (jvm.clj:529)
    eastwood.analyze-ns/analyze-file/fn--72506/fn--72511/fn--72513 (analyze_ns.clj:407)
    eastwood.analyze-ns/analyze-file/fn--72506/fn--72511 (analyze_ns.clj:403)
    eastwood.analyze-ns/analyze-file/fn--72506 (analyze_ns.clj:400)
    eastwood.analyze-ns/analyze-file (analyze_ns.clj:398)
    eastwood.analyze-ns/analyze-file (analyze_ns.clj:314)
    eastwood.analyze-ns/analyze-ns/fn--72556 (analyze_ns.clj:514)
    eastwood.analyze-ns/with-form-writers (analyze_ns.clj:104)
    eastwood.analyze-ns/with-form-writers (analyze_ns.clj:102)
    eastwood.analyze-ns/analyze-ns (analyze_ns.clj:509)
    eastwood.analyze-ns/analyze-ns (analyze_ns.clj:487)
    eastwood.lint/lint-ns (lint.clj:321)
    eastwood.lint/lint-ns (lint.clj:300)
    eastwood.lint/lint-namespace (lint.clj:546)
    eastwood.lint/lint-namespace (lint.clj:544)
    eastwood.lint/eval75512/fn--75514/fn--75516 (lint.clj:569)
    clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
    clojure.core/reduce (core.clj:6827)
    clojure.core/reduce (core.clj:6810)
    eastwood.lint/eval75512/fn--75514 (lint.clj:567)
    clojure.lang.MultiFn.invoke (MultiFn.java:252)
    eastwood.lint/eastwood-core (lint.clj:630)
    eastwood.lint/eastwood-core (lint.clj:590)
    eastwood.lint/eastwood (lint.clj:738)
    eastwood.lint/eastwood (lint.clj:718)
    eastwood.lint/eastwood (lint.clj:719)
    eastwood.lint/eastwood (lint.clj:718)
    eastwood.lint/eastwood-from-cmdline (lint.clj:750)
    eastwood.lint/eastwood-from-cmdline (lint.clj:749)
    clojure.lang.Var.invoke (Var.java:384)
    eastwood.versioncheck/run-eastwood (versioncheck.clj:17)
    eastwood.versioncheck/run-eastwood (versioncheck.clj:11)
    user/eval67602 (form-init10778513256630036894.clj:1)
    user/eval67602 (form-init10778513256630036894.clj:1)
    clojure.lang.Compiler.eval (Compiler.java:7177)
    clojure.lang.Compiler.eval (Compiler.java:7167)
    clojure.lang.Compiler.load (Compiler.java:7636)
    clojure.lang.Compiler.loadFile (Compiler.java:7574)
    clojure.main/load-script (main.clj:475)
    clojure.main/init-opt (main.clj:477)
    clojure.main/init-opt (main.clj:477)
    clojure.main/initialize (main.clj:508)
    clojure.main/null-opt (main.clj:542)
    clojure.main/null-opt (main.clj:539)
    clojure.main/main (main.clj:664)
    clojure.main/main (main.clj:616)
    clojure.lang.Var.applyTo (Var.java:705)
    clojure.main.main (main.java:40)

The following form was being processed during the exception:
(use-fixtures :once (fixtures/initialize :db))

Shown again with metadata for debugging (some metadata elided for brevity):
^{:line 42} (^{:line 42} use-fixtures :once ^{:line 42} (^{:line 42} fixtures/initialize :db))
camsaul commented 3 years ago

Sorry, I figured it out. It was actually an issue with the arglist for fixtures/initialize -- not an issue with this form specifically

vemv commented 3 years ago

Got it, thanks! Maybe the error for when one makes a typo while writing :arglists could be clearer. At the same time, this comes from tools.analyzer so generally I like not to mess with 3rd-party deps much.