Skip to content

Commit 4feab20

Browse files
committed
fix: update golangci-lint configs for v2.x schema compatibility
The golangci-lint v2.x series requires a different configuration schema: 1. `linters-settings` must be nested under `linters.settings` 2. `issues.exclude-generated-strict` is not supported 3. `issues.exclude-rules` complex syntax replaced with simpler `exclude` patterns Changes to both backend/.golangci-fast.yml and backend/.golangci.yml: - Restructured linter settings under `linters.settings` - Converted exclude-rules to simple exclude patterns - Added proper v2.x directives (exclude-use-default, max-issues-per-linter) - Maintained all security checks and error handling exclusions This resolves the "invalid configuration keys" error when running golangci-lint v2.8.0 with golangci-lint-action v9.2.0. Fixes: #666 (golangci-lint configuration schema validation)
1 parent a1ef8e4 commit 4feab20

2 files changed

Lines changed: 79 additions & 102 deletions

File tree

backend/.golangci-fast.yml

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,32 @@ linters:
1212
- ineffassign # Ineffectual assignments
1313
- unused # Unused code detection
1414
- gosec # Security checks (critical issues only)
15-
16-
linters-settings:
17-
govet:
18-
enable:
19-
- shadow
20-
errcheck:
21-
exclude-functions:
22-
- (io.Closer).Close
23-
- (*os.File).Close
24-
- (net/http.ResponseWriter).Write
25-
gosec:
26-
# Only check CRITICAL security issues for fast pre-commit
27-
includes:
28-
- G101 # Hardcoded credentials
29-
- G110 # Potential DoS via decompression bomb
30-
- G305 # File traversal when extracting archive
31-
- G401 # Weak crypto (MD5, SHA1)
32-
- G501 # Blacklisted import crypto/md5
33-
- G502 # Blacklisted import crypto/des
34-
- G503 # Blacklisted import crypto/rc4
15+
settings:
16+
govet:
17+
enable:
18+
- shadow
19+
errcheck:
20+
exclude-functions:
21+
- (io.Closer).Close
22+
- (*os.File).Close
23+
- (net/http.ResponseWriter).Write
24+
gosec:
25+
# Only check CRITICAL security issues for fast pre-commit
26+
includes:
27+
- G101 # Hardcoded credentials
28+
- G110 # Potential DoS via decompression bomb
29+
- G305 # File traversal when extracting archive
30+
- G401 # Weak crypto (MD5, SHA1)
31+
- G501 # Blacklisted import crypto/md5
32+
- G502 # Blacklisted import crypto/des
33+
- G503 # Blacklisted import crypto/rc4
3534

3635
issues:
37-
exclude-generated-strict: true
38-
exclude-rules:
39-
# Allow test-specific patterns for errcheck
40-
- linters:
41-
- errcheck
42-
path: ".*_test\\.go$"
43-
text: "json\\.Unmarshal|SetPassword|CreateProvider"
36+
exclude-use-default: false
37+
exclude-dirs:
38+
- vendor
39+
exclude-files:
40+
- ".*\\.gen\\.go$"
41+
exclude:
42+
# Allow test-specific patterns
43+
- 'Error return value of `.*(json\.Unmarshal|SetPassword|CreateProvider).*` is not checked'

backend/.golangci.yml

Lines changed: 52 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -14,82 +14,59 @@ linters:
1414
- staticcheck
1515
- unused
1616
- errcheck
17-
18-
linters-settings:
19-
gocritic:
20-
enabled-tags:
21-
- diagnostic
22-
- performance
23-
- style
24-
- opinionated
25-
- experimental
26-
disabled-checks:
27-
- whyNoLint
28-
- wrapperFunc
29-
- hugeParam
30-
- rangeValCopy
31-
- ifElseChain
32-
- appendCombine
33-
- appendAssign
34-
- commentedOutCode
35-
- sprintfQuotedString
36-
govet:
37-
enable:
38-
- shadow
39-
errcheck:
40-
exclude-functions:
41-
# Ignore deferred close errors - these are intentional
42-
- (io.Closer).Close
43-
- (*os.File).Close
44-
- (net/http.ResponseWriter).Write
45-
- (*encoding/json.Encoder).Encode
46-
- (*encoding/json.Decoder).Decode
47-
# Test utilities
48-
- os.Setenv
49-
- os.Unsetenv
50-
- os.RemoveAll
51-
- os.MkdirAll
52-
- os.WriteFile
53-
- os.Remove
54-
- (*gorm.io/gorm.DB).AutoMigrate
55-
# Additional test cleanup functions
56-
- (*database/sql.Rows).Close
57-
- (gorm.io/gorm.Migrator).DropTable
58-
- (*net/http.Response.Body).Close
17+
settings:
18+
gocritic:
19+
enabled-tags:
20+
- diagnostic
21+
- performance
22+
- style
23+
- opinionated
24+
- experimental
25+
disabled-checks:
26+
- whyNoLint
27+
- wrapperFunc
28+
- hugeParam
29+
- rangeValCopy
30+
- ifElseChain
31+
- appendCombine
32+
- appendAssign
33+
- commentedOutCode
34+
- sprintfQuotedString
35+
govet:
36+
enable:
37+
- shadow
38+
errcheck:
39+
exclude-functions:
40+
# Ignore deferred close errors - these are intentional
41+
- (io.Closer).Close
42+
- (*os.File).Close
43+
- (net/http.ResponseWriter).Write
44+
- (*encoding/json.Encoder).Encode
45+
- (*encoding/json.Decoder).Decode
46+
# Test utilities
47+
- os.Setenv
48+
- os.Unsetenv
49+
- os.RemoveAll
50+
- os.MkdirAll
51+
- os.WriteFile
52+
- os.Remove
53+
- (*gorm.io/gorm.DB).AutoMigrate
54+
# Additional test cleanup functions
55+
- (*database/sql.Rows).Close
56+
- (gorm.io/gorm.Migrator).DropTable
57+
- (*net/http.Response.Body).Close
5958

6059
issues:
61-
exclude-rules:
62-
# errcheck is strict by design; allow a few intentionally-ignored errors in tests only.
63-
- linters:
64-
- errcheck
65-
path: ".*_test\\.go$"
66-
text: "json\\.Unmarshal|SetPassword|CreateProvider|ProxyHostService\\.Create"
67-
60+
exclude-use-default: false
61+
exclude:
6862
# Gosec exclusions - be specific to avoid hiding real issues
6963
# G104: Ignoring return values - already checked by errcheck
70-
- linters:
71-
- gosec
72-
text: "G104:"
73-
74-
# G301/G302/G306: File permissions - allow in specific contexts
75-
- linters:
76-
- gosec
77-
path: "internal/config/"
78-
text: "G301:|G302:|G306:"
79-
80-
# G304: File path from variable - allow in handlers with proper validation
81-
- linters:
82-
- gosec
83-
path: "internal/api/handlers/"
84-
text: "G304:"
85-
86-
# G602: Slice bounds - allow in test files where it's typically safe
87-
- linters:
88-
- gosec
89-
path: ".*_test\\.go$"
90-
text: "G602:"
91-
92-
# Exclude shadow warnings in specific patterns
93-
- linters:
94-
- govet
95-
text: "shadows declaration"
64+
- "G104:"
65+
# Allow shadow warnings in specific patterns
66+
- "shadows declaration"
67+
exclude-dirs:
68+
- vendor
69+
exclude-files:
70+
- ".*_test\\.go$" # Test-specific exclusions handled via patterns
71+
max-issues-per-linter: 0
72+
max-same-issues: 0

0 commit comments

Comments
 (0)