Skip to content

build: Exclude generated files from golangci-lint#4338

Closed
JamBalaya56562 wants to merge 1 commit into
google:masterfrom
JamBalaya56562:build/4070-exclude-generated-from-lint
Closed

build: Exclude generated files from golangci-lint#4338
JamBalaya56562 wants to merge 1 commit into
google:masterfrom
JamBalaya56562:build/4070-exclude-generated-from-lint

Conversation

@JamBalaya56562

@JamBalaya56562 JamBalaya56562 commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Excludes the large auto-generated files from golangci-lint's linters and formatters in .golangci.yml:

  • github/github-accessors.go / github/github-accessors_test.go
  • github/github-iterators.go / github/github-iterators_test.go
  • github/github-stringify_test.go

They are added to linters.exclusions.paths and formatters.exclusions.paths. All carry the // Code generated ... DO NOT EDIT. header and are covered by check-generated, go build, and go test.

This did not measurably change lint/format wall-clock time:

linters (run) formatters (fmt)
before ~15–17 s ~6–7 s
after ~16–17 s ~6–7 s

golangci-lint loads and type-checks whole packages, so the excluded files are still parsed; exclusions.paths only suppresses their reported issues/formatting (lax mode already suppresses generated-file issues for the linters, so the net-new effect is on the formatters).

Re #4070

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

codecov Bot commented Jun 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.48%. Comparing base (d11391c) to head (7034fc5).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gmlewis

gmlewis commented Jun 27, 2026

Copy link
Copy Markdown
Collaborator

@JamBalaya56562 - according to the description above, this PR makes zero difference.

And in fact, for developers who actually are tweaking the tools in this repo, this PR would actually PREVENT them from seeing linter warnings for the newly-modified files that they are working on.

So I'm thinking that this PR is NOT desireable and should be closed.

Or am I missing something?

@gmlewis

gmlewis commented Jun 27, 2026

Copy link
Copy Markdown
Collaborator

Also, it certainly does NOT fix #4070.

@JamBalaya56562

Copy link
Copy Markdown
Contributor Author

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 gen-*.go generators. That's a real downside, so this isn't worth doing. Closing.

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.

@JamBalaya56562 JamBalaya56562 deleted the build/4070-exclude-generated-from-lint branch June 29, 2026 04:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants