|
1 |
| -# options for analysis running |
| 1 | +version: "2" |
2 | 2 | run:
|
3 |
| - # timeout for analysis, e.g. 30s, 5m, default is 1m |
4 |
| - timeout: 15m |
5 | 3 | build-tags:
|
6 |
| - - synthetics |
7 | 4 | - integration
|
8 |
| - |
9 |
| -issues: |
10 |
| - # Maximum count of issues with the same text. |
11 |
| - # Set to 0 to disable. |
12 |
| - # Default: 3 |
13 |
| - max-same-issues: 3 |
14 |
| - # Maximum issues count per one linter. |
15 |
| - # Set to 0 to disable. |
16 |
| - # Default: 50 |
17 |
| - max-issues-per-linter: 50 |
18 |
| - exclude-rules: |
19 |
| - # Exclude package name contains '-' issue because we have at least one package with |
20 |
| - # it on its name. |
21 |
| - - text: "ST1003:" |
22 |
| - linters: |
23 |
| - - stylecheck |
24 |
| - - text: "undefined" |
25 |
| - linters: |
26 |
| - - typecheck |
27 |
| - - text: "undeclared name:" |
28 |
| - linters: |
29 |
| - - typecheck |
30 |
| - - text: "imported and not used" |
31 |
| - linters: |
32 |
| - - typecheck |
33 |
| - - text: "previous case" |
34 |
| - linters: |
35 |
| - - typecheck |
36 |
| - # From mage we are printing to the console to ourselves |
37 |
| - - path: (.*magefile.go|.*dev-tools/mage/.*) |
38 |
| - linters: forbidigo |
39 |
| - |
40 |
| -output: |
41 |
| - sort-results: true |
42 |
| - |
43 |
| -# Find the whole list here https://golangci-lint.run/usage/linters/ |
44 | 5 | linters:
|
45 |
| - disable-all: true |
| 6 | + default: none |
46 | 7 | enable:
|
47 |
| - - errcheck # checking for unchecked errors in go programs |
48 |
| - - 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. |
49 |
| - - forbidigo # forbids identifiers matched by reg exps |
50 |
| - - gosimple # linter for Go source code that specializes in simplifying a code |
51 |
| - - misspell # finds commonly misspelled English words in comments |
52 |
| - - nakedret # finds naked returns in functions greater than a specified function length |
53 |
| - - nolintlint # reports ill-formed or insufficient nolint directives |
54 |
| - - staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks |
55 |
| - - stylecheck # a replacement for golint |
56 |
| - - unused # checks Go code for unused constants, variables, functions and types |
57 |
| - - govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string |
58 |
| - - ineffassign # detects when assignments to existing variables are not used |
59 |
| - - asciicheck # simple linter to check that your code does not contain non-ASCII identifiers |
60 |
| - - bodyclose # checks whether HTTP response body is closed successfully |
61 |
| - - durationcheck # check for two durations multiplied together |
62 |
| - - exportloopref # checks for pointers to enclosing loop variables |
63 |
| - - goimports # Goimports does everything that gofmt does. Additionally it checks unused imports |
64 |
| - - gosec # inspects source code for security problems |
65 |
| - - importas # enforces consistent import aliases |
66 |
| - - nilerr # finds the code that returns nil even if it checks that the error is not nil. |
67 |
| - - noctx # noctx finds sending http request without context.Context |
68 |
| - - unconvert # Remove unnecessary type conversions |
69 |
| - - wastedassign # wastedassign finds wasted assignment statements. |
70 |
| - - gomodguard # check for blocked dependencies in go.mod |
71 |
| - - depguard # check for blocked dependencies in Go files |
| 8 | + - asciicheck |
| 9 | + - bodyclose |
| 10 | + - depguard |
| 11 | + - durationcheck |
| 12 | + - errcheck |
| 13 | + - errorlint |
| 14 | + - forbidigo |
72 | 15 | - gomoddirectives
|
73 |
| - |
74 |
| -# all available settings of specific linters |
75 |
| -linters-settings: |
76 |
| - depguard: |
| 16 | + - gomodguard |
| 17 | + - gosec |
| 18 | + - govet |
| 19 | + - importas |
| 20 | + - ineffassign |
| 21 | + - misspell |
| 22 | + - nakedret |
| 23 | + - nilerr |
| 24 | + - noctx |
| 25 | + - nolintlint |
| 26 | + - staticcheck |
| 27 | + - unconvert |
| 28 | + - unused |
| 29 | + - wastedassign |
| 30 | + settings: |
| 31 | + depguard: |
| 32 | + rules: |
| 33 | + apache-licensed-code: |
| 34 | + list-mode: lax |
| 35 | + files: |
| 36 | + - '!**/x-pack/**/*.go' |
| 37 | + deny: |
| 38 | + - pkg: github.com/elastic/beats/v7/x-pack |
| 39 | + desc: Apache 2.0 licensed code cannot depend on Elastic licensed code (x-pack/). |
| 40 | + main: |
| 41 | + list-mode: lax |
| 42 | + deny: |
| 43 | + - pkg: math/rand$ |
| 44 | + desc: superseded by math/rand/v2 |
| 45 | + errcheck: |
| 46 | + check-type-assertions: true |
| 47 | + check-blank: false |
| 48 | + exclude-functions: |
| 49 | + - (github.com/elastic/elastic-agent-libs/mapstr.M).Delete |
| 50 | + - (github.com/elastic/elastic-agent-libs/mapstr.M).Put |
| 51 | + - github.com/elastic/elastic-agent-libs/logp.TestingSetup |
| 52 | + - github.com/elastic/elastic-agent-libs/logp.DevelopmentSetup |
| 53 | + errorlint: |
| 54 | + errorf: true |
| 55 | + asserts: true |
| 56 | + comparison: true |
| 57 | + forbidigo: |
| 58 | + forbid: |
| 59 | + - pattern: fmt.Print.* |
| 60 | + gomoddirectives: |
| 61 | + replace-allow-list: |
| 62 | + - github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption |
| 63 | + - github.com/Shopify/sarama |
| 64 | + - github.com/apoydence/eachers |
| 65 | + - github.com/dop251/goja |
| 66 | + - github.com/dop251/goja_nodejs |
| 67 | + - github.com/fsnotify/fsevents |
| 68 | + - github.com/fsnotify/fsnotify |
| 69 | + - github.com/google/gopacket |
| 70 | + - github.com/insomniacslk/dhcp |
| 71 | + - github.com/meraki/dashboard-api-go/v3 |
| 72 | + - github.com/snowflakedb/gosnowflake |
| 73 | + replace-local: false |
| 74 | + gomodguard: |
| 75 | + blocked: |
| 76 | + modules: |
| 77 | + - github.com/pkg/errors: |
| 78 | + recommendations: |
| 79 | + - errors |
| 80 | + - fmt |
| 81 | + reason: This package is deprecated, use `fmt.Errorf` with `%w` instead |
| 82 | + - gotest.tools/v3: |
| 83 | + recommendations: |
| 84 | + - github.com/stretchr/testify |
| 85 | + reason: Use one assertion library consistently across the codebase |
| 86 | + - github.com/google/uuid: |
| 87 | + recommendations: |
| 88 | + - github.com/gofrs/uuid/v5 |
| 89 | + reason: Use one uuid library consistently across the codebase |
| 90 | + gosec: |
| 91 | + excludes: |
| 92 | + - G306 |
| 93 | + - G404 |
| 94 | + - G401 |
| 95 | + - G501 |
| 96 | + - G505 |
| 97 | + nolintlint: |
| 98 | + require-explanation: true |
| 99 | + require-specific: false |
| 100 | + allow-unused: false |
| 101 | + prealloc: |
| 102 | + simple: false |
| 103 | + range-loops: true |
| 104 | + for-loops: true |
| 105 | + staticcheck: |
| 106 | + checks: |
| 107 | + - -ST1005 |
| 108 | + - all |
| 109 | + exclusions: |
| 110 | + generated: lax |
| 111 | + presets: |
| 112 | + - comments |
| 113 | + - common-false-positives |
| 114 | + - legacy |
| 115 | + - std-error-handling |
77 | 116 | rules:
|
78 |
| - main: |
79 |
| - list-mode: lax |
80 |
| - deny: |
81 |
| - - pkg: "math/rand$" |
82 |
| - desc: "superseded by math/rand/v2" |
83 |
| - apache-licensed-code: |
84 |
| - list-mode: lax |
85 |
| - files: |
86 |
| - - '!**/x-pack/**/*.go' |
87 |
| - deny: |
88 |
| - - pkg: github.com/elastic/beats/v7/x-pack |
89 |
| - desc: Apache 2.0 licensed code cannot depend on Elastic licensed code (x-pack/). |
90 |
| - errcheck: |
91 |
| - # report about not checking of errors in type assertions: `a := b.(MyStruct)`; |
92 |
| - # default is false: such cases aren't reported by default. |
93 |
| - check-type-assertions: true |
94 |
| - # report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`. |
95 |
| - check-blank: false |
96 |
| - # List of functions to exclude from checking, where each entry is a single function to exclude. |
97 |
| - # See https://github.com/kisielk/errcheck#excluding-functions for details. |
98 |
| - exclude-functions: |
99 |
| - - (github.com/elastic/elastic-agent-libs/mapstr.M).Delete # Only returns ErrKeyNotFound, can safely be ignored. |
100 |
| - - (github.com/elastic/elastic-agent-libs/mapstr.M).Put # Can only fail on type conversions, usually safe to ignore. |
101 |
| - - github.com/elastic/elastic-agent-libs/logp.TestingSetup # Cannot return a non-nil error using the provided API. |
102 |
| - - github.com/elastic/elastic-agent-libs/logp.DevelopmentSetup # Cannot return a non-nil error using the provided API. |
103 |
| - |
104 |
| - errorlint: |
105 |
| - # Check whether fmt.Errorf uses the %w verb for formatting errors. See the readme for caveats |
106 |
| - errorf: true |
107 |
| - # Check for plain type assertions and type switches |
108 |
| - asserts: true |
109 |
| - # Check for plain error comparisons |
110 |
| - comparison: true |
111 |
| - |
112 |
| - forbidigo: |
113 |
| - # Forbid the following identifiers |
114 |
| - forbid: |
115 |
| - - fmt.Print.* # too much log noise |
116 |
| - # Exclude godoc examples from forbidigo checks. Default is true. |
117 |
| - exclude_godoc_examples: true |
118 |
| - |
119 |
| - goimports: |
120 |
| - local-prefixes: github.com/elastic |
121 |
| - |
122 |
| - gomodguard: |
123 |
| - blocked: |
124 |
| - # List of blocked modules. |
125 |
| - modules: |
126 |
| - # Blocked module. |
127 |
| - - github.com/pkg/errors: |
128 |
| - # Recommended modules that should be used instead. (Optional) |
129 |
| - recommendations: |
130 |
| - - errors |
131 |
| - - fmt |
132 |
| - reason: "This package is deprecated, use `fmt.Errorf` with `%w` instead" |
133 |
| - - gotest.tools/v3: |
134 |
| - recommendations: |
135 |
| - - github.com/stretchr/testify |
136 |
| - reason: "Use one assertion library consistently across the codebase" |
137 |
| - - github.com/google/uuid: |
138 |
| - # Recommended modules that should be used instead. (Optional) |
139 |
| - recommendations: |
140 |
| - - github.com/gofrs/uuid/v5 |
141 |
| - reason: "Use one uuid library consistently across the codebase" |
142 |
| - |
143 |
| - gomoddirectives: |
144 |
| - # Forbid local `replace` directives |
145 |
| - replace-local: false |
146 |
| - |
147 |
| - # Forbid any `replace` directives that are intended temporarily only during |
148 |
| - # development. The modules listed below are intended to be replaced permanently. |
149 |
| - replace-allow-list: |
150 |
| - - github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption |
151 |
| - - github.com/Shopify/sarama |
152 |
| - - github.com/apoydence/eachers |
153 |
| - - github.com/dop251/goja |
154 |
| - - github.com/dop251/goja_nodejs |
155 |
| - - github.com/fsnotify/fsevents |
156 |
| - - github.com/fsnotify/fsnotify |
157 |
| - - github.com/google/gopacket |
158 |
| - - github.com/insomniacslk/dhcp |
159 |
| - - github.com/meraki/dashboard-api-go/v3 |
160 |
| - - github.com/snowflakedb/gosnowflake |
161 |
| - |
162 |
| - nakedret: |
163 |
| - # make an issue if func has more lines of code than this setting and it has naked returns; default is 30 |
164 |
| - max-func-lines: 0 |
165 |
| - |
166 |
| - nolintlint: |
167 |
| - # Enable to ensure that nolint directives are all used. Default is true. |
168 |
| - allow-unused: false |
169 |
| - # Exclude following linters from requiring an explanation. Default is []. |
170 |
| - allow-no-explanation: [] |
171 |
| - # Enable to require an explanation of nonzero length after each nolint directive. Default is false. |
172 |
| - require-explanation: true |
173 |
| - # Enable to require nolint directives to mention the specific linter being suppressed. Default is false. |
174 |
| - require-specific: false |
175 |
| - |
176 |
| - staticcheck: |
177 |
| - checks: ["all"] |
178 |
| - |
179 |
| - stylecheck: |
180 |
| - # Disabled: |
181 |
| - # ST1005: error strings should not be capitalized |
182 |
| - checks: ["all", "-ST1005"] |
183 |
| - |
184 |
| - gosec: |
185 |
| - excludes: |
186 |
| - - G306 # Expect WriteFile permissions to be 0600 or less |
187 |
| - - G404 # Use of weak random number generator |
188 |
| - - G401 # Detect the usage of DES, RC4, MD5 or SHA1: Used in non-crypto contexts. |
189 |
| - - G501 # Import blocklist: crypto/md5: Used in non-crypto contexts. |
190 |
| - - G505 # Import blocklist: crypto/sha1: Used in non-crypto contexts. |
191 |
| - |
192 |
| - prealloc: |
193 |
| - # IMPORTANT: we don't recommend using this linter before doing performance profiling. |
194 |
| - # For most programs usage of prealloc will be a premature optimization. |
195 |
| - |
196 |
| - # Report pre-allocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them. |
197 |
| - # Default: true |
198 |
| - simple: false |
199 |
| - # Report pre-allocation suggestions on range loops. |
200 |
| - # Default: true |
201 |
| - range-loops: true |
202 |
| - # Report pre-allocation suggestions on for loops. |
203 |
| - # Default: false |
204 |
| - for-loops: true |
| 117 | + - linters: |
| 118 | + - staticcheck |
| 119 | + text: 'ST1003:' |
| 120 | + - linters: |
| 121 | + - forbidigo |
| 122 | + path: (.*magefile.go|.*dev-tools/mage/.*) |
| 123 | + paths: |
| 124 | + - third_party$ |
| 125 | + - builtin$ |
| 126 | + - examples$ |
| 127 | +issues: |
| 128 | + max-issues-per-linter: 50 |
| 129 | + max-same-issues: 3 |
| 130 | +formatters: |
| 131 | + enable: |
| 132 | + - goimports |
| 133 | + settings: |
| 134 | + goimports: |
| 135 | + local-prefixes: |
| 136 | + - github.com/elastic |
| 137 | + exclusions: |
| 138 | + generated: lax |
| 139 | + paths: |
| 140 | + - third_party$ |
| 141 | + - builtin$ |
| 142 | + - examples$ |
0 commit comments