Skip to content

Commit

Permalink
Fix clj-kondo#1786: support gen-interface (clj-kondo#2418)
Browse files Browse the repository at this point in the history
* Add test

* Fix clj-kondo#1786: support gen-interface
  • Loading branch information
borkdude authored Nov 1, 2024
1 parent 7735785 commit e8f0a6f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ For a list of breaking changes, check [here](#breaking-changes).
- [#1784](https://github.com/clj-kondo/clj-kondo/issues/1784): detect `:redundant-do` in `catch`
- [#2410](https://github.com/clj-kondo/clj-kondo/issues/2410): add `--report-level` flag
- [#2416](https://github.com/clj-kondo/clj-kondo/issues/2416): detect empty `require` and `:require` forms ([@NoahTheDuke](https://github.com/NoahTheDuke))
- [#1786](https://github.com/clj-kondo/clj-kondo/issues/1786): Support `gen-interface` (by suppressing unresolved symbols)

## 2024.09.27

Expand Down
7 changes: 7 additions & 0 deletions src/clj_kondo/impl/analyzer.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2062,6 +2062,12 @@
(swap! (:namespaces ctx) assoc-in [base-lang lang current-ns :gen-class] true)
nil)

(defn analyze-gen-interface [ctx expr]
;; for now we just ignore the form to not cause false positives
;; we can add more sophisticated linting, e.g. causing -init to be used
(let [ctx (utils/ctx-with-linter-disabled ctx :unresolved-symbol)]
(analyze-children ctx expr)))

(defn analyze-extend-type-children
"Used for analyzing children of extend-protocol, extend-type, reify and specify! "
[ctx children defined-by defined-by->lint-as]
Expand Down Expand Up @@ -2484,6 +2490,7 @@
(analyze-hof ctx expr resolved-as-name resolved-namespace resolved-name)
(ns-unmap) (analyze-ns-unmap ctx base-lang lang ns-name expr)
(gen-class) (analyze-gen-class ctx expr base-lang lang ns-name)
(gen-interface) (analyze-gen-interface ctx expr)
(exists?) (analyze-cljs-exists? ctx expr)
(with-precision) (analyze-with-precision ctx expr children)
(var) (analyze-var ctx expr children)
Expand Down
7 changes: 6 additions & 1 deletion test/clj_kondo/main_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1969,7 +1969,12 @@ foo/foo ;; this does use the private var
{:linters {:unresolved-symbol {:level :error}}}
"--lang" "cljs")))
(is (empty? (lint! "(def Vec 1)"
{:linters {:redefined-var {:level :error}}}))))
{:linters {:redefined-var {:level :error}}})))
(is (empty? (lint! "(ns a.b.c)
(gen-interface
:name a.b.c.Foo
:methods [[bar [String] Object]])"
{:linters {:unresolved-symbol {:level :error}}}))))

(deftest tagged-literal-test
(is (empty?
Expand Down

0 comments on commit e8f0a6f

Please sign in to comment.