Skip to content

Commit

Permalink
Fixed linter deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1836 committed Jun 3, 2024
1 parent d5e44a3 commit 846662d
Showing 1 changed file with 114 additions and 100 deletions.
214 changes: 114 additions & 100 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ run:
concurrency: 4

# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 1m
timeout: 6m

# exit code when at least one issue was found, default is 1
issues-exit-code: 1
Expand All @@ -19,31 +19,10 @@ run:
build-tags:
- mytag

# which dirs to skip: issues from them won't be reported;
# can use regexp here: generated.*, regexp is applied on full path;
# default value is empty list, but default dirs are skipped independently
# of this option's value (see skip-dirs-use-default).
# "/" will be replaced by current OS file path separator to properly work
# on Windows.
skip-dirs:
- .github
- .make
- dist

# default is true. Enables skipping of directories:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs-use-default: true

# which files to skip: they will be analyzed, but issues from them
# won't be reported. Default value is empty list, but there is
# no need to include all autogenerated files, we confidently recognize
# autogenerated files. If it's not please let us know.
# "/" will be replaced by current OS file path separator to properly work
# on Windows.
skip-files:
- ".*\\.my\\.go$"
- lib/bad.go

# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
# If invoked with -mod=readonly, the go command is disallowed from the implicit
# automatic updating of go.mod described above. Instead, it fails when any changes
Expand All @@ -58,11 +37,11 @@ run:
# If false (default) - golangci-lint acquires file lock on start.
allow-parallel-runners: false


# output configuration options
output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
format: colored-line-number
formats:
- format: colored-line-number

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


# all available settings of specific linters
linters-settings:
dogsled:
Expand All @@ -94,10 +72,9 @@ linters-settings:
# default is false: such cases aren't reported by default.
check-blank: false

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

# path to a file containing a list of functions to exclude from checking
# see https://github.com/kisielk/errcheck#excluding-functions for details
Expand All @@ -111,10 +88,8 @@ linters-settings:
lines: 60
statements: 40
gci:
# put imports beginning with prefix after 3rd-party packages;
# only support one prefix
# if not set, use goimports.local-prefixes
local-prefixes: github.com/org/project
sections:
- prefix(github.com/org/project) # Custom section: groups all imports with the specified Prefix.
gocognit:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 10
Expand All @@ -125,7 +100,7 @@ linters-settings:
# minimal length of string constant, 3 by default
min-len: 3
# minimal occurrences count to trigger, 3 by default
min-occurrences: 3
min-occurrences: 10
gocritic:
# Which checks should be enabled; can't be combined with 'disabled-checks';
# See https://go-critic.github.io/overview#checks-overview
Expand Down Expand Up @@ -176,35 +151,15 @@ linters-settings:
# define here regexp type values, for example
# AUTHOR: .*@mycompany\.com
template:
# put here copyright header template for source code files, for example:
# {{ AUTHOR }} {{ COMPANY }} {{ YEAR }}
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
template-path:
# also, as alternative of directive 'template' you may put the path to file with the template source
""
goimports:
# put imports beginning with prefix after 3rd-party packages;
# it's a comma-separated list of prefixes
local-prefixes: github.com/org/project
gomnd:
settings:
mnd:
# the list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.
checks: argument,case,condition,operation,return,assign
golint:
# minimal confidence for issues, default is 0.8
min-confidence: 0.8
govet:
# report about shadowed variables
check-shadowing: true

# settings per analyzer
settings:
Expand All @@ -218,27 +173,25 @@ linters-settings:
# enable or disable analyzers by name
enable:
- atomicalign
- shadow
enable-all: false
disable:
#- shadow
#disable:
#- shadow
disable-all: false
depguard:
list-type: blacklist
include-go-root: false
packages:
- github.com/sirupsen/logrus
packages-with-error-message:
# specify an error message to output when a blacklisted package is used
- github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
#depguard:
# list-type: blacklist
# include-go-root: false
# packages:
# - github.com/sirupsen/logrus
# packages-with-error-message:
# # specify an error message to output when a blacklisted package is used
# - github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
lll:
# max line length, lines longer will be reported. Default is 120.
# '\t' is counted as 1 character by default, and can be changed with the tab-width option
line-length: 120
# tab width in spaces. Default to 1.
tab-width: 1
maligned:
# print struct with more effective memory layout or not, false by default
suggest-new: true
misspell:
# Correct spellings using locale preferences for US or UK.
# Default is to use a neutral variety of English.
Expand All @@ -263,7 +216,7 @@ linters-settings:
# Enable to ensure that nolint directives are all used. Default is true.
allow-unused: false
# Disable to ensure that nolint directives don't have a leading space. Default is true.
allow-leading-space: true
#allow-leading-space: true
# Exclude following linters from requiring an explanation. Default is [].
allow-no-explanation: []
# Enable to require an explanation of nonzero length after each nolint directive. Default is false.
Expand All @@ -283,17 +236,17 @@ linters-settings:
# with golangci-lint call it on a directory with the changed file.
check-exported: false
unused:
# treat code as a program (not a library) and report unused exported identifiers; default is false.
# XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
# if it's called for subdir of a project it can't find funcs usages. All text editor integrations
# with golangci-lint call it on a directory with the changed file.
check-exported: false
# treat code as a program (not a library) and report unused exported identifiers; default is false.
# XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
# if it's called for subdir of a project it can't find funcs usages. All text editor integrations
# with golangci-lint call it on a directory with the changed file.
#check-exported: false
whitespace:
multi-if: false # Enforces newlines (or comments) after every multi-line if statement
multi-func: false # Enforces newlines (or comments) after every multi-line function signature
wsl:
# If true append is only allowed to be cuddled if appending value is
# matching variables, fields or types online above. Default is true.
# matching variables, fields or types on the line above. Default is true.
strict-append: true
# Allow calls and assignments to be cuddled as long as the lines have any
# matching variables, fields or types. Default is true.
Expand Down Expand Up @@ -329,40 +282,95 @@ linters-settings:

