-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Unexpected detection of file as autogenerated skipped all linters #2254
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
Comments
Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors. |
As it stands with a project with a number of autogenerated mock files, turning on debug to catch something that is accidental such as this would be quite cumbersome. Right now it was caught because I seem to spot lint mistakes in code and was left wondering why they weren't caught automatically, but my colleagues didn't see any issue until I mentioned it. Would it be better to have both a strict set of strings and a lax set of strings and let end users select which to use? Or to have an option that warns on files that only match a lax set unless they or their pattern is listed in the config to not warn? |
I checked for another match of the @golangci/team I would propose to abandon partial matches and switch to only checking "idiomatic" pattern used almost everywhere else ( see
|
It might be nice to be able to customize the generated code comment pattern with config yaml. |
I think this sound like the way to go and I don't think there's a big risk introducing this change since the amount of code that uses a non recommended pattern but has been ignored and still contains linting issues must be pretty limited. I don't think having a configuration parameter for this is the way to go since it's very clear to me that the documentation only recommends one exact pattern and that's what I'm used to see and use. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Fixed by #4507 |
Welcome
Description of the problem
Detection of auto generated files based on the string
code generated
can be a little wide and ended up picking up a file that had the text before the imports:It appears it is a deliberate choice to be less strict with matching compared to https://pkg.go.dev/cmd/go#hdr-Generate_Go_files_by_processing_source.
The problem is that, the only reason this was spotted was that I noticed some lines that looked like they should have failed linting. Otherwise the changes would have been committed as is with issues that should have been flagged by the linter.
There does not appear to be any way to easily catch this besides linting with debug enabled and checking the files detected as autogenerated against a separate list to ensure no accidental detection's are occurring.
Version of golangci-lint
Configuration file
Go environment
I've had to replace some of the details due it having references to employer private org and UID.
Verbose output of running
Code example or link to a public repository
https://github.com/electrofelix/golangci-lint-bug-demo
The text was updated successfully, but these errors were encountered: