Skip to content

Commit 846662d

Browse files
committed
Fixed linter deprecations
1 parent d5e44a3 commit 846662d

File tree

1 file changed

+114
-100
lines changed

1 file changed

+114
-100
lines changed

.golangci.yml

+114-100
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ run:
77
concurrency: 4
88

99
# timeout for analysis, e.g. 30s, 5m, default is 1m
10-
timeout: 1m
10+
timeout: 6m
1111

1212
# exit code when at least one issue was found, default is 1
1313
issues-exit-code: 1
@@ -19,31 +19,10 @@ run:
1919
build-tags:
2020
- mytag
2121

22-
# which dirs to skip: issues from them won't be reported;
23-
# can use regexp here: generated.*, regexp is applied on full path;
24-
# default value is empty list, but default dirs are skipped independently
25-
# of this option's value (see skip-dirs-use-default).
26-
# "/" will be replaced by current OS file path separator to properly work
27-
# on Windows.
28-
skip-dirs:
29-
- .github
30-
- .make
31-
- dist
32-
3322
# default is true. Enables skipping of directories:
3423
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
3524
skip-dirs-use-default: true
3625

37-
# which files to skip: they will be analyzed, but issues from them
38-
# won't be reported. Default value is empty list, but there is
39-
# no need to include all autogenerated files, we confidently recognize
40-
# autogenerated files. If it's not please let us know.
41-
# "/" will be replaced by current OS file path separator to properly work
42-
# on Windows.
43-
skip-files:
44-
- ".*\\.my\\.go$"
45-
- lib/bad.go
46-
4726
# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
4827
# If invoked with -mod=readonly, the go command is disallowed from the implicit
4928
# automatic updating of go.mod described above. Instead, it fails when any changes
@@ -58,11 +37,11 @@ run:
5837
# If false (default) - golangci-lint acquires file lock on start.
5938
allow-parallel-runners: false
6039

61-
6240
# output configuration options
6341
output:
6442
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
65-
format: colored-line-number
43+
formats:
44+
- format: colored-line-number
6645

6746
# print lines of code with issue, default is true
6847
print-issued-lines: true
@@ -76,7 +55,6 @@ output:
7655
# add a prefix to the output file references; default is no prefix
7756
path-prefix: ""
7857

79-
8058
# all available settings of specific linters
8159
linters-settings:
8260
dogsled:
@@ -94,10 +72,9 @@ linters-settings:
9472
# default is false: such cases aren't reported by default.
9573
check-blank: false
9674

97-
# [deprecated] comma-separated list of pairs of the form pkg:regex
98-
# the regex is used to ignore names within pkg. (default "fmt:.*").
99-
# see https://github.com/kisielk/errcheck#the-deprecated-method for details
100-
ignore: fmt:.*,io/ioutil:^Read.*
75+
# path to a file containing a list of functions to exclude from checking
76+
# see https://github.com/kisielk/errcheck#excluding-functions for details
77+
exclude-functions: fmt:.*,io/ioutil:^Read.*
10178

10279
# path to a file containing a list of functions to exclude from checking
10380
# see https://github.com/kisielk/errcheck#excluding-functions for details
@@ -111,10 +88,8 @@ linters-settings:
11188
lines: 60
11289
statements: 40
11390
gci:
114-
# put imports beginning with prefix after 3rd-party packages;
115-
# only support one prefix
116-
# if not set, use goimports.local-prefixes
117-
local-prefixes: github.com/org/project
91+
sections:
92+
- prefix(github.com/org/project) # Custom section: groups all imports with the specified Prefix.
11893
gocognit:
11994
# minimal code complexity to report, 30 by default (but we recommend 10-20)
12095
min-complexity: 10
@@ -125,7 +100,7 @@ linters-settings:
125100
# minimal length of string constant, 3 by default
126101
min-len: 3
127102
# minimal occurrences count to trigger, 3 by default
128-
min-occurrences: 3
103+
min-occurrences: 10
129104
gocritic:
130105
# Which checks should be enabled; can't be combined with 'disabled-checks';
131106
# See https://go-critic.github.io/overview#checks-overview
@@ -176,35 +151,15 @@ linters-settings:
176151
# define here regexp type values, for example
177152
# AUTHOR: .*@mycompany\.com
178153
template:
179-
# put here copyright header template for source code files, for example:
180-
# {{ AUTHOR }} {{ COMPANY }} {{ YEAR }}
181-
# SPDX-License-Identifier: Apache-2.0
182-
#
183-
# Licensed under the Apache License, Version 2.0 (the "License");
184-
# you may not use this file except in compliance with the License.
185-
# You may obtain a copy of the License at:
186-
#
187-
# http://www.apache.org/licenses/LICENSE-2.0
188-
#
189-
# Unless required by applicable law or agreed to in writing, software
190-
# distributed under the License is distributed on an "AS IS" BASIS,
191-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
192-
# See the License for the specific language governing permissions and
193-
# limitations under the License.
194-
template-path:
195-
# also, as alternative of directive 'template' you may put the path to file with the template source
154+
""
196155
goimports:
197156
# put imports beginning with prefix after 3rd-party packages;
198157
# it's a comma-separated list of prefixes
199158
local-prefixes: github.com/org/project
200-
gomnd:
201-
settings:
202-
mnd:
203-
# the list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.
204-
checks: argument,case,condition,operation,return,assign
159+
golint:
160+
# minimal confidence for issues, default is 0.8
161+
min-confidence: 0.8
205162
govet:
206-
# report about shadowed variables
207-
check-shadowing: true
208163

