Skip to content

Releases: NoahTheDuke/splint

v1.19.0

26 Nov 20:22
Compare
Choose a tag to compare

New Rules

  • style/redundant-nested-call: Prefer (+ 1 2 3 4) to (+ 1 2 (+ 3 4)).

Added

  • Table of Contents to each of the rules pages.

Fixed

  • style/into-literal ignores when in a threaded context.
  • lint/def-fn ignores when in a syntax-quoted context.

v1.18.0

03 Oct 16:16
Compare
Choose a tag to compare

New Rules

  • lint/defmethod-names: Require that defmethod 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

20 Sep 19:20
Compare
Choose a tag to compare

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

08 Sep 20:05
Compare
Choose a tag to compare

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 to defrule, :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 with lint/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

08 Aug 15:27
Compare
Choose a tag to compare

New rules

  • lint/redundant-call-str: Don't call str 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 and json-pretty now work with Babashka, by relying on Babashka's built-in chehire.core instead of clojure.data.json. This shouldn't result in any observable differences. I'd use cheshire.core for both, but cheshire.core is much bigger and more complicated than clojure.data.json, and it's a pain in the ass imo.

v1.15.2

09 May 13:13
Compare
Choose a tag to compare

Changed

  • Expanded documentation, added CONTRIBUTING.md.
  • Switch all existing uses of deftest (including in new_rule.tmpl) back to using defexpect. 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 uses camel-snake-kebab to check and convert the given record name to PascalCase.
  • Add :method-value style to style/new-object to suggest Foo/new instead of Foo..
  • Disable lint/dot-class-method and lint/dot-obj-method when lint/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. Change check-all-rules-of-type to reduce over rule names and pull the rule map from ctx.

Fixed

  • Remove incorrect guide-ref in lint/duplicate-field-name.
  • Get auto-gen-config working again. (See #16)

v1.15.1

09 May 13:12
Compare
Choose a tag to compare

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 when f is a macro. Covered or explicitly, no good generalized solution at the moment. (See #15.)
  • --print-config properly includes the genre of printed rules.

v1.15.0

01 May 14:54
Compare
Choose a tag to compare

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 and require top-level config option that takes a vector of strings. These are loaded with load-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 proper ns form before issuing a diagnostic.
  • Updated README speed comparison chart.

v1.14.0

19 Feb 14:50
Compare
Choose a tag to compare

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 multiple read-form patterns in a let block and checking each one.

Fixed

  • Correctly suggest Obj/staticMethod when given (. Obj (staticMethod)) in lint/dot-class-usage.
  • Only suggest naming/conversion-functions when there's no - in the part before -to-. (Will warn on f-to-g, will not warn on expect-f-to-c.)
  • Correctly render args in lint/assoc-fn.

v1.13

14 Feb 14:12
Compare
Choose a tag to compare

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 in performance/dot-equals.
  • Switch new_rule.tmpl to use deftest. 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.