Skip to content
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

feat: option to strictly follow Go autogenerated file convention #4507

Merged
merged 15 commits into from
Mar 15, 2024

Conversation

ldez
Copy link
Member

@ldez ldez commented Mar 14, 2024

The current autogenerated file detection is very lax and it's expected (#48, #72).

But in some cases, this can be a problem.

Then I added an option to strictly follow Go autogenerated file convention.

To convey to humans and machine tools that code is generated, generated source should have a line that matches the following regular expression (in Go syntax):

^// Code generated .* DO NOT EDIT\.$

This line must appear before the first non-comment, non-blank text in the file.
https://go.dev/s/generatedcode

The strict mode can be extended with simple run.skip-dirs or run.skip-files.

One commit, one change.

Fixes #4506
Fixes #2254

@ldez ldez added enhancement New feature or improvement area: processors labels Mar 14, 2024
@ldez ldez added this to the next milestone Mar 14, 2024
@ldez ldez mentioned this pull request Mar 14, 2024
5 tasks
@ldez ldez changed the title feat: option to strictly follow Go autogenerated file detection feat: option to strictly follow Go autogenerated file convention Mar 14, 2024
Copy link
Member

@bombsimon bombsimon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Would you like to deprecate the old variant at some point? It feels like supporting anything that is not the Go convention is a bad idea and if you want to do that it would make more sense to use skip-dirs or skip-files but I also see the convenience keeping it and having the strict version as opt-in.

jsonschema/golangci.next.jsonschema.json Show resolved Hide resolved
pkg/result/processors/autogenerated_exclude.go Outdated Show resolved Hide resolved
@ldez
Copy link
Member Author

ldez commented Mar 14, 2024

Would you like to deprecate the old variant at some point?

Maybe just change the default (but it's breaking), because I think some people rely on that.

it would make more sense to use skip-dirs or skip-files

I think skip-dirs or skip-files should be deprecated and replaced by something in the issues section with a relevant name.
Because skip-xxx are skipping nothing 😄

@ldez ldez merged commit b05e397 into golangci:master Mar 15, 2024
12 checks passed
@ldez ldez deleted the feat/improve-exclude branch March 15, 2024 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: processors enhancement New feature or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issues in gqlgen resolvers are ignored Unexpected detection of file as autogenerated skipped all linters
3 participants