Automatic fixing of errors? #1673
Replies: 7 comments 1 reply
-
@reutsharabani clj-kondo works closely with the clojure-lsp project (of which @ericdallo is currently the most active maintainer) and clojure-lsp provides fixes/refactorings based on what clj-kondo finds. In short, I recommend using the clojure-lsp CLI for this. |
Beta Was this translation helpful? Give feedback.
-
I'd personally love this feature. Being able to do this directly through a CLI at git commit/push time would be amazing. I don't see an easy way to do this with clojure-lsp. We just added clj-kondo to a bunch of our projects and this would've saved us a ton of time. We had a ton of:
etc which all seem like they could be autofixed and I suspect this would dramatically improve developer adoption of tools like clj-kondo? Anyways @borkdude would love if this was reconsidered! |
Beta Was this translation helpful? Give feedback.
-
@vincentjames501 As said, clojure-lsp already has a lot of that and they offer a CLI to fix those things. I recommend trying it. /cc @ericdallo |
Beta Was this translation helpful? Give feedback.
-
Not sure all of that would be easy to make it work on clojure-lsp, first we would need to have the feature of fix each one of these findings to them provide them via CLI, I think we could start with a issue to discuss a little bit more |
Beta Was this translation helpful? Give feedback.
-
ESLint has the following which I really like from a CLI usage standpoint FWIW:
Rust has things like clippy to auto fix things, ruby has rubocop to auto fix issues, etc which are all amazing CLIs. |
Beta Was this translation helpful? Give feedback.
-
Aside from clojure-lsp there are a few projects that can automatically fix clj-kondo findings:
|
Beta Was this translation helpful? Give feedback.
-
My experience is that once you have fixed most initial things on a clojure project, you don't need that much "auto-fixing" anymore since you simply won't introduce any new clj-kondo warnings/errors. My most used "fix" is lsp-organize-imports of clojure-sort-ns (clojure-mode in emacs) for cleaning up an ns form. Other than that, none that I can think of. |
Beta Was this translation helpful? Give feedback.
-
To upvote this issue, give it a thumbs up. See this list for the most upvoted issues.
Is your feature request related to a problem? Please describe.
Some of the errors/warning that come up during lint are trivial but fixing them, especially on newly-linted projects or when adding new linters, is tedious.
Describe the solution you'd like
Maybe clj-kondo can supply a --fix flag that can rewrite code as recommended (where it makes sense). An example would be sorting imports. This exists in linters like eslint and rubocop.
Describe alternatives you've considered
Currently I am fixing manually, even trivial stuff. For my specific linter I've outputted as a warning the required form to solve the problem (which is deterministic).
Beta Was this translation helpful? Give feedback.
All reactions