Exclude composite literals from goconst instead of raising its threshold - #124
Merged
Merged
Conversation
The goconst block shipped with the v2.13.2 pin held the linter's prior
signal with ignore-map-keys and min-occurrences: 6. Measured against the
fleet after deployment, that covers map keys only. goconst v1.9.0 reports
every element of a composite literal, and two more shapes survive:
- slice elements and map values: baton-1password's permission lists
(`view_items` x10, `view_and_copy_passwords` x8) and baton-axiomatic's
`"Error"` as a map value and struct field (x6)
- struct field values in test helpers: `Method: "GET"` in the go-github
mock tables of baton-github and baton-github-test
exclude-types: [CompositeLit] names that shape directly. Call stays in
the list because golangci-lint's goconst default is exclude-types: [Call]
(pkg/config/linters_settings.go:74) and any value replaces the default
rather than extending it; measured without Call, string arguments to
functions are reported everywhere and baton-github-test goes from 1
finding to 19, baton-github from 1 to 22, baton-demo from 0 to 6.
min-occurrences: 6 is dropped. It only ever compensated for the
composite-literal reports, and it loosened goconst on assignments,
comparisons, case labels and returns from the default 3 to 6, which the
v2.11.4 pin never did. With composite literals excluded, the default
threshold is the pre-bump behavior.
Validated with golangci-lint v2.13.2 on baton-1password, baton-github-test,
baton-github, baton-demo and baton-snyk: 0 goconst findings on all five,
the same result as keeping both prior settings alongside this one. The
deployed config leaves 3, 1, 1, 0 and 0 respectively.
baton-admin syncs this file into pkg/files/.golangci.yml daily and pushes
it to every managed connector; the fleet is already on v2.13.2, which
accepts exclude-types.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Bencheng21
approved these changes
Sep 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The goconst block shipped with the v2.13.2 pin held the linter's prior signal with ignore-map-keys and min-occurrences: 6. Measured against the fleet after deployment, that covers map keys only. goconst v1.9.0 reports every element of a composite literal, and two more shapes survive:
view_itemsx10,view_and_copy_passwordsx8) and baton-axiomatic's"Error"as a map value and struct field (x6)Method: "GET"in the go-github mock tables of baton-github and baton-github-testexclude-types: [CompositeLit] names that shape directly. Call stays in the list because golangci-lint's goconst default is exclude-types: [Call] (pkg/config/linters_settings.go:74) and any value replaces the default rather than extending it; measured without Call, string arguments to functions are reported everywhere and baton-github-test goes from 1 finding to 19, baton-github from 1 to 22, baton-demo from 0 to 6.
min-occurrences: 6 is dropped. It only ever compensated for the composite-literal reports, and it loosened goconst on assignments, comparisons, case labels and returns from the default 3 to 6, which the v2.11.4 pin never did. With composite literals excluded, the default threshold is the pre-bump behavior.