-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.golangci.yml
More file actions
196 lines (171 loc) · 4.91 KB
/
.golangci.yml
File metadata and controls
196 lines (171 loc) · 4.91 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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
run:
timeout: 5m
tests: true
linters:
# Enable essential and recommended linters
enable:
# Essential - Bug Detection & Best Practices
- govet # Official Go vet tool
- errcheck # Checks for unchecked errors
- staticcheck # Comprehensive static analysis
- unused # Finds unused code
- ineffassign # Detects ineffectual assignments
- gosec # Security auditing
- forbidigo # Forbids specific identifiers
# Code Quality
- goconst # Repeated strings that should be constants
- gocyclo # Cyclomatic complexity
- dupl # Code duplication
- misspell # Spelling mistakes
- revive # Fast, configurable linter (golint replacement)
- unconvert # Unnecessary type conversions
- unparam # Unused function parameters
# Style & Maintainability
- gofmt # Code formatting
- goimports # Import organization
- gci # Import ordering/grouping
- whitespace # Unnecessary blank lines
- nakedret # Naked returns in long functions
- nolintlint # Validates //nolint directives
# Performance & Best Practices
- prealloc # Slice preallocation opportunities
- errorlint # Error wrapping (Go 1.13+)
linters-settings:
# Duplication detection
dupl:
threshold: 100
# Error checking configuration
errcheck:
check-type-assertions: false # Allow unchecked type assertions where appropriate
check-blank: false # Allow assigning errors to blank identifier when intentional
# Magic constants/strings
goconst:
min-len: 3
min-occurrences: 3
ignore-tests: true
# Cyclomatic complexity
gocyclo:
min-complexity: 15
# Security
gosec:
excludes:
- G104 # We handle error checking explicitly with errcheck
config:
G204:
# Treat these custom wrappers as os/exec calls for security auditing
# Some versions of gosec use CustomExec, others use audit_custom_functions
CustomExec:
- 'runCommand'
- 'runCommandVerbose'
- 'runCommandWithStdin'
- 'runCommandToFile'
- 'runCommandAsync'
- 'runCommandWithStdoutPipe'
- 'runCommandExt'
- 'getCommandOutput'
audit_custom_functions:
- 'runCommand'
- 'runCommandVerbose'
- 'runCommandWithStdin'
- 'runCommandToFile'
- 'runCommandAsync'
- 'runCommandWithStdoutPipe'
- 'runCommandExt'
- 'getCommandOutput'
# Naked returns
nakedret:
max-func-lines: 20
# Forbid specific identifiers
forbidigo:
forbid:
- p: ^exec\.Command$
msg: 'Use of direct exec.Command is forbidden. Use secure wrappers in cmd/devtool/exec.go instead.'
# Import organization
gci:
sections:
- standard # Go standard library
- default # Third-party packages
- prefix(github.com/osse101/BrandishBot_Go) # Project imports
skip-generated: true
# Revive configuration (golint replacement)
revive:
rules:
- name: exported
disabled: false
- name: package-comments
disabled: true # Not enforcing package comments for internal packages
- name: blank-imports
- name: context-as-argument
- name: dot-imports
- name: error-return
- name: error-strings
- name: error-naming
- name: if-return
- name: var-naming
- name: var-declaration
- name: range
- name: receiver-naming
- name: indent-error-flow
- name: superfluous-else
- name: unexported-return
- name: time-naming
- name: context-keys-type
- name: errorf
issues:
# Show all issues
max-issues-per-linter: 0
max-same-issues: 0
# Don't hide new issues in existing code
new: false
exclude-rules:
# Relax linters for test files
- path: _test\.go
linters:
- dupl
- errcheck
- gosec
- gocyclo
- funlen
- goconst
- path: cmd/devtool/exec\.go
linters:
- forbidigo
text: 'Use of direct exec\.Command is forbidden'
# Exclude all linters from migrations (schema-only SQL)
- path: migrations/
linters:
- all
# Exclude all linters from generated code
- path: internal/database/generated/
linters:
- all
# Exclude all linters from mocks
- path: mocks/
linters:
- all
# G115: Integer overflow conversion - acceptable in database context where IDs fit in int32
- linters:
- gosec
text: 'G115'
path: internal/database/postgres/
- linters:
- gosec
text: 'G115'
path: internal/cooldown/postgres.go
# Allow long lines in generated files
- path: _generated\.go
linters:
- lll
# Exclude specific directories
exclude-dirs:
- third_party
- builtin
- examples
- vendor
- scripts
output:
formats:
- format: colored-line-number
print-issued-lines: true
print-linter-name: true
sort-results: true