-
Notifications
You must be signed in to change notification settings - Fork 59
ci: run golangci-lint #437
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
base: main
Are you sure you want to change the base?
Conversation
3ab307c
to
5a2121f
Compare
Hm, with the current configuration we are at 334 found issues - now I wonder if we should just accept the current issues and just disallow new ones, or refine the list of enabled linters. Quite a few ones are definitely helpful - we have for example many cases where we create new errors on the fly, which would be better solved by defining constants. Do you have any cool default set to use, @ccoVeille ? |
I do ! https://github.com/ccoVeille/golangci-lint-config-examples Please also note, the settings you chose might seem pretty complete, while it isn't. You cannot imagine, trust me. linters:
enable-all: true
disable:
# all currently deprecated linters
- execinquery
- exportloopref
- gomnd And it's not your fault. Many golangci-lint linters are using default rulesets that all pretty lax, and not strict. There are a lot of things to enable in govet, gocritict, staticcheck, revive to get interesting settings. Please note, not all of them are interesting. Some are in forcing rules barely no one want. Such as "never reuses a variable for error, define new one". Discovering, enabling, and configuring linters is a journey, as interesting and perilous than going to the Mordor. You can lose yourself. That's why I created my project of examples of golangci-lint configuration examples. BTW, I think I will have to update my README file with something close to what I just wrote. EDIT: I opened |
Then to reply your questions about what could be the path to enable and fix the issues. I would say the strategy depends on the time you want to spend on fixing the issues golangci-lint may report. I would say it's important to also do not block contributions to project. There are many ways to achieve this. Define a Then you have multiple options:
So here, you have somehow to fix the issues reported by this configuration files before enforcing the CI to block them. Otherwise, you block contributions.
This feature is there to say "OK, old code sucks, we know that, but we want new code to be clean" Both option can be used at same time, or separately. Everything is a matter of balance:
It seems to be complex, but the gain is real. Also, don't be afraid, it's a journey, time is needed, but there are multiple rewards in trying such a quest:
I talked a lot, I hope I didn't afraid you. It's a very interesting and fascinating topic. I can help of course, even if I'm less active right now for personal reason. |
I was hoping for such a good base configuration to get started - and 17 issues is much more manageable that over 300. Fixing the first set of issues was quite easy, but now I'm a bit stuck on how to handle the remaining three:
|
09e0657
to
113f2c1
Compare
Since this was done with the go1.24 migration differently, I just remembered that printing the errors as strings should be the simpler approach.
…ove the arg then remove the now unused variables and arguments from the functions earlier in the callchain
Since @ccoVeille mentioned it in #434, I thought we should give it a spin.