Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation explaining the different mistakes/style issues detected #936

Closed
Tiv0w opened this issue Jul 19, 2020 · 5 comments
Closed

Documentation explaining the different mistakes/style issues detected #936

Tiv0w opened this issue Jul 19, 2020 · 5 comments

Comments

@Tiv0w
Copy link

Tiv0w commented Jul 19, 2020

Problem

Hello, I'm a super beginner with Clojure, and using clj-kondo I'm sometimes not helped at all. I make mistakes in my code (which is normal as a beginner), clj-kondo tells me about these errors, but I absolutely don't know what to do with an information like:

file.clj:36:5: warning: inline def

I'm willing to refactor it to something better, but I don't know what to refactor it to!
I also don't know if it's a logic issue or a style issue.

Solution

At least a simple Markdown or text file to list and document the potential errors/warnings thrown by clj-kondo, and indications on how to refactor them (in my above example: change inline def to a let binding).

Alternatives

Rust tooling provides with the linter a --explain [ERROR CODE] command, which prints a small explanation of the error, and most of the times how to remedy to the given error.


I could try to collect and gather information and documentation about the errors as I learn and then open a PR, but I think we're all better off with the documentation of someone who actually knows Clojure and why those errors are being reported. (Not me 😇 )

@borkdude
Copy link
Member

Thanks! I think that would certainly be good to add. I've also been meaning to add a full list of all possible linters for the configuration page (https://github.com/borkdude/clj-kondo/blob/macros-sci/doc/config.md).

As for inline def, this means that you are using def within a def or defn. This isn't idiomatic Clojure. For the inner def you should probably use let. More about the explanation of the term inline def here:

https://blog.michielborkent.nl/2017/05/25/inline-def-debugging/

@borkdude borkdude added this to Needs triage in clj-kondo via automation Jul 19, 2020
@borkdude borkdude moved this from Needs triage to Medium priority (new / enhance) in clj-kondo Jul 19, 2020
@Tiv0w
Copy link
Author

Tiv0w commented Jul 20, 2020

Adding a list of the linters would really help newcomers as well!
I really appreciate that you're open to suggestions, and in particular to help newbies like me.

And yeah, after some Googling, and some docs reading, I found out why the inline def error and corrected it in my code.

Anyway, thanks for clj-kondo and helping a beginner like me start with some notions of idiomatic Clojure! 🎉

@borkdude borkdude self-assigned this Aug 20, 2020
@borkdude borkdude moved this from Medium priority (new / enhance) to High priority (next release) in clj-kondo Aug 20, 2020
@borkdude borkdude moved this from High priority (next release) to In progress in clj-kondo Sep 8, 2020
@borkdude borkdude moved this from In progress to High priority (next release) in clj-kondo Sep 27, 2020
@borkdude borkdude moved this from High priority (next release) to Medium priority (new / enhance) in clj-kondo Oct 4, 2020
@borkdude borkdude moved this from Medium priority (new / enhance) to In progress in clj-kondo Dec 4, 2020
@borkdude borkdude moved this from In progress to Next release in clj-kondo Dec 4, 2020
borkdude added a commit that referenced this issue Dec 4, 2020
@borkdude
Copy link
Member

borkdude commented Dec 4, 2020

@Tiv0w The list is now available here: https://github.com/borkdude/clj-kondo/blob/master/doc/linters.md.
Let me know what you think.

@vemv
Copy link
Contributor

vemv commented Dec 8, 2020

Looks great to me!

It will help me upgrade a project which was using an old clj-kondo dep.

(I assume the list is exhaustive)

@borkdude
Copy link
Member

borkdude commented Dec 8, 2020

@vemv Yes, the list is (or should be) exhaustive.

clj-kondo automation moved this from Next release to Done Dec 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
clj-kondo
  
Done
Development

No branches or pull requests

3 participants