Releases: NoahTheDuke/splint
v1.19.0
v1.18.0
New Rules
lint/defmethod-names
: Require thatdefmethod
calls define a name for the function body. This helps improve stack traces. Suggested names are built from the dispatch value and cannot be trusted to be unique or usable, so while the rule is safe, it does not support autocorrect. Disabled by default.
Fixed
style/is-eq-order
relaxed expected input to accept any non-quoted list. (See #25.)
v1.17.1
Fixed
- Autocorrect skips quoted forms.
- Autocorrect only saves non-empty files.
- Autocorrect removes all rules that don't have
:autocorrect
. --interactive
has been added to the CLI options, making it usable. (oops)--interactive
now applies:autocorrect
so it doesn't need to be specified.
v1.17.0
Big feature: Safety and Autocorrection
Every rule has been marked as safe or unsafe. Safe rules don't generate false positives and any suggested alternatives can be used directly. Unsafe rules may generate false positives or their suggested alternatives may contain errors.
Rules that are safe may also perform autocorrection, which is tracked in defrule
with :autocorrect
. Rules may only perform autocorrection if they're safe.
The Rules Overview has been expanded as well.
Changed
- Update dependencies.
edamame
1.4.27 supports the Clojure 1.12 array syntax:Integer/1
. - Rules documentation can now handle 3 different directives:
@note
,@safety
, and@examples
. All existing# Examples
have been converted to@examples
, and the relevant rule docstrings have been updated. - Rules documentation generation has been changed to handle the above.
- Added
:autocorrect
todefrule
,:safe
to config schema.
Fixed
lint/redundant-str-call
ignores when used in threading macros. (See #20.)lint/redundant-call
ignores when used in threading macros. (See #21.)- Fix matching
nil
when input is too short in patterns, which fixes subtle issues withlint/cond-else
. - Make
support-clojure-version?
only compare minor versions if major version numbers match, and likewise with incremental/minor version numbers.
v1.16.0
New rules
lint/redundant-call-str
: Don't callstr
on input that's guaranteed to be a string: Prefer"foo"
to(str "foo")
,(str "foo" bar)
to(str (str "foo" bar))
, and(format "foo%s" bar)
to(str (format "foo%s" bar))
. (See clj-kondo#2323 for inspiration.)lint/duplicate-case-test
: Don't use the same case test constant more than once.lint/locking-object
: Prefer to lock on a symbol bound to(Object.)
.
Added
--only RULE
cli flag to run only specified rules or genres. Can be used multiple times. (#13)
Changed
- Switched from
clojure.pprint
to fipp for pretty-printing code. Fast and easy to extend. - Use org.flatland/ordered (when run in Clojure) to keep parsed maps and sets in their read order.
- Add exceptions to diagnostics and print stack traces in all errors. Should fix bugs where all that's printed is
Splint encountered an error: ""
which is unhelpful and shameful. - External links in
default.edn
are now:links
, a vector of strings. This allows for listing multiple references. - Switch all tests to Lazytest to do some dogfooding.
- Enforce that
??
only 1 or 2 arguments, and if provided, that the predicate is a symbol. - Updated all dependencies.
- Switch tests to use Lazytest.
Fixed
- Outputs
json
andjson-pretty
now work with Babashka, by relying on Babashka's built-inchehire.core
instead ofclojure.data.json
. This shouldn't result in any observable differences. I'd usecheshire.core
for both, butcheshire.core
is much bigger and more complicated thanclojure.data.json
, and it's a pain in the ass imo.
v1.15.2
Changed
- Expanded documentation, added CONTRIBUTING.md.
- Switch all existing uses of
deftest
(including innew_rule.tmpl
) back to usingdefexpect
. Sean fixed the 3-arg issue when I raised it in clojure-expectations/clojure-test#35, and it's nice to only import a single namespace instead of multiple. - Add table of namespaces to aliases in
naming/conventional-aliases
docs. naming/record-name
now usescamel-snake-kebab
to check and convert the given record name to PascalCase.- Add
:method-value
style tostyle/new-object
to suggestFoo/new
instead ofFoo.
. - Disable
lint/dot-class-method
andlint/dot-obj-method
whenlint/prefer-method-values
is enabled. - Track rules on ctx instead of passing as a separate argument in
runner
functions. - Move rules from
(:config ctx)
to(:rules ctx)
as map of rule-name to rule map. Add(:rules-by-type ctx)
, a map of simple-type to vector of rule names. Changecheck-all-rules-of-type
to reduce over rule names and pull the rule map fromctx
.
Fixed
- Remove incorrect guide-ref in
lint/duplicate-field-name
. - Get auto-gen-config working again. (See #16)
v1.15.1
Changed
- Updated all rules examples to use "avoid" and "prefer" instead of "bad" and "good". This aligns closer with Splint's perspective on the issues found.
- Updated configuration docs to be more explicit about enabling and disabling rules and the use of
global
. (See #11 and #12)
Fixed
- False positive in
lint/assoc-fn
whenf
is a macro. Coveredor
explicitly, no good generalized solution at the moment. (See #15.) --print-config
properly includes the genre of printed rules.
v1.15.0
New Rules
style/is-eq-order
: Prefer(is (= 200 status))
over(is (= status 200))
when writing assertions.style/prefer-for-with-literals
: Prefer(for [item coll] {:a 1 :b item})
over(map #(hash-map :a 1 :b %) coll)
. (See #10.)
Added
-r
/--require
cli flag that can be used multiple times andrequire
top-level config option that takes a vector of strings. These are loaded withload-file
at run-time to allow for custom rules to be written and used. (See #8.) This is inherently unsafe, so don't run code you don't know.
Changed
- Slight change to the patterns, now a final-position
?*
or?+
will immediately return the rest of the current input instead of accumulating it one-by-one. - Reformatted every file to use Tonsky's Better Clojure formatting.
lint/warn-on-reflection
now checks that the file contains a properns
form before issuing a diagnostic.- Updated README speed comparison chart.
v1.14.0
Changed
-
General performance increases in rules:
lint/body-unquote-splicing
lint/if-else-nil
lint/underscore-in-namespace
lint/warn-on-reflection
metrics/parameter-count
naming/conversion-function
naming/predicate
naming/record-name
naming/single-segment-namespace
style/def-fn
style/eq-zero
style/prefer-clj-string
style/prefer-condp
style/reduce-str
style/single-key-in
style/tostring
style/useless-do
-
Remove documentation about
?_
short form, as it's covered by the existing?
and_
binding rules. -
Expand
?foo
short-forms in patterns to their(? foo)
special form. Simplifies matching functions, makes the pattern DSL more consistent. Now?|foo
will throw immediately instead of part-way through macroexpansion. -
Updated pattern docs with a small example at the top.
-
Simplified
?|
matcher logic to use a set, as that's faster than creating multipleread-form
patterns in a let block and checking each one.
Fixed
- Correctly suggest
Obj/staticMethod
when given(. Obj (staticMethod))
inlint/dot-class-usage
. - Only suggest
naming/conversion-functions
when there's no-
in the part before-to-
. (Will warn onf-to-g
, will not warn onexpect-f-to-c
.) - Correctly render args in
lint/assoc-fn
.
v1.13
New Rules
lint/prefer-method-values
: Prefer(^[] String/toUpperCase "noah")
to(.toUpperCase "noah")
. Enabled by default.lint/require-explicit-param-tags
: Prefer(^[File] File/mkdir (io/file \"a\"))
to(File/mkdir (io/file \"a\"))
. Prefer(^[String String] File/createTempFile \"abc\" \"b\")
to(^[_ _] File/createTempFile \"abc\" \"b\")
. Has:missing
,:wildcard
, and:both
styles, which check for lack of any:param-tags
, usage of_
in a:param-tags
, and both. Defaults to:wildcard
. Disabled by default.
Changed
- Add support for
lint/prefer-method-values
inperformance/dot-equals
. - Switch
new_rule.tmpl
to usedeftest
.defexpect
is a thin wrapper and has the annoying "if given two non-expect entries, wrap in expect", which doesn't work when we use custom expect macros.