-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy path.golangci.yml
More file actions
175 lines (155 loc) · 4.43 KB
/
.golangci.yml
File metadata and controls
175 lines (155 loc) · 4.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# =============================================================================
# usulnet - golangci-lint configuration
# =============================================================================
# Run: golangci-lint run ./...
# Docs: https://golangci-lint.run/usage/configuration/
# =============================================================================
run:
timeout: 10m
go: "1.25"
tests: true
# Skip generated files
skip-dirs:
- vendor
- node_modules
skip-files:
- ".*_templ\\.go$"
- ".*\\.gen\\.go$"
output:
formats:
- format: colored-line-number
sort-results: true
sort-order:
- linter
- severity
- file
linters:
enable:
# Security
- gosec # Security issues
# Bug detection
- staticcheck # Go static analysis (SA*, S*, ST*, QF* checks)
- govet # Go vet checks
- errcheck # Unchecked errors
- ineffassign # Unused assignments
- unused # Unused code (variables, functions, types)
# Code quality
- gocritic # Go critic linter (opinionated but useful)
- revive # Drop-in replacement for golint
- gofmt # Go formatting
- goimports # Import organization
# Performance
- prealloc # Slice preallocation hints
# Error handling
- nilerr # nil error return after error check
- errorlint # Error wrapping best practices
# Style
- misspell # Spelling mistakes in comments
- unconvert # Unnecessary type conversions
- whitespace # Whitespace issues
linters-settings:
gosec:
severity: medium
confidence: medium
excludes:
- G101 # Hardcoded credentials (too many false positives with test files)
- G104 # Audit errors not checked (covered by errcheck)
- G304 # File path provided as taint input (needed for file operations)
config:
global:
audit: false
govet:
enable-all: true
disable:
- fieldalignment # Too noisy, minimal real impact
- shadow # Too noisy in large codebase
errcheck:
check-type-assertions: false
check-blank: false
exclude-functions:
- io.Copy
- io.WriteTo
- (io.Closer).Close
- (*os.File).Close
- (net/http.ResponseWriter).Write
- fmt.Fprintf
- fmt.Fprintln
staticcheck:
checks:
- all
- -SA1019 # Deprecated usage (handle separately)
gocritic:
enabled-tags:
- diagnostic
- performance
disabled-checks:
- hugeParam # Too aggressive for this codebase
- rangeValCopy # Often false positive with small structs
- commentFormatting # Too noisy
revive:
rules:
- name: exported
disabled: true # Too strict for initial adoption
- name: unexported-return
disabled: true
- name: var-naming
disabled: true # Conflicts with existing naming conventions
goimports:
local-prefixes: github.com/fr4nsys/usulnet
misspell:
locale: US
prealloc:
simple: true
range-loops: true
for-loops: false # Too many false positives in complex loops
issues:
# Don't limit output
max-issues-per-linter: 0
max-same-issues: 0
# Exclude test files from some strict checks
exclude-rules:
# Tests can use magic numbers and have longer functions
- path: _test\.go
linters:
- gosec
- errcheck
- gocritic
- prealloc
# Generated templ files should be excluded
- path: _templ\.go
linters:
- all
# Migration files have long SQL strings
- path: migrations/
linters:
- gocritic
# Allow some patterns in handlers (they're verbose by design)
- path: internal/api/handlers/
linters:
- gocritic
text: "ifElseChain"
# Main packages can have init()
- path: cmd/
linters:
- gocritic
text: "initClause"
# Exclude common patterns
exclude:
# errcheck: Allow ignoring errors from response.Write
- "Error return value of .((os\\.)?std(out|err)\\..*|.*Close|.*Flush|os\\.Remove(All)?|.*printf?|os\\.(Un)?Setenv). is not checked"
# govet: Allow printf-like functions
- "printf: non-constant format string"
severity:
default-severity: warning
rules:
- linters:
- gosec
severity: error
- linters:
- govet
- errcheck
severity: error
- linters:
- misspell
- whitespace
severity: info