linters:
enable:
- megacheck
- gosimple
- staticcheck
- unused
- govet
- gofmt
- gosec
- bodyclose
- revive
- unconvert
- dupl
- misspell
- dogsled
- prealloc
- exportloopref
- exhaustive
- sqlclosecheck
- nolintlint
- gci
- goconst
- asciicheck
- bidichk
- bodyclose
- containedctx
- unused
- dogsled
- durationcheck
- errchkjson
- errname
- errorlint
- exhaustive
- forbidigo
- gocheckcompilerdirectives
- gochecknoinits
- gochecksumtype
- goheader
- gosmopolitan
- inamedparam
- makezero
- mirror
- misspell
- musttag
- nosprintfhostport
- prealloc
- predeclared
- reassign
- rowserrcheck
- sqlclosecheck
- unconvert
- wastedassign
- contextcheck
#- perfsprint - this needs more fixes to full use
#- goconst # Turned this off - tons of false positives
disable:
- gocritic # use this for very opinionated linting
- gochecknoglobals
- whitespace
- wsl
- goerr113
- godot
- testpackage
- nestif
- nlreturn
- gci # issues a lot with import sorting
- gochecknoglobals # this project uses some globals
- godot # some comments do not end in a period
- godox # finds all the HACKs
- err113 # requires a lot of fixes for errors with wrapping
- gomnd # we have too many raw numbers that are not magic
- gomoddirectives # we use replace as needed
- nilnil # we do not conform to this
#- contextcheck # having issues with this
disable-all: false
presets:
- bugs
- unused
fast: false


issues:

# which files to skip: they will be analyzed, but issues from them
# won't be reported. Default value is empty list, but there is
# no need to include all autogenerated files, we confidently recognize
# autogenerated files. If it's not please let us know.
# "/" will be replaced by current OS file path separator to properly work
# on Windows.
exclude-files:
- ".*\\.my\\.go$"
- lib/bad.go

# which dirs to skip: issues from them won't be reported;
# can use regexp here: generated.*, regexp is applied on full path;
# default value is empty list, but default dirs are skipped independently
# of this option's value (see skip-dirs-use-default).
# "/" will be replaced by current OS file path separator to properly work
# on Windows.
exclude-dirs:
- .github
- .make
- dist

# List of regexps of issue texts to exclude, empty list by default.
# But independently of this option we use default exclude patterns,
# it can be disabled by `exclude-use-default: false`. To list all
Expand All @@ -372,18 +380,10 @@ issues:

# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
- linters:
- gosec
text: "G304:"

# Exclude some linters from running on tests files.
- path: _test\.go
linters:
- gocyclo
- errcheck
- dupl
- gosec
- goconst

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

# Exclude some gosec messages
- linters:
- gosec
text: "G202:"

# Exclude some scopelint messages
- linters:
- scopelint
text: "Using the variable on range scope"

# Exclude lll issues for long lines with go:generate
- linters:
- lll
Expand All @@ -412,6 +422,10 @@ issues:
# regular expressions become case-sensitive.
exclude-case-sensitive: false

# The list of IDs of default excludes to include or disable. By default, it's empty.
include:
- EXC0002 # disable excluding of issues about comments from golint

# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
max-issues-per-linter: 0

Expand All @@ -434,7 +448,7 @@ issues:

severity:
# Default value is empty string.
# Set the default severity for issues. If severity rules are defined and the issues
# Set the default severity for issues. If severity rules are defined, and the issues
# do not match or no severity is provided to the rule this will be the default
# severity applied. Severities should match the supported severity names of the
# selected out format.
Expand Down

0 comments on commit 846662d

Please sign in to comment.