-
Notifications
You must be signed in to change notification settings - Fork 41
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
Skip analysis of generated files #148
Skip analysis of generated files #148
Conversation
Thanks! I think this makes sense! Either you're not in control of the generator and can't do anything about it or you are and should fix the generator. Since generated files usually shouldn't be edited I can't think of a reason to not do this or make it an opt-in and just always ignore them.
@kseniadumpling There were some flakes in CI that got fixed, can you rebase on |
52dcdb2
to
99d9859
Compare
@bombsimon sure! |
Hi @bombsimon |
Not at all, thanks for the ping and patiently waiting! This was a miss by me, I've tagged v4.3.0 with this change included. Hope that helps! |
Yep, thanks a lot! |
First, I agree with skipping generated files, but there is a missing case here: when you work on a generator. When you work on a generator, you try to generate "right" files, so you need linters. I think it should be an option. |
Thanks for your input! To me this feels like a rare edge case. I think this is reasonable for linters that check for bugs or security issues but for styling it makes less sense since you're likely not going to read (and never change) generated code. Although not an optimal flow, a workaround if you're the author of the generator and want the code to be linted could be to simply avoid adding the
I created PR #152 to add a flag, PTAL and let me know if this is what you had in mind @ldez |
Hi! I have a suggestion to make, hope you don't mind :)
Since
golangci-lint
doesn't support SuggestedFixes (golangci/golangci-lint#1779), in my project I callwsl --fix
separately. And it turns out that the linter fixes everything, including generated files (for example, files that are generated by protoc-gen-go).This PR suggest to skip such files. It uses
ast.IsGenerated(file *ast.File)
as recommended in golang/go#43481 and golang/go#28089