diff --git a/CHANGELOG.md b/CHANGELOG.md index ea05413a78..41aaea6f6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/clj_kondo/impl/analyzer.clj b/src/clj_kondo/impl/analyzer.clj index 557c6b2d8f..7a091cf932 100644 --- a/src/clj_kondo/impl/analyzer.clj +++ b/src/clj_kondo/impl/analyzer.clj @@ -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)) diff --git a/test/clj_kondo/format_test.clj b/test/clj_kondo/format_test.clj index 9d6a507fe7..e6edbf8a4f 100644 --- a/test/clj_kondo/format_test.clj +++ b/test/clj_kondo/format_test.clj @@ -17,6 +17,9 @@ (assert-submaps '({:file "", :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 "", :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)")))