From 41b6931dc127c6971748d1a4da868507aac6ee9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juli=C3=A1n=20Gonz=C3=A1lez?= Date: Tue, 22 Sep 2026 14:14:44 -0700 Subject: [PATCH] Exclude composite literals from goconst instead of raising its threshold 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 --- .golangci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 7ab6339..9ae6560 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -40,9 +40,8 @@ linters: exhaustive: default-signifies-exhaustive: true goconst: - # goconst v1.9.0 reports literals inside composite literals; these hold the prior signal. - ignore-map-keys: true - min-occurrences: 6 + # goconst v1.9.0 reports literals inside composite literals. Call is the upstream default; keep it. + exclude-types: [Call, CompositeLit] gocritic: enabled-checks: - ruleguard