209164
# settings per analyzer
210165
settings:
@@ -218,27 +173,25 @@ linters-settings:
218173
# enable or disable analyzers by name
219174
enable:
220175
- atomicalign
176+
- shadow
221177
enable-all: false
222-
disable:
223-
#- shadow
178+
#disable:
179+
#- shadow
224180
disable-all: false
225-
depguard:
226-
list-type: blacklist
227-
include-go-root: false
228-
packages:
229-
- github.com/sirupsen/logrus
230-
packages-with-error-message:
231-
# specify an error message to output when a blacklisted package is used
232-
- github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
181+
#depguard:
182+
# list-type: blacklist
183+
# include-go-root: false
184+
# packages:
185+
# - github.com/sirupsen/logrus
186+
# packages-with-error-message:
187+
# # specify an error message to output when a blacklisted package is used
188+
# - github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
233189
lll:
234190
# max line length, lines longer will be reported. Default is 120.
235191
# '\t' is counted as 1 character by default, and can be changed with the tab-width option
236192
line-length: 120
237193
# tab width in spaces. Default to 1.
238194
tab-width: 1
239-
maligned:
240-
# print struct with more effective memory layout or not, false by default
241-
suggest-new: true
242195
misspell:
243196
# Correct spellings using locale preferences for US or UK.
244197
# Default is to use a neutral variety of English.
@@ -263,7 +216,7 @@ linters-settings:
263216
# Enable to ensure that nolint directives are all used. Default is true.
264217
allow-unused: false
265218
# Disable to ensure that nolint directives don't have a leading space. Default is true.
266-
allow-leading-space: true
219+
#allow-leading-space: true
267220
# Exclude following linters from requiring an explanation. Default is [].
268221
allow-no-explanation: []
269222
# Enable to require an explanation of nonzero length after each nolint directive. Default is false.
@@ -283,17 +236,17 @@ linters-settings:
283236
# with golangci-lint call it on a directory with the changed file.
284237
check-exported: false
285238
unused:
286-
# treat code as a program (not a library) and report unused exported identifiers; default is false.
287-
# XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
288-
# if it's called for subdir of a project it can't find funcs usages. All text editor integrations
289-
# with golangci-lint call it on a directory with the changed file.
290-
check-exported: false
239+
# treat code as a program (not a library) and report unused exported identifiers; default is false.
240+
# XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
241+
# if it's called for subdir of a project it can't find funcs usages. All text editor integrations
242+
# with golangci-lint call it on a directory with the changed file.
243+
#check-exported: false
291244
whitespace:
292245
multi-if: false # Enforces newlines (or comments) after every multi-line if statement
293246
multi-func: false # Enforces newlines (or comments) after every multi-line function signature
294247
wsl:
295248
# If true append is only allowed to be cuddled if appending value is
296-
# matching variables, fields or types online above. Default is true.
249+
# matching variables, fields or types on the line above. Default is true.
297250
strict-append: true
298251
# Allow calls and assignments to be cuddled as long as the lines have any
299252
# matching variables, fields or types. Default is true.
@@ -329,40 +282,95 @@ linters-settings:
329282

