build: Exclude generated files from golangci-lint#4338
Conversation
Explicitly exclude the large auto-generated files from golangci-lint's linters and formatters, as discussed in google#4070: github/github-accessors.go, github/github-accessors_test.go, github/github-iterators.go, github/github-iterators_test.go, github/github-stringify_test.go (~3.7 MB total) These are produced by script/generate.sh and are verified by check-generated, go build, and go test, so excluding them from lint/format loses no coverage. Note: this did not measurably change lint/format wall-clock time (see the PR description for before/after numbers) -- golangci-lint loads and type-checks whole packages, so excluded files are still parsed. The change is kept for explicitness and to stop the formatters from reformatting generated output. Fixes google#4070
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4338 +/- ##
=======================================
Coverage 97.48% 97.48%
=======================================
Files 193 193
Lines 19417 19417
=======================================
Hits 18929 18929
Misses 270 270
Partials 218 218 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@JamBalaya56562 - according to the description above, this PR makes zero difference. And in fact, for developers who actually are tweaking the So I'm thinking that this PR is NOT desireable and should be closed. Or am I missing something? |
|
Also, it certainly does NOT fix #4070. |
|
You're right on both counts — thanks. The numbers show no wall-clock improvement, and more importantly your second point is valid: excluding the generated files would hide linter warnings on the regenerated output for anyone working on the Agreed that it doesn't fix #4070 either — I've dropped that keyword. For context on #4070: this generated-file exclusion was the last open item there (the performance-relevant work — custom-gcl caching #4116/#4119, formatter/linter cleanup #4094/#4097 — is already merged, and the revive/gci changes were declined). Since this last item turns out to be undesirable rather than just neutral, I think #4070 itself can be closed, but I'll leave that to you. |
Excludes the large auto-generated files from golangci-lint's linters and formatters in
.golangci.yml:github/github-accessors.go/github/github-accessors_test.gogithub/github-iterators.go/github/github-iterators_test.gogithub/github-stringify_test.goThey are added to
linters.exclusions.pathsandformatters.exclusions.paths. All carry the// Code generated ... DO NOT EDIT.header and are covered bycheck-generated,go build, andgo test.This did not measurably change lint/format wall-clock time:
run)fmt)golangci-lint loads and type-checks whole packages, so the excluded files are still parsed;
exclusions.pathsonly suppresses their reported issues/formatting (laxmode already suppresses generated-file issues for the linters, so the net-new effect is on the formatters).Re #4070