Skip to content

Commit

Permalink
[clj-kondo#950] Fix resolving class names
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Aug 6, 2020
1 parent 365ac5f commit de925fa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/clj_kondo/impl/namespace.clj
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,11 @@
(update ns :imports merge imports)))
nil)

(defn class-name? [s]
(let [splits (str/split s #"\.")]
(and (> (count splits) 2)
(Character/isUpperCase ^char (first (last splits))))))
(defn class-name? [^String s]
(when-let [i (str/last-index-of s \.)]
(let [should-be-capital-letter-idx (inc i)]
(and (> (.length s) should-be-capital-letter-idx)
(Character/isUpperCase ^char (.charAt s (inc i)))))))

(defn reg-unresolved-symbol!
[{:keys [:namespaces] :as _ctx}
Expand Down
3 changes: 2 additions & 1 deletion test/clj_kondo/main_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1751,7 +1751,8 @@ foo/foo ;; this does use the private var
{:linters {:type-mismatch {:level :error}}})))
(is (empty? (lint! "(def x) (doto x)")))
(is (empty? (lint! "(def ^:private a 1) (let [{:keys [a] :or {a a}} {}] a)"
{:linters {:unused-binding {:level :warning}}}))))
{:linters {:unused-binding {:level :warning}}})))
(is (empty? (lint! "(scala.Int/MinValue)" {:linters {:unresolved-symbol {:level :error}}}))))

(deftest proxy-super-test
(is (empty? (lint! "
Expand Down

0 comments on commit de925fa

Please sign in to comment.