@@ -12,46 +12,37 @@ issues:
12
12
# Set to 0 to disable.
13
13
# Default: 50
14
14
max-issues-per-linter : 0
15
+ exclude-rules :
16
+ # Exclude package name contains '-' issue because we have at least one package with
17
+ # it on its name.
18
+ - text : " ST1003:"
19
+ linters :
20
+ - stylecheck
21
+ # From mage we are priting to the console to ourselves
22
+ - path : (.*magefile.go|.*dev-tools/mage/.*)
23
+ linters :
24
+ - forbidigo
15
25
16
26
output :
17
27
sort-results : true
18
28
19
- # Uncomment and add a path if needed to exclude
20
- # skip-dirs:
21
- # - some/path
22
- # skip-files:
23
- # - ".*\\.my\\.go$"
24
- # - lib/bad.go
25
-
26
29
# Find the whole list here https://golangci-lint.run/usage/linters/
27
30
linters :
28
31
disable-all : true
29
32
enable :
30
- - deadcode # finds unused code
31
33
- errcheck # checking for unchecked errors in go programs
32
34
- 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.
33
- - goconst # finds repeated strings that could be replaced by a constant
34
- - dupl # tool for code clone detection
35
35
- forbidigo # forbids identifiers matched by reg exps
36
- # 'replace' is used in go.mod for many dependencies that come from libbeat. We should work to remove those,
37
- # so we can re-enable this linter.
38
- # - gomoddirectives # manage the use of 'replace', 'retract', and 'excludes' directives in go.mod.
39
- - gomodguard
40
36
- gosimple # linter for Go source code that specializes in simplifying a code
41
37
- misspell # finds commonly misspelled English words in comments
42
38
- nakedret # finds naked returns in functions greater than a specified function length
43
- - prealloc # finds slice declarations that could potentially be preallocated
44
39
- nolintlint # reports ill-formed or insufficient nolint directives
45
40
- staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks
46
41
- stylecheck # a replacement for golint
47
- - unparam # reports unused function parameters
48
42
- unused # checks Go code for unused constants, variables, functions and types
49
-
50
43
- govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
51
44
- ineffassign # detects when assignments to existing variables are not used
52
- - structcheck # finds unused struct fields
53
45
- typecheck # Like the front-end of a Go compiler, parses and type-checks Go code
54
- - varcheck # Finds unused global variables and constants
55
46
- asciicheck # simple linter to check that your code does not contain non-ASCII identifiers
56
47
- bodyclose # checks whether HTTP response body is closed successfully
57
48
- durationcheck # check for two durations multiplied together
@@ -63,14 +54,20 @@ linters:
63
54
- noctx # noctx finds sending http request without context.Context
64
55
- unconvert # Remove unnecessary type conversions
65
56
- wastedassign # wastedassign finds wasted assignment statements.
66
- # - godox # tool for detection of FIXME, TODO and other comment keywords
57
+ - gomodguard # check for blocked dependencies
67
58
68
59
# all available settings of specific linters
69
60
linters-settings :
70
61
errcheck :
71
62
# report about not checking of errors in type assertions: `a := b.(MyStruct)`;
72
- # default is false: such cases aren't reported by default.
73
- check-type-assertions : true
63
+ check-type-assertions : false
64
+ # report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`.
65
+ check-blank : false
66
+ # List of functions to exclude from checking, where each entry is a single function to exclude.
67
+ # See https://github.com/kisielk/errcheck#excluding-functions for details.
68
+ exclude-functions :
69
+ - (mapstr.M).Delete # Only returns ErrKeyNotFound, can safely be ignored.
70
+ - (mapstr.M).Put # Can only fail on type conversions, usually safe to ignore.
74
71
75
72
errorlint :
76
73
# Check whether fmt.Errorf uses the %w verb for formatting errors. See the readme for caveats
@@ -80,85 +77,66 @@ linters-settings:
80
77
# Check for plain error comparisons
81
78
comparison : true
82
79
83
- goconst :
84
- # minimal length of string constant, 3 by default
85
- min-len : 3
86
- # minimal occurrences count to trigger, 3 by default
87
- min-occurrences : 2
88
-
89
- dupl :
90
- # tokens count to trigger issue, 150 by default
91
- threshold : 100
92
-
93
80
forbidigo :
94
81
# Forbid the following identifiers
95
82
forbid :
96
83
- fmt.Print.* # too much log noise
97
84
# Exclude godoc examples from forbidigo checks. Default is true.
98
85
exclude_godoc_examples : true
99
86
100
- gomoddirectives :
101
- # Allow local `replace` directives. Default is false.
102
- replace-local : false
87
+ goimports :
88
+ local-prefixes : github.com/elastic
103
89
104
90
gomodguard :
105
91
blocked :
106
92
# List of blocked modules.
107
93
modules :
108
- - github.com/elastic/beats/v7 :
109
- reason : " There must be no Beats dependency, use elastic-agent-libs instead."
110
-
94
+ # Blocked module.
95
+ - github.com/pkg/errors :
96
+ # Recommended modules that should be used instead. (Optional)
97
+ recommendations :
98
+ - errors
99
+ - fmt
100
+ reason : " This package is deprecated, use `fmt.Errorf` with `%w` instead"
111
101
112
102
gosimple :
113
103
# Select the Go version to target. The default is '1.13'.
114
- go : " 1.17"
115
-
116
- misspell :
117
- # Correct spellings using locale preferences for US or UK.
118
- # Default is to use a neutral variety of English.
119
- # Setting locale to US will correct the British spelling of 'colour' to 'color'.
120
- # locale: US
121
- # ignore-words:
122
- # - IdP
104
+ go : " 1.18.7"
123
105
124
106
nakedret :
125
107
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
126
108
max-func-lines : 0
127
109
128
- prealloc :
129
- # Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
130
- # True by default.
131
- simple : true
132
- range-loops : true # Report preallocation suggestions on range loops, true by default
133
- for-loops : false # Report preallocation suggestions on for loops, false by default
134
-
135
110
nolintlint :
136
111
# Enable to ensure that nolint directives are all used. Default is true.
137
112
allow-unused : false
138
113
# Disable to ensure that nolint directives don't have a leading space. Default is true.
139
- allow-leading-space : true
114
+ allow-leading-space : false
140
115
# Exclude following linters from requiring an explanation. Default is [].
141
116
allow-no-explanation : []
142
117
# Enable to require an explanation of nonzero length after each nolint directive. Default is false.
143
118
require-explanation : true
144
119
# Enable to require nolint directives to mention the specific linter being suppressed. Default is false.
145
- require-specific : true
120
+ require-specific : false
146
121
147
122
staticcheck :
148
123
# Select the Go version to target. The default is '1.13'.
149
- go : " 1.17"
124
+ go : " 1.18.7"
125
+ checks : ["all"]
150
126
151
127
stylecheck :
152
128
# Select the Go version to target. The default is '1.13'.
153
- go : " 1.17"
154
-
155
- unparam :
156
- # Inspect exported functions, default is false. Set to true if no external program/library imports your code.
157
- # XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
158
- # if it's called for subdir of a project it can't find external interfaces. All text editor integrations
159
- # with golangci-lint call it on a directory with the changed file.
160
- check-exported : false
129
+ go : " 1.18.7"
130
+ checks : ["all"]
161
131
162
132
unused :
163
133
# Select the Go version to target. The default is '1.13'.
164
- go : " 1.17"
134
+ go : " 1.18.7"
135
+
136
+ gosec :
137
+ excludes :
138
+ - G306 # Expect WriteFile permissions to be 0600 or less
139
+ - G404 # Use of weak random number generator
140
+ - G401 # Detect the usage of DES, RC4, MD5 or SHA1: Used in non-crypto contexts.
141
+ - G501 # Import blocklist: crypto/md5: Used in non-crypto contexts.
142
+ - G505 # Import blocklist: crypto/sha1: Used in non-crypto contexts.
0 commit comments