Skip to content

Commit c42e8d2

Browse files
committed
revert .golangci.yaml
1 parent 61ee176 commit c42e8d2

1 file changed

Lines changed: 244 additions & 130 deletions

File tree

.golangci.yaml

Lines changed: 244 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -1,135 +1,249 @@
1-
version: "2"
1+
## Golden config for golangci-lint v1.46.2
2+
#
3+
# This is the best config for golangci-lint based on my experience and opinion.
4+
# It is very strict, but not extremely strict.
5+
# Feel free to adopt and change it for your needs.
6+
7+
run:
8+
# Timeout for analysis, e.g. 30s, 5m.
9+
# Default: 1m
10+
timeout: 3m
11+
12+
# This file contains only configs which differ from defaults.
13+
# All possible options can be found here https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml
14+
linters-settings:
15+
cyclop:
16+
# The maximal code complexity to report.
17+
# Default: 10
18+
max-complexity: 30
19+
# The maximal average package complexity.
20+
# If it's higher than 0.0 (float) the check is enabled
21+
# Default: 0.0
22+
package-average: 10.0
23+
24+
errcheck:
25+
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
26+
# Such cases aren't reported by default.
27+
# Default: false
28+
check-type-assertions: true
29+
30+
funlen:
31+
# Checks the number of lines in a function.
32+
# If lower than 0, disable the check.
33+
# Default: 60
34+
lines: 100
35+
# Checks the number of statements in a function.
36+
# If lower than 0, disable the check.
37+
# Default: 40
38+
statements: 51
39+
40+
gocognit:
41+
# Minimal code complexity to report
42+
# Default: 30 (but we recommend 10-20)
43+
min-complexity: 20
44+
45+
gocritic:
46+
# Settings passed to gocritic.
47+
# The settings key is the name of a supported gocritic checker.
48+
# The list of supported checkers can be find in https://go-critic.github.io/overview.
49+
settings:
50+
captLocal:
51+
# Whether to restrict checker to params only.
52+
# Default: true
53+
paramsOnly: false
54+
underef:
55+
# Whether to skip (*x).method() calls where x is a pointer receiver.
56+
# Default: true
57+
skipRecvDeref: false
58+
59+
gomodguard:
60+
blocked:
61+
# List of blocked modules.
62+
# Default: []
63+
modules:
64+
- github.com/golang/protobuf:
65+
recommendations:
66+
- google.golang.org/protobuf
67+
reason: "see https://developers.google.com/protocol-buffers/docs/reference/go/faq#modules"
68+
- github.com/satori/go.uuid:
69+
recommendations:
70+
- github.com/google/uuid
71+
reason: "satori's package is not maintained"
72+
- github.com/gofrs/uuid:
73+
recommendations:
74+
- github.com/google/uuid
75+
reason: "see recommendation from dev-infra team: https://confluence.gtforge.com/x/gQI6Aw"
76+
77+
govet:
78+
# Enable all analyzers.
79+
# Default: false
80+
enable-all: true
81+
# Disable analyzers by name.
82+
# Run `go tool vet help` to see all analyzers.
83+
# Default: []
84+
disable:
85+
- fieldalignment # too strict
86+
# Settings per analyzer.
87+
settings:
88+
shadow:
89+
# Whether to be strict about shadowing; can be noisy.
90+
# Default: false
91+
strict: true
92+
93+
nakedret:
94+
# Make an issue if func has more lines of code than this setting, and it has naked returns.
95+
# Default: 30
96+
max-func-lines: 0
97+
98+
nolintlint:
99+
# Exclude following linters from requiring an explanation.
100+
# Default: []
101+
allow-no-explanation: [funlen, gocognit, lll]
102+
# Enable to require an explanation of nonzero length after each nolint directive.
103+
# Default: false
104+
require-explanation: false
105+
# Enable to require nolint directives to mention the specific linter being suppressed.
106+
# Default: false
107+
require-specific: true
108+
109+
rowserrcheck:
110+
# database/sql is always checked
111+
# Default: []
112+
packages:
113+
- github.com/jmoiron/sqlx
114+
115+
tenv:
116+
# The option `all` will run against whole test files (`_test.go`) regardless of method/function signatures.
117+
# Otherwise, only methods that take `*testing.T`, `*testing.B`, and `testing.TB` as arguments are checked.
118+
# Default: false
119+
all: true
120+
2121
linters:
3122
enable:
4-
- asciicheck
5-
- bidichk
6-
- bodyclose
7-
- contextcheck
8-
- cyclop
9-
- dupl
10-
- durationcheck
11-
- errname
12-
- errorlint
13-
- funlen
14-
- gocognit
15-
- gocritic
16-
- gocyclo
17-
- godox
18123
- gomoddirectives
19-
- gomodguard
20-
- goprintffuncname
21-
- gosec
22-
- makezero
23-
- nakedret
24-
- nilerr
25-
- nilnil
26-
- noctx
27-
- nolintlint
28-
- predeclared
29-
- promlinter
30-
- rowserrcheck
31-
- sqlclosecheck
32-
- staticcheck
33-
- testpackage
34-
- tparallel
35-
- unconvert
36-
- unparam
37-
- wastedassign
38-
- whitespace
39-
settings:
40-
cyclop:
41-
max-complexity: 30
42-
package-average: 10
43-
errcheck:
44-
check-type-assertions: true
45-
funlen:
46-
lines: 100
47-
statements: 51
48-
gocognit:
49-
min-complexity: 20
50-
gocritic:
51-
settings:
52-
captLocal:
53-
paramsOnly: false
54-
underef:
55-
skipRecvDeref: false
56-
gomodguard:
57-
blocked:
58-
modules:
59-
- github.com/golang/protobuf:
60-
recommendations:
61-
- google.golang.org/protobuf
62-
reason: see https://developers.google.com/protocol-buffers/docs/reference/go/faq#modules
63-
- github.com/satori/go.uuid:
64-
recommendations:
65-
- github.com/google/uuid
66-
reason: satori's package is not maintained
67-
- github.com/gofrs/uuid:
68-
recommendations:
69-
- github.com/google/uuid
70-
reason: 'see recommendation from dev-infra team: https://confluence.gtforge.com/x/gQI6Aw'
71-
govet:
72-
disable:
73-
- fieldalignment
74-
enable-all: true
75-
settings:
76-
shadow:
77-
strict: true
78-
nakedret:
79-
max-func-lines: 0
80-
nolintlint:
81-
require-explanation: false
82-
require-specific: true
83-
allow-no-explanation:
84-
- funlen
85-
- gocognit
86-
- lll
87-
rowserrcheck:
88-
packages:
89-
- github.com/jmoiron/sqlx
90-
exclusions:
91-
generated: lax
92-
presets:
93-
- comments
94-
- common-false-positives
95-
- legacy
96-
- std-error-handling
97-
rules:
98-
- linters:
99-
- lll
100-
source: ^//\s*go:generate\s
101-
- linters:
102-
- godox
103-
source: (noinspection|TODO)
104-
- linters:
105-
- gocritic
106-
source: //noinspection
107-
- linters:
108-
- errorlint
109-
source: ^\s+if _, ok := err\.\([^.]+\.InternalError\); ok {
110-
- linters:
111-
- bodyclose
112-
- cyclop
113-
- dupl
114-
- funlen
115-
- gocognit
116-
- goconst
117-
- gosec
118-
- noctx
119-
- wrapcheck
120-
path: _test\.go
121-
paths:
122-
- third_party$
123-
- builtin$
124-
- examples$
124+
- errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases
125+
- gosimple # Linter for Go source code that specializes in simplifying a code
126+
- govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
127+
- ineffassign # Detects when assignments to existing variables are not used
128+
- staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks
129+
- typecheck # Like the front-end of a Go compiler, parses and type-checks Go code
130+
- unused # Checks Go code for unused constants, variables, functions and types
131+
- asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers
132+
- bidichk # Checks for dangerous unicode character sequences
133+
- bodyclose # checks whether HTTP response body is closed successfully
134+
- contextcheck # check the function whether use a non-inherited context
135+
- cyclop # checks function and package cyclomatic complexity
136+
- dupl # Tool for code clone detection
137+
- durationcheck # check for two durations multiplied together
138+
- errname # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error.
139+
- errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13.
140+
# - execinquery # execinquery is a linter about query string checker in Query function which reads your Go src files and warning it finds
141+
# - exhaustive # check exhaustiveness of enum switch statements
142+
# - exportloopref # checks for pointers to enclosing loop variables (deprecated)
143+
# - forbidigo # Forbids identifiers
144+
- funlen # Tool for detection of long functions
145+
# - gochecknoglobals # check that no global variables exist
146+
# - gochecknoinits # Checks that no init functions are present in Go code
147+
- gocognit # Computes and checks the cognitive complexity of functions
148+
# - goconst # Finds repeated strings that could be replaced by a constant
149+
- gocritic # Provides diagnostics that check for bugs, performance and style issues.
150+
- gocyclo # Computes and checks the cyclomatic complexity of functions
151+
# - godot # Check if comments end in a period
152+
- goimports # In addition to fixing imports, goimports also formats your code in the same style as gofmt.
153+
# - gomnd # An analyzer to detect magic numbers.
154+
# - gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod.
155+
- gomodguard # Allow and block list linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations.
156+
- goprintffuncname # Checks that printf-like functions are named with f at the end
157+
- gosec # Inspects source code for security problems
158+
# - lll # Reports long lines
159+
- makezero # Finds slice declarations with non-zero initial length
160+
- nakedret # Finds naked returns in functions greater than a specified function length
161+
# - nestif # Reports deeply nested if statements
162+
- nilerr # Finds the code that returns nil even if it checks that the error is not nil.
163+
- nilnil # Checks that there is no simultaneous return of nil error and an invalid value.
164+
- noctx # noctx finds sending http request without context.Context
165+
- nolintlint # Reports ill-formed or insufficient nolint directives
166+
# - nonamedreturns # Reports all named returns
167+
# - nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL.
168+
- predeclared # find code that shadows one of Go's predeclared identifiers
169+
- promlinter # Check Prometheus metrics naming via promlint
170+
# - revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint.
171+
- rowserrcheck # checks whether Err of rows is checked successfully
172+
- sqlclosecheck # Checks that sql.Rows and sql.Stmt are closed.
173+
- stylecheck # Stylecheck is a replacement for golint
174+
- tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17
175+
- testpackage # linter that makes you use a separate _test package
176+
- tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes
177+
- unconvert # Remove unnecessary type conversions
178+
- unparam # Reports unused function parameters
179+
- wastedassign # wastedassign finds wasted assignment statements.
180+
- whitespace # Tool for detection of leading and trailing whitespace
181+
## you may want to enable
182+
#- decorder # check declaration order and count of types, constants, variables and functions
183+
#- exhaustruct # Checks if all structure fields are initialized
184+
#- goheader # Checks is file header matches to pattern
185+
#- ireturn # Accept Interfaces, Return Concrete Types
186+
#- prealloc # [premature optimization, but can be used in some cases] Finds slice declarations that could potentially be preallocated
187+
#- varnamelen # [great idea, but too many false positives] checks that the length of a variable's name matches its scope
188+
#- wrapcheck # Checks that errors returned from external packages are wrapped
189+
## disabled
190+
#- containedctx # containedctx is a linter that detects struct contained context.Context field
191+
#- depguard # [replaced by gomodguard] Go linter that checks if package imports are in a list of acceptable packages
192+
#- dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())
193+
#- errchkjson # [don't see profit + I'm against of omitting errors like in the first example https://github.com/breml/errchkjson] Checks types passed to the json encoding functions. Reports unsupported types and optionally reports occasions, where the check for the returned error can be omitted.
194+
#- forcetypeassert # [replaced by errcheck] finds forced type assertions
195+
#- gci # Gci controls golang package import order and makes it always deterministic.
196+
- godox # Tool for detection of FIXME, TODO and other comment keywords
197+
#- goerr113 # [too strict] Golang linter to check the errors handling expressions
198+
#- gofmt # [replaced by goimports] Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification
199+
#- gofumpt # [replaced by goimports, gofumports is not available yet] Gofumpt checks whether code was gofumpt-ed.
200+
#- grouper # An analyzer to analyze expression groups.
201+
#- ifshort # Checks that your code uses short syntax for if-statements whenever possible
202+
#- importas # Enforces consistent import aliases
203+
#- maintidx # maintidx measures the maintainability index of each function.
204+
#- misspell # [useless] Finds commonly misspelled English words in comments
205+
#- nlreturn # [too strict and mostly code is not more readable] nlreturn checks for a new line before return and branch statements to increase code clarity
206+
#- paralleltest # [too many false positives] paralleltest detects missing usage of t.Parallel() method in your Go test
207+
#- tagliatelle # Checks the struct tags.
208+
#- thelper # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers
209+
#- wsl # [too strict and mostly code is not more readable] Whitespace Linter - Forces you to use empty lines!
210+
## deprecated
211+
#- exhaustivestruct # [deprecated, replaced by exhaustruct] Checks if all struct's fields are initialized
212+
#- golint # [deprecated, replaced by revive] Golint differs from gofmt. Gofmt reformats Go source code, whereas golint prints out style mistakes
213+
#- interfacer # [deprecated] Linter that suggests narrower interface types
214+
#- maligned # [deprecated, replaced by govet fieldalignment] Tool to detect Go structs that would take less memory if their fields were sorted
215+
#- scopelint # [deprecated, replaced by exportloopref] Scopelint checks for unpinned variables in go programs
216+
125217
issues:
218+
# Maximum count of issues with the same text.
219+
# Set to 0 to disable.
220+
# Default: 3
126221
max-same-issues: 50
127-
formatters:
128-
enable:
129-
- goimports
130-
exclusions:
131-
generated: lax
132-
paths:
133-
- third_party$
134-
- builtin$
135-
- examples$
222+
223+
# exclude:
224+
225+
exclude-rules:
226+
# Allow unused params at the cobra command level
227+
# - linters: [revive]
228+
# text: "unused-parameter: parameter ('cmd'|'args') seems to be unused, consider removing or renaming it as _"
229+
- source: "^//\\s*go:generate\\s"
230+
linters: [lll]
231+
# Allow TODO for now
232+
- source: "(noinspection|TODO)"
233+
linters: [godox]
234+
- source: "//noinspection"
235+
linters: [gocritic]
236+
- source: "^\\s+if _, ok := err\\.\\([^.]+\\.InternalError\\); ok {"
237+
linters: [errorlint]
238+
- path: "_test\\.go"
239+
linters:
240+
# - revive
241+
- bodyclose
242+
- dupl
243+
- funlen
244+
- goconst
245+
- gosec
246+
- noctx
247+
- wrapcheck
248+
- gocognit
249+
- cyclop

0 commit comments

Comments
 (0)