-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Disable all golangci linters and then enable the ones we want #2715
Comments
The list of the current disabled and not deprecated linters:
I quickly reviewed them and below are my suggestions. Good to have:
Something I think does make sense but not sure if we should enable it:
Do you see a case for it?
|
Thanks for the list @codebien 🙇
I would agree, but running it on the codebase returns Going through them - huge amount is config defaults. And I don't think that will make those better. It will just now be a constant somewhere which will be "defaultBatchPerHost" and then if you need to look it up - you will need to jump to it. Repeat that 100x times. Some of the others are file masks, which ... might be okay .. but I doubt we will have a package with file masks constants to imports so 🤷 And the majority of the rest magic numbers seem sensible. The bigger problem for some of them is that they are not documented on what they mean. And adding a name will help, but not always. So I am slightly 👎 at this points as this in practice requires more or less naming every constant number in the codebase. p.s.: with the increased count even more of them are arguably false positives. I don't know if this is literally us catching this all the time and fixing it in PRs. Or just the amount of actually "good" magical numbers to be much higher in this codebase, but it seems like we have quite a lot of things that I would not change.
I don't really care about this. It gave me 0 errors currently ... which I find sus. Looking at the things it does:
🤷 I find that I am okay with this being added I guess. Not certain how useful it is.
3 occurrences currently. Which also seems sus to be honest.
I am okay with that. The two current occurrences are If anything I find the default 10 methods to be way too big for an interface.
326 cases I figured out there is a default limit 🤦 With this many cases I am slightly less sure. There are quire a lot of errors. And again most of them likely get wrapped later on. And I don't really want our users to get an error that has been wrapped 5 times just to appease the linter. So ... uh kind of 👎
I don't intend on linting our dependencies. |
Status quo
Currently, we have golangci-lint config where we enable all linters, and then we go and disable a bunch of them. This has a few problems ranging from annoyance to in practice terrible UX unless the developer uses the make file to run the linters, which has other problems.
Basic update of golangci-lint
For starters each time we want to bump the version we currently have to discuss if any of the newly added (and now by our config enabled) linters should be disabled. Based on my memory - most of the times we disable all but a few. As most of them are just somebodies opinion as a linter with which we disagree. Also, most of the newly added linters have bugs which on our fairly big codebase we hit pretty heads on.
The (theoretical IMO) benefit here is that we might enable a really nice new linter.
The problem is that because we decided to do this at the same time we update the version, in practice we update the version very rarely. IMO this is mostly because someone now needs to go through the new linters, ask the team if they want them enabled or disabled ,wait for a week or two to get results back. And then make the changes and update - and ain't nobody got time for this.
We could probably just split the process in two : bump the version with all new linters disabled, and open an issue to discuss which one to enable back. This will help on this front but not on the others.
Due to the way we currently list the linters we do not want instead of the ones that we want to run, we will get breaking changes when one of those gets removed from golangci-lint. As far as I know this hasn't happened yet, but they have now deprecated a bunch and I would expect they will be removed at some point.
It also means that anyone running older version locally will get error if we disabled a linter that is from a newer one. This might be a good thing - making them update. But it also will break even if the newer version is just ... newer and hasn't actually added anything new that we use - which arguably is just bad UX.
The config does not tell you what we care about it tells you what we don't care about
The configuration will not tell anyone just by looking at it what linters we want to run, unless they know all the linters and can remove the one we don't care about.
This also has the problem of when we see a new linter - we don't know if we already have something similar enabled - you need to run
golanci-lint linters
and look at the output.Proposal:
gofmt
andgofumpt
for example)2
+3
as the way to update the golangci-lint and do that every once in a while - for example k6 release.This way developers:
p.s. the xk6-browser project already has done exactly this.
The text was updated successfully, but these errors were encountered: