Skip to content

Commit

Permalink
Add printf to vars linted by analyze-format (clj-kondo#2453)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomdl89 authored Dec 10, 2024
1 parent 4bac9e2 commit 2bedcd5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ For a list of breaking changes, check [here](#breaking-changes).

## Unreleased

- Add `printf` to vars linted by `analyze-format`. ([@tomdl89](https://github.com/tomdl89))
- [#2272](https://github.com/clj-kondo/clj-kondo/issues/2272): Report var usage in `if-let` etc condition as always truthy
- [#2272](https://github.com/clj-kondo/clj-kondo/issues/2272): Report var usage in `if-not` condition as always truthy
- [#2433](https://github.com/clj-kondo/clj-kondo/issues/2433): false positive redundant ignore with hook
Expand Down
2 changes: 1 addition & 1 deletion src/clj_kondo/impl/analyzer.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2478,7 +2478,7 @@
this-as (analyze-this-as ctx expr)
memfn (analyze-memfn ctx expr)
empty? (analyze-empty? ctx expr)
format (analyze-format ctx expr)
(format printf) (analyze-format ctx expr)
(use require)
(if top-level? (namespace-analyzer/analyze-require ctx expr)
(analyze-children ctx children))
Expand Down
3 changes: 3 additions & 0 deletions test/clj_kondo/format_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
(assert-submaps
'({:file "<stdin>", :row 1, :col 68, :level :error, :message "Format string expects 1 arguments instead of 2."})
(lint! "(require '[clojure.tools.logging :as l]) (l/errorf (ex-info \"\" {}) \"%s\" 1 2)"))
(assert-submaps
'({:file "<stdin>", :row 1, :col 9, :level :error, :message "Format string expects 2 arguments instead of 1."})
(lint! "(printf \"%s %s\" 1)"))
(is (empty? (lint! "(format \"%3$s\" 1 2 3)")))
(is (empty? (lint! "(format \"%3$s %s %s %s\" 1 2 3)")))
(is (empty? (lint! "(format \"%3$s %s %s %s %s\" 1 2 3 4)")))
Expand Down

0 comments on commit 2bedcd5

Please sign in to comment.