330283
linters:
331284
enable:
332-
- megacheck
285+
- gosimple
286+
- staticcheck
287+
- unused
333288
- govet
289+
- gofmt
334290
- gosec
335291
- bodyclose
336292
- revive
337293
- unconvert
338-
- dupl
339294
- misspell
340295
- dogsled
341296
- prealloc
342297
- exportloopref
343298
- exhaustive
344299
- sqlclosecheck
345300
- nolintlint
346-
- gci
347-
- goconst
301+
- asciicheck
302+
- bidichk
303+
- bodyclose
304+
- containedctx
305+
- unused
306+
- dogsled
307+
- durationcheck
308+
- errchkjson
309+
- errname
310+
- errorlint
311+
- exhaustive
312+
- forbidigo
313+
- gocheckcompilerdirectives
314+
- gochecknoinits
315+
- gochecksumtype
316+
- goheader
317+
- gosmopolitan
318+
- inamedparam
319+
- makezero
320+
- mirror
321+
- misspell
322+
- musttag
323+
- nosprintfhostport
324+
- prealloc
325+
- predeclared
326+
- reassign
327+
- rowserrcheck
328+
- sqlclosecheck
329+
- unconvert
330+
- wastedassign
331+
- contextcheck
332+
#- perfsprint - this needs more fixes to full use
333+
#- goconst # Turned this off - tons of false positives
348334
disable:
349335
- gocritic # use this for very opinionated linting
350-
- gochecknoglobals
351-
- whitespace
352-
- wsl
353-
- goerr113
354-
- godot
355-
- testpackage
356-
- nestif
357-
- nlreturn
336+
- gci # issues a lot with import sorting
337+
- gochecknoglobals # this project uses some globals
338+
- godot # some comments do not end in a period
339+
- godox # finds all the HACKs
340+
- err113 # requires a lot of fixes for errors with wrapping
341+
- gomnd # we have too many raw numbers that are not magic
342+
- gomoddirectives # we use replace as needed
343+
- nilnil # we do not conform to this
344+
#- contextcheck # having issues with this
358345
disable-all: false
359346
presets:
360347
- bugs
361348
- unused
362349
fast: false
363350

364-
365351
issues:
352+
353+
# which files to skip: they will be analyzed, but issues from them
354+
# won't be reported. Default value is empty list, but there is
355+
# no need to include all autogenerated files, we confidently recognize
356+
# autogenerated files. If it's not please let us know.
357+
# "/" will be replaced by current OS file path separator to properly work
358+
# on Windows.
359+
exclude-files:
360+
- ".*\\.my\\.go$"
361+
- lib/bad.go
362+
363+
# which dirs to skip: issues from them won't be reported;
364+
# can use regexp here: generated.*, regexp is applied on full path;
365+
# default value is empty list, but default dirs are skipped independently
366+
# of this option's value (see skip-dirs-use-default).
367+
# "/" will be replaced by current OS file path separator to properly work
368+
# on Windows.
369+
exclude-dirs:
370+
- .github
371+
- .make
372+
- dist
373+
366374
# List of regexps of issue texts to exclude, empty list by default.
367375
# But independently of this option we use default exclude patterns,
368376
# it can be disabled by `exclude-use-default: false`. To list all
@@ -372,18 +380,10 @@ issues:
372380

373381
# Excluding configuration per-path, per-linter, per-text and per-source
374382
exclude-rules:
375-
- linters:
376-
- gosec
377-
text: "G304:"
378-
379383
# Exclude some linters from running on tests files.
380384
- path: _test\.go
381385
linters:
382386
- gocyclo
383-
- errcheck
384-
- dupl
385-
- gosec
386-
- goconst
387387

388388
# Exclude known linters from partially hard-vendored code,
389389
# which is impossible to exclude via "nolint" comments.
@@ -397,6 +397,16 @@ issues:
397397
- staticcheck
398398
text: "SA1019:"
399399

400+
# Exclude some gosec messages
401+
- linters:
402+
- gosec
403+
text: "G202:"
404+
405+
# Exclude some scopelint messages
406+
- linters:
407+
- scopelint
408+
text: "Using the variable on range scope"
409+
400410
# Exclude lll issues for long lines with go:generate
401411
- linters:
402412
- lll
@@ -412,6 +422,10 @@ issues:
412422
# regular expressions become case-sensitive.
413423
exclude-case-sensitive: false
414424

425+
# The list of IDs of default excludes to include or disable. By default, it's empty.
426+
include:
427+
- EXC0002 # disable excluding of issues about comments from golint
428+
415429
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
416430
max-issues-per-linter: 0
417431

@@ -434,7 +448,7 @@ issues:
434448

435449
severity:
436450
# Default value is empty string.
437-
# Set the default severity for issues. If severity rules are defined and the issues
451+
# Set the default severity for issues. If severity rules are defined, and the issues
438452
# do not match or no severity is provided to the rule this will be the default
439453
# severity applied. Severities should match the supported severity names of the
440454
# selected out format.

0 commit comments

Comments
 (0)