Skip to content

Commit

Permalink
Fix self-lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
tomdl89 committed Dec 9, 2024
1 parent 7d75424 commit 44d012d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.
37 changes: 16 additions & 21 deletions src/clj_kondo/impl/analyzer.clj
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,9 @@
:top-level? top-level?
:arg-types (if add-new-arg-types?
(let [[k v] (first callstack)]
(if (and (symbol? k)
(symbol? v))
(atom [])
nil))
(when (and (symbol? k)
(symbol? v))
(atom [])))
(:arg-types ctx))
:len len)]
(into []
Expand Down Expand Up @@ -1971,10 +1970,10 @@
keep keep-indexed])
arg-count (if (and transducer-eligable?
(zero? arg-count)) ;; transducer
(if (and core-ns?
(or (= 'map hof-resolved-name)
(= 'mapcat hof-resolved-name)))
nil 1)
(when-not (and core-ns?
(or (= 'map hof-resolved-name)
(= 'mapcat hof-resolved-name)))
1)
arg-count)
ctx (update ctx :callstack
(fn [cs]
Expand Down Expand Up @@ -2113,9 +2112,8 @@
;; see https://clojure.org/reference/java_interop#dot
(findings/warn-reflection ctx expr)
(let [[instance meth & args] children]
(if instance (analyze-expression** ctx instance)
;; TODO, warning, instance is required
nil)
;; TODO, warning if no instance. Instance is required
(when instance (analyze-expression** ctx instance))
(when meth
(if (and (identical? :list (utils/tag meth)) (not args))
(let [[meth & children] (:children meth)]
Expand Down Expand Up @@ -2246,10 +2244,9 @@
(update ctx :config config/merge-config! cfg)
ctx)
prev-callstack (:callstack ctx)
arg-types (if (and resolved-namespace resolved-name
(not (linter-disabled? ctx :type-mismatch)))
(atom [])
nil)
arg-types (when (and resolved-namespace resolved-name
(not (linter-disabled? ctx :type-mismatch)))
(atom []))
ctx (assoc ctx :arg-types arg-types)]
(cond unresolved-ns
(do
Expand Down Expand Up @@ -2715,9 +2712,8 @@
expr-meta (meta expr)
resolved-namespace :clj-kondo/unknown-namespace
ctx (update ctx :callstack conj [nil :token])
arg-types (if (not (linter-disabled? ctx :type-mismatch))
(atom [])
nil)
arg-types (when-not (linter-disabled? ctx :type-mismatch)
(atom []))
ctx (assoc ctx :arg-types arg-types)
analyzed
(let [next-ctx ctx]
Expand Down Expand Up @@ -3234,10 +3230,9 @@
update base-lang into (:used-namespaces init-ns))
(loop [ctx init-ctx
[expression & rest-expressions] expressions]
(if expression
(when expression
(let [ctx (analyze-expression* ctx expression)]
(recur ctx rest-expressions))
nil))))
(recur ctx rest-expressions))))))

;;;; processing of string input

Expand Down
3 changes: 1 addition & 2 deletions src/clj_kondo/impl/linters.clj
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,7 @@
:message (str
(format "#'%s is deprecated"
(str fn-ns "/" fn-name))
(if (true? deprecated)
nil
(when-not (true? deprecated)
(str " since " deprecated)))})))
(when called-fn
(when-let [loc (:redundant-fn-wrapper-parent-loc call)]
Expand Down

0 comments on commit 44d012d

Please sign in to comment.