-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy path.golangci.yml
More file actions
188 lines (185 loc) · 7.46 KB
/
.golangci.yml
File metadata and controls
188 lines (185 loc) · 7.46 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
version: '2'
# This is a manually created golangci.com yaml configuration with
# some defaults explicitly provided. There is a large number of
# linters we've enabled that are usually disabled by default.
#
# https://golangci-lint.run/usage/configuration/#config-file
# This section provides the configuration for how golangci
# outputs it results from the linters it executes.
output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
formats:
text:
path: stdout
# print linter name in the end of issue text, default is true
print-linter-name: true
# print lines of code with issue, default is true
print-issued-lines: true
linters:
# disable all linters as new linters might be added to golangci
# in v2, this is for disable-all: true
default: none
# enable a specific set of linters to run
enable:
- bidichk # checks for dangerous unicode character sequences
- bodyclose # checks whether HTTP response body is closed successfully
- contextcheck # check the function whether use a non-inherited context
- copyloopvar # checks for loop variables
- depguard # checks for dependencies that are not allowed
- errcheck # checks for unchecked errors
- errorlint # find misuses of errors
- funlen # detects long functions
- goconst # finds repeated strings that could be replaced by a constant
- gocyclo # computes and checks the cyclomatic complexity of functions
- godot # checks if comments end in a period
- goheader # checks is file header matches to pattern
- gomoddirectives # manage 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 code for security problems
- govet # reports suspicious constructs, ex. Printf calls whose arguments don't align with the format string
- ineffassign # detects when assignments to existing variables aren't used
- 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
- nilerr # finds the code that returns nil even if it checks that the error is not nil
- noctx # noctx finds sending http request without context.Context
- nolintlint # reports ill-formed or insufficient nolint directives
- revive # linter for go
- staticcheck # applies static analysis checks, go vet on steroids
# The linters stylecheck, gosimple, and staticcheck has been merged inside the staticcheck.
- tagalign # finds maligned struct tags
- unconvert # remove unnecessary type conversions
- unparam # reports unused function parameters
- unused # checks for unused constants, variables, functions and types
- whitespace # detects leading and trailing whitespace
- wsl_v5 # forces code to use empty lines
# static list of linters we know golangci can run but we've
# chosen to leave disabled for now
# - asciicheck - non-critical
# - cyclop - unused complexity metric
# - dogsled - blanks allowed
# - durationcheck - unused
# - errname - unused
# - exhaustive - unused
# - exhaustivestruct - style preference
# - forbidigo - unused
# - forcetypeassert - unused
# - gochecknoinits - unused
# - gochecknoglobals - global variables allowed
# - gocognit - unused complexity metric
# - gocritic - style preference
# - godox - to be used in the future
# - goerr113 - to be used in the future
# - goimports - use gci
# - golint - archived, replaced with revive
# - gofumpt - use gofmt
# - gomnd - get too many false-positives
# - gomodguard - unused
# - ifshort - use both styles
# - ireturn - allow interfaces to be returned
# - importas - want flexibility with naming
# - lll - not too concerned about line length
# - interfacer - archived
# - nestif - non-critical
# - nilnil - style preference
# - nlreturn - style preference
# - maligned - archived, replaced with govet 'fieldalignment'
# - paralleltest - false-positives
# - prealloc - don't use
# - predeclared - unused
# - promlinter - style preference
# - rowserrcheck - unused
# - scopelint - deprecated - replaced with exportloopref
# - sqlclosecheck - unused
# - tagliatelle - use a mix of variable naming
# - testpackage - don't use this style of testing
# - thelper - false-positives
# - varnamelen - unused
# - wastedassign - duplicate functionality
# - wrapcheck - style preference
# This section provides the configuration for each linter
# we've instructed golangci to execute.
settings:
# https://golangci-lint.run/usage/linters/#depguard
depguard:
rules:
main:
deny:
- pkg: 'github.com/pkg/errors'
desc: Should be replaced by standard lib errors package
# https://github.com/mibk/dupl
dupl:
threshold: 100
# https://github.com/ultraware/funlen
funlen:
# accounting for comments
lines: 160
statements: 70
# https://github.com/denis-tingaikin/go-header
goheader:
template: 'SPDX-License-Identifier: Apache-2.0'
# https://github.com/client9/misspell
misspell:
locale: US
# https://github.com/golangci/golangci-lint/blob/master/pkg/golinters/nolintlint
nolintlint:
require-explanation: true # require an explanation for nolint directives
require-specific: true # require nolint directives to be specific about which linter is being skipped
allow-unused: false # allow nolint directives that don't address a linting issue
# https://golangci-lint.run/usage/linters/#tagalign
# ensure struct tags are aligned
# will auto fix with `make lintfix`
tagalign:
sort: false
# static check to ignore QFI (Quality Function Interface) issues
staticcheck:
checks:
- '-QF1001' # ignore specific QFI issues
- '-QF1003'
- '-QF1004'
- '-QF1008'
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
# Excluding configuration per-path, per-linter, per-text and per-source
# prevent linters from running on *_test.go files
- linters:
- funlen
- goconst
- gocyclo
- wsl
path: _test\.go
paths:
- third_party$
- builtin$
- examples$
issues:
# make issues output unique by line, default is true
uniq-by-line: true
formatters:
enable:
- gci # consistent import ordering
- gofmt # checks whether code was gofmt-ed
settings:
# https://github.com/daixiang0/gci
# ensure import order is consistent
# gci write --custom-order -s standard -s default -s blank -s dot -s "prefix(github.com/go-vela)" .
gci:
sections:
- standard
- default
- blank
- dot
- prefix(github.com/go-vela)
custom-order: true
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$