Fork me on GitHub
#clj-kondo
<
2022-09-06
>
Rachel Westmacott16:09:18

Hi all, enjoying clj-kondo gratitude !

Rachel Westmacott16:09:35

Is there a line-length linter that I'm too foolish to find?

borkdude16:09:35

@peterwestmacott Thank you! clj-kondo does not lint whitespace or length of lines (currently)

eskos12:09:40

Maybe it’s good to stay away from this debate, line length tends to be a very political and emotion filled subject… 🙂

Rachel Westmacott16:09:18

Okay! - is that deliberate choice, or just it's not seemed important enough yet?

borkdude16:09:47

the latter

👍 1
borkdude16:09:16

I think you could write one in bb maybe ;)

borkdude16:09:07

I haven't heard many people ask about this, but if you want, you can check if there's already an existing issue or create a new one and then we can see if people have interest

👍 1
borkdude08:09:01

Yes! In the original template there is a snippet like "if you like this feature, upvote it with a thumbs up". You could leave that in

1
borkdude08:09:19

Then I can sort issues to see what people are most interested in

borkdude08:09:58

I think the implementation for this would be pretty easy: walk over the whole file input and emit a lint warning when a line is longer

Rachel Westmacott08:09:58

I know nothing about the internals of clj-kondo, but it certainly sounds like a simple thing to check for.

borkdude08:09:27

so basically, every file being linted passes through here: https://github.com/clj-kondo/clj-kondo/blob/27a12984042afc7dc3d11327f4573a73f51176e3/src/clj_kondo/impl/analyzer.clj#L2725 the input argument is the file contents as string

borkdude08:09:54

When a line is longer than a certain value, you call (findings/reg-finding! ...) and that's basically it

Rachel Westmacott08:09:11

Are you saying this because it is interesting, or because you hope I will submit a PR? (it might work)

borkdude08:09:33

If you're up for a PR, sure

🆗 1
Rachel Westmacott08:09:36

(or for some third reason I've not considered)

borkdude19:09:47

Tested it locally, works!

borkdude19:09:57

I think I'll leave it on for personal use ;)

borkdude19:09:08

Merged. Congrats and thanks.

🎉 2
borkdude12:09:14

@peterwestmacott Have you considered cases like this?

borkdude14:09:51

What would you do in this case?

Rachel Westmacott14:09:15

I don't know. :thinking_face:

borkdude14:09:33

What do other linters do here?

Rachel Westmacott14:09:07

Again I don't know. I imagine they complain, because the line is too long.

Rachel Westmacott14:09:28

Are you suggesting that this particular line length might be legitimate?

Rachel Westmacott14:09:20

To my mind it is too long and shouldn't be allowed, but I can see that pragmatically that could be annoying.

Rachel Westmacott14:09:42

It seems to point at a fundamental issue with URL length

Rachel Westmacott14:09:23

I could imagine a 'softer' version of the linter that only looked for whitespace beyond the desired line length. That way if your line was too long, but you could argue that you 'didn't have a chance to break it' it would let you off.

borkdude14:09:54

> Are you suggesting... No, I honestly don't know

Rachel Westmacott14:09:44

Afk rn or I'd check on lein bikeshed to see how it behaves, but I'd put money on it complaining.

borkdude14:09:08

@U051BLM8F: What does rubocop do in cases of long urls that can't be broken?

Rachel Westmacott14:09:19

One could say "use a URL shortener" or "link to your issuer tracker and put the super long URL in there"

borkdude14:09:30

or long strings for that matter

didibus05:01:11

I know some linters make an exception for lines with no space in them, such as a url