Skip to content

Commit 35ff0a6

Browse files
lexfreiclaude
andauthored
chore(lint): configure goconst linter (#5929)
* chore(lint): configure goconst linter Enable goconst linter with min-occurrences threshold of 3 and exclude well-known protocol values that don't need constants: - DNS record types (A, AAAA, CNAME, TXT, etc.) - Boolean strings ("true", "false") - Common null indicators ("none") - Registry types (aws-sd, noop) This catches genuinely problematic string repetitions while avoiding over-engineering for standard protocol values. Co-Authored-By: Claude <[email protected]> * docs(lint): update golangci-lint documentation URLs Update all linter documentation references from deprecated /usage/ paths to current /docs/ paths. Fix errorlint anchor from #errcheck to #errorlint. Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
1 parent effffb2 commit 35ff0a6

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

.golangci.yml

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,39 @@
1-
# https://golangci-lint.run/usage/configuration/
1+
# https://golangci-lint.run/docs/configuration/
22
version: "2"
33
linters:
44
default: none
55
enable: # golangci-lint help linters
6-
- copyloopvar # A linter detects places where loop variables are copied. https://golangci-lint.run/usage/linters/#copyloopvar
7-
- dogsled # Checks assignments with too many blank identifiers. https://golangci-lint.run/usage/linters/#dogsled
8-
- dupword # Duplicate word. https://golangci-lint.run/usage/linters/#dupword
6+
- copyloopvar # A linter detects places where loop variables are copied. https://golangci-lint.run/docs/linters/configuration/#copyloopvar
7+
- dogsled # Checks assignments with too many blank identifiers. https://golangci-lint.run/docs/linters/configuration/#dogsled
8+
- dupword # Duplicate word. https://golangci-lint.run/docs/linters/configuration/#dupword
99
- goprintffuncname
1010
- govet
1111
- ineffassign
1212
- misspell
1313
- revive
14-
- recvcheck # Checks for receiver type consistency. https://golangci-lint.run/usage/linters/#recvcheck
14+
- recvcheck # Checks for receiver type consistency. https://golangci-lint.run/docs/linters/configuration/#recvcheck
1515
- rowserrcheck # Checks whether Rows.Err of rows is checked successfully.
16-
- errchkjson # Checks types passed to the json encoding functions. ref: https://golangci-lint.run/usage/linters/#errchkjson
17-
- errorlint # Checking for unchecked errors in Go code https://golangci-lint.run/usage/linters/#errcheck
16+
- errchkjson # Checks types passed to the json encoding functions. ref: https://golangci-lint.run/docs/linters/configuration/#errchkjson
17+
- errorlint # Checking for unchecked errors in Go code https://golangci-lint.run/docs/linters/configuration/#errorlint
1818
- staticcheck
1919
- unconvert
2020
- unused
21-
- usestdlibvars # A linter that detect the possibility to use variables/constants from the Go standard library. https://golangci-lint.run/usage/linters/#usestdlibvars
21+
- usestdlibvars # A linter that detect the possibility to use variables/constants from the Go standard library. https://golangci-lint.run/docs/linters/configuration/#usestdlibvars
2222
- whitespace
23-
- decorder # Check declaration order and count of types, constants, variables and functions. https://golangci-lint.run/usage/linters/#decorder
24-
- tagalign # Check that struct tags are well aligned. https://golangci-lint.run/usage/linters/#tagalign
23+
- decorder # Check declaration order and count of types, constants, variables and functions. https://golangci-lint.run/docs/linters/configuration/#decorder
24+
- tagalign # Check that struct tags are well aligned. https://golangci-lint.run/docs/linters/configuration/#tagalign
2525
- predeclared # Find code that shadows one of Go's predeclared identifiers
2626
- sloglint # Ensure consistent code style when using log/slog
2727
- asciicheck # Checks that all code identifiers does not have non-ASCII symbols in the name
28-
- nilnil # Checks that there is no simultaneous return of nil error and an nil value. ref: https://golangci-lint.run/usage/linters/#nilnil
29-
- nonamedreturns # Checks that functions with named return values do not return named values. https://golangci-lint.run/usage/linters/#nonamedreturns
30-
- cyclop # Checks function and package cyclomatic complexity. https://golangci-lint.run/usage/linters/#cyclop
28+
- nilnil # Checks that there is no simultaneous return of nil error and an nil value. ref: https://golangci-lint.run/docs/linters/configuration/#nilnil
29+
- nonamedreturns # Checks that functions with named return values do not return named values. https://golangci-lint.run/docs/linters/configuration/#nonamedreturns
30+
- cyclop # Checks function and package cyclomatic complexity. https://golangci-lint.run/docs/linters/configuration/#cyclop
3131
- gocritic # Analyze source code for various issues, including bugs, performance hiccups, and non-idiomatic coding practices. https://golangci-lint.run/docs/linters/configuration/#gocritic
32-
- gochecknoinits # Checks that there are no init() functions in the code. https://golangci-lint.run/usage/linters/#gochecknoinits
32+
- gochecknoinits # Checks that there are no init() functions in the code. https://golangci-lint.run/docs/linters/configuration/#gochecknoinits
33+
- goconst # Finds repeated strings that could be replaced by a constant. https://golangci-lint.run/docs/linters/configuration/#goconst
3334

3435
# tests
35-
- testifylint # Checks usage of github.com/stretchr/testify. https://golangci-lint.run/usage/linters/#testifylint
36+
- testifylint # Checks usage of github.com/stretchr/testify. https://golangci-lint.run/docs/linters/configuration/#testifylint
3637
settings:
3738
exhaustive:
3839
default-signifies-exhaustive: false
@@ -44,6 +45,14 @@ linters:
4445
disabled: true
4546
cyclop: # Lower cyclomatic complexity threshold after the max complexity is lowered
4647
max-complexity: 37 # Controller/execute.go:147:1: calculated cyclomatic complexity for function buildProvider is 37
48+
goconst:
49+
min-occurrences: 3
50+
# Ignore well-known DNS record types, boolean strings, and common values
51+
ignore-string-values:
52+
- "^(A|AAAA|ALIAS|CNAME|MX|NS|PTR|SRV|TXT)$" # DNS record types
53+
- "^(true|false)$" # Boolean strings
54+
- "^none$" # Common null/empty indicator
55+
- "^(aws-sd|noop)$" # Registry types - can be ignored for consistency
4756
testifylint:
4857
# Enable all checkers (https://github.com/Antonboom/testifylint#checkers).
4958
# Default: false
@@ -79,6 +88,7 @@ linters:
7988
- unused
8089
- varcheck
8190
- whitespace
91+
- goconst
8292
path: _test\.go
8393
# TODO: skiip as will require design changes
8494
- linters:

0 commit comments

Comments
 (0)