-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy path.golangci.yaml
More file actions
120 lines (113 loc) · 4.85 KB
/
Copy path.golangci.yaml
File metadata and controls
120 lines (113 loc) · 4.85 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
version: "2"
run:
tests: true
issues:
max-issues-per-linter: 0
max-same-issues: 0
linters:
enable:
- "asasalint" # Check for pass []any as any in variadic func(...any).
- "bodyclose" # Checks whether HTTP response body is closed successfully.
- "dupword" # Checks for duplicate words in the source code.
- "errcheck" # Checks for unchecked errors.
- "errorlint" # Verifies errors are properly wrapped.
- "errname" # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error.
- "gocheckcompilerdirectives" # Checks that go compiler directive comments (//go:) are valid.
- "gochecksumtype" # Run exhaustiveness checks on Go "sum types".
# TODO: enable gosec - when bored, run 'golangci-lint run -Egosec' and fix issues
# - "gosec" # Checks for potential security issues
- "gomoddirectives" # Manages 'replace', 'retract' and 'excludes' directives in go.mod.
- "gosmopolitan" # Report certain i18n/l10n anti-patterns in your Go codebase.
- "govet" # Runs go vet.
- "ineffassign" # Detects when assignments to variables are not used.
- "makezero" # Finds slice declarations with non-zero initial length and later used with append.
- "misspell" # Finds common typing mistakes
- "nilerr" # Finds the code that returns nil even if it checks that the error is not nil.
- "noctx" # Finds http requests without context.Context.
- "nolintlint" # Reports ill-formed or insufficient nolint directives.
- "perfsprint" # Finds uses of formatting that can be replaced with a faster alternative.
- "prealloc" # Finds slice declarations that could potentially be pre-allocated.
- "predeclared" # Find code that shadows one of Go's predeclared identifiers.
- "promlinter" # Check Prometheus metrics naming via promlint.
# TODO: enable revive - when bored, run 'golangci-lint run -Erevive' and fix issues
# - "revive" # Miscellaneous linter
- "staticcheck" # Runs staticcheck.
- "sqlclosecheck" # Checks that sql.Rows, sql.Stmt, sqlx.NamedStmt, pgx.Query are closed.
- "rowserrcheck" # Checks whether Rows.Err of rows is checked successfully.
- "unconvert" # Checks for unnecessary type conversions.
- "usestdlibvars" # Detects the possibility to use variables/constants from stdlib.
- "usetesting" # Reports use of functions with replacements inside the testing package.
- "unused" # Checks for unused constants, variables, functions and types.
- "whitespace" # Checks for unnecessary newlines at the start and end of functions, if, for, etc.
# TODO: enable wrapcheck - when bored, run 'golangci-lint run -Ewrapcheck' and fix issues
# - "wrapcheck" # Checks that errors returned from external packages are wrapped.
settings:
errcheck:
exclude-functions:
- "loggo.ConfigureLoggers(string)"
gocritic:
disabled-checks:
- "elseif"
- "exitAfterDefer"
- "ifElseChain"
- "singleCaseSwitch"
godox: # Finds todo comments; Use: golangci-lint run --enable-only godox
keywords:
- "XXX"
- "TODO"
- "FIXME"
nolintlint:
# Require an explanation after each nolint directive.
# Explanation format example: '//nolint:ineffassign // Explanation goes here.'
# If this becomes too annoying, disable it.
require-explanation: true
exclusions:
generated: "strict"
presets:
- "comments"
- "common-false-positives"
- "legacy"
- "std-error-handling"
rules:
# Avoid applying De Morgan's law automatically.
- linters: [ "staticcheck" ]
text: "QF1001:" # "could apply De Morgan's law"
# Avoid automatically merging conditional assignments into var declarations.
- linters: [ "staticcheck" ]
text: "QF1007:" # "could merge conditional assignment into var declaration"
# Ignore "response body must be closed" when calling websocket.Dial.
# Response body closure is handled by the websocket library.
- linters: [ "bodyclose" ]
text: "response body must be closed"
source: "websocket\\.Dial"
# Ignore not checking return value of c.CloseNow (websocket) in tests.
- path: "(.+)_test\\.go"
linters: [ "errcheck" ]
text: "Error return value of `c.CloseNow` is not checked"
# Ignore some linters in tests
- path: "(.+)_test\\.go"
linters:
- prealloc
paths:
- "third_party$"
- "builtin$"
- "examples$"
formatters:
enable:
- "goimports"
- "gci" # Enforces package import order, making it deterministic.
- "gofumpt" # An extended version of go fmt.
settings:
gci:
sections:
- "standard"
- "default"
- "blank"
- "dot"
- "localmodule"
custom-order: true
exclusions:
paths:
- "third_party$"
- "builtin$"
- "examples$"