-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.golangci.yml
More file actions
215 lines (187 loc) · 6.55 KB
/
.golangci.yml
File metadata and controls
215 lines (187 loc) · 6.55 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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# golangci-lint configuration for nix-auth
# Documentation: https://golangci-lint.run/usage/configuration/
version: "2"
run:
# Timeout for analysis
timeout: 5m
# Include test files
tests: true
# List of build tags to use
build-tags:
- integration
linters:
default: standard
enable:
# Additional linters for code quality
- bodyclose # Checks whether HTTP response body is closed successfully
- dogsled # Checks assignments with too many blank identifiers
- dupl # Tool for code clone detection
- copyloopvar # Checks for unpinned variables in go programs
- gocognit # Computes cognitive complexity of functions
- goconst # Finds repeated strings that could be replaced by constants
- gocritic # Provides diagnostics that check for bugs, performance and style issues
- gocyclo # Computes cyclomatic complexity of functions
- godot # Check if comments end in a period
- mnd # Detects magic numbers (replaces gomnd)
- goprintffuncname # Checks that printf-like functions are named with `f` at the end
- gosec # Security checker
- misspell # Finds commonly misspelled English words in comments
- nakedret # Finds naked returns in functions greater than a specified function length
- nestif # Reports deeply nested if statements
- nilerr # Finds the code that returns nil even if it checks that the error is not nil
- noctx # Finds sending http request without context.Context
- nolintlint # Reports ill-formed or insufficient nolint directives
- prealloc # Finds slice declarations that could potentially be preallocated
- predeclared # Find code that shadows one of Go's predeclared identifiers
- revive # Fast, configurable, extensible, flexible, and beautiful linter for Go
- rowserrcheck # Checks whether Err of rows is checked successfully
- sqlclosecheck # Checks that sql.Rows and sql.Stmt are closed
- thelper # Detects Go test helpers without t.Helper() call
- tparallel # Detects inappropriate usage of t.Parallel() method in your Go test codes
- unconvert # Remove unnecessary type conversions
- unparam # Reports unused function parameters
- whitespace # Tool for detection of leading and trailing whitespace
- wsl # Whitespace Linter
disable:
- depguard # Checks if package imports are in a list of acceptable packages
- exhaustive # Check exhaustiveness of enum switch statements
- funlen # Tool for detection of long functions
- gochecknoglobals # Check that no global variables exist
- godox # Tool for detection of FIXME, TODO and other comment keywords
- err113 # Golang linter to check the errors handling expressions
- wrapcheck # Checks that errors returned from external packages are wrapped
exclusions:
paths:
- vendor
- .git
- testdata
files:
- ".*\\.pb\\.go$"
- ".*\\.gen\\.go$"
formatters:
enable:
- gci # Controls Go package import order and makes it deterministic
- gofmt # Checks whether code was gofmt-ed
- goimports # Check import statements are formatted according to the 'goimport' command
exclusions:
paths:
- vendor
- .git
- testdata
files:
- ".*\\.pb\\.go$"
- ".*\\.gen\\.go$"
linters-settings:
errcheck:
# Don't report errors for defer Close() calls
exclude-functions:
- (io.Closer).Close
- (*os.File).Close
- (*io.PipeWriter).Close
- (*bytes.Buffer).WriteTo
- (*strings.Builder).WriteTo
govet:
# Enable all analyzers
enable-all: true
gocyclo:
# Minimal code complexity to report
min-complexity: 15
dupl:
# Tokens count to trigger issue
threshold: 100
goconst:
# Minimal length of string constant
min-len: 3
# Minimal occurrences count to trigger
min-occurrences: 3
misspell:
# Locale to use
locale: US
mnd:
# Don't include the "operation" and "assign"
checks: [argument,case,condition,return]
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
disabled-checks:
- dupImport # https://github.com/go-critic/go-critic/issues/845
- ifElseChain
- octalLiteral
- whyNoLint
- wrapperFunc
goimports:
# Put local imports after 3rd-party packages
local-prefixes: github.com/numtide/nix-auth
gci:
sections:
- standard
- default
- prefix(github.com/numtide/nix-auth)
nolintlint:
# Enable to ensure that nolint directives are all used
allow-unused: false
# Exclude following linters from requiring an explanation
allow-no-explanation: []
# Enable to require an explanation of nonzero length for nolint directives
require-explanation: true
# Enable to require nolint directives to mention the specific linter
require-specific: true
revive:
# Accept interfaces, return concrete types
confidence: 0.8
rules:
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: error-return
- name: error-strings
- name: error-naming
- name: if-return
- name: increment-decrement
- name: var-naming
- name: var-declaration
- name: package-comments
- name: range
- name: receiver-naming
- name: time-naming
- name: unexported-return
- name: indent-error-flow
- name: errorf
- name: empty-block
- name: superfluous-else
- name: unused-parameter
- name: unreachable-code
- name: redefines-builtin-id
issues:
# Exclude some linters from running on tests files
exclude-rules:
- path: _test\.go
linters:
- dupl
- mnd
# Exclude G104 (error handling) from specific files
- linters:
- gosec
text: "G104"
# Maximum issues count per one linter. Set to 0 to disable
max-issues-per-linter: 0
# Maximum count of issues with the same text. Set to 0 to disable
max-same-issues: 0
# Show only new issues created after git revision
new: false
# Fix found issues (if it's supported by the linter)
fix: false
severity:
# Set the default severity for issues
default: warning
# The list of ids of default excludes to include or disable
rules:
- linters:
- gosec
text: "G104" # Errors unhandled
severity: info