-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.golangci.yml
More file actions
189 lines (183 loc) · 7.75 KB
/
.golangci.yml
File metadata and controls
189 lines (183 loc) · 7.75 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
# v2.1.6
# Please don't remove the first line. It's used in CI to determine the golangci-lint version.
version: "2"
linters:
# See list of supported linters: https://golangci-lint.run/usage/linters/
# And list of linters we may want to enable:
# https://gist.github.com/maratori/47a4d00457a92aa426dbd48a18776322
default: none
enable:
## Enabled by default
- errcheck # detects unchecked errors, which can be critical bugs in some cases
- govet # reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
- ineffassign # detects when assignments to existing variables are not used
- staticcheck # is a go vet on steroids, applying a ton of static analysis checks
- unused # checks for unused constants, variables, functions and types
## Disabled by default
- asasalint # checks for pass []any as any in variadic func(...any)
- asciicheck # checks that your code does not contain non-ASCII identifiers
- bidichk # checks for dangerous unicode character sequences
- bodyclose # checks whether HTTP response body is closed successfully
- contextcheck # check whether the function uses a non-inherited context
- cyclop # checks function and package cyclomatic complexity
- dogsled # checks assignments with too many blank identifiers (e.g. x, , , _, := f()).
- dupl # detects duplicate code
- durationcheck # checks for two durations multiplied together
- errchkjson # checks types passed to the json encoding functions
- errname # checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error
- errorlint # finds code that will cause problems with the error wrapping scheme introduced in Go 1.13
- exhaustive # checks exhaustiveness of enum switch statements
- forbidigo # forbids identifiers
- forcetypeassert # finds forced type assertions
- funlen # detects long functions
- gocheckcompilerdirectives # validates go compiler directive comments (//go:)
- gochecknoglobals # checks that no global variables exist
- gocognit # computes and checks the cognitive complexity of functions
- goconst # finds repeated strings that could be replaced by a constant
- gocritic # provides diagnostics that check for bugs, performance and style issues
- godot # checks if comments end in a period
- gomoddirectives # manages the use of 'replace', 'retract', and 'excludes' directives in go.mod
- goprintffuncname # checks that printf-like functions are named with f at the end
- gosec # inspects source code for security problems
- importas # enforces consistent import aliases
- interfacebloat # checks the number of methods inside an interface
- ireturn # accept interfaces, return concrete types
- lll # reports long lines
- makezero # finds slice declarations with non-zero initial length
- 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
- nilnil # checks that there is no simultaneous return of nil error and an invalid value
- noctx # finds sending http request without context.Context
- nolintlint # reports ill-formed or insufficient nolint directives
- nosprintfhostport # checks for misuse of Sprintf to construct a host with port in a URL
- prealloc # finds slice declarations that could potentially be preallocated
- predeclared # finds code that shadows one of Go's predeclared identifiers
- revive # fast, configurable, extensible, flexible, and beautiful linter for Go, drop-in replacement of golint
- reassign # checks that package variables are not reassigned
- rowserrcheck # checks whether Err of rows is checked successfully
- sqlclosecheck # checks that sql.Rows and sql.Stmt are closed
- tparallel # detects inappropriate usage of t.Parallel() method in your Go test codes
- unconvert # removes unnecessary type conversions
- unparam # reports unused function parameters
- usestdlibvars # detects the possibility to use variables/constants from the Go standard library
- usetesting # reports uses of functions with replacement inside the testing package
- wastedassign # finds wasted assignment statements
- whitespace # detects leading and trailing whitespace
- wrapcheck # checks that errors returned from external packages are wrapped
## Disabled
#- exhaustruct # [too noisy] checks if all structure fields are initialized
#- paralleltest # [too many false positives] detects missing usage of t.Parallel() method in your Go test
settings:
cyclop:
max-complexity: 25
package-average: 10
dupl:
threshold: 150
errcheck:
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
# Such cases aren't reported by default.
# Default: false
check-type-assertions: true
exhaustive:
# Program elements to check for exhaustiveness.
# Default: [ switch ]
check:
- switch
- map
default-signifies-exhaustive: true
forbidigo:
forbid:
- pattern: ^(fmt\\.Print(|f|ln)|print|println)$
funlen:
lines: 80
statements: 60
ignore-comments: true
goconst:
min-len: 10
min-occurrences: 4
govet:
# Enable all analyzers.
# Default: false
enable-all: true
# Disable analyzers by name.
# Run `go tool vet help` to see all analyzers.
# Default: []
disable:
- fieldalignment
# Settings per analyzer.
settings:
shadow:
# Whether to be strict about shadowing; can be noisy.
# Default: false
strict: true
lll:
line-length: 120
mnd:
# List of function patterns to exclude from analysis.
# Values always ignored: `time.Date`,
# `strconv.FormatInt`, `strconv.FormatUint`, `strconv.FormatFloat`,
# `strconv.ParseInt`, `strconv.ParseUint`, `strconv.ParseFloat`.
# Default: []
ignored-functions:
- flag.Arg
- flag.Duration.*
- flag.Float.*
- flag.Int.*
- flag.Uint.*
- os.Chmod
- os.Mkdir.*
- os.OpenFile
- os.WriteFile
nolintlint:
# Enable to require an explanation of nonzero length after each nolint directive.
# Default: false
require-explanation: true
# Enable to require nolint directives to mention the specific linter being suppressed.
# Default: false
require-specific: true
# Exclude following linters from requiring an explanation.
# Default: []
allow-no-explanation:
- funlen
- gocognit
- lll
wrapcheck:
# An array of strings that specify globs of packages to ignore.
# Default: []
ignore-package-globs:
- go.hackfix.me/paseto-cli/*
exclusions:
generated: lax
rules:
- linters:
- cyclop
- dupl
- funlen
- gocognit
- gochecknoglobals
- lll
- wrapcheck
path: _(test|gen)\.go
paths:
- third_party$
- builtin$
- examples$
issues:
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
max-issues-per-linter: 0
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
max-same-issues: 0
formatters:
enable:
# checks common formatting issues; stricter than gofmt
- gofumpt
# in addition to fixing imports, goimports also formats your code in the same style as gofmt
- goimports
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$