Skip to content

Commit

Permalink
Fixed linter deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1836 committed May 3, 2024
1 parent cb4f303 commit bf3a40c
Showing 1 changed file with 116 additions and 100 deletions.
216 changes: 116 additions & 100 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

# options for analysis running
run:
# default concurrency is a available CPU number
# default concurrency is an available CPU number
concurrency: 4

# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 2m
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
# from 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 Down Expand Up @@ -111,10 +89,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 +101,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 +152,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,18 +174,19 @@ 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
Expand All @@ -245,7 +202,7 @@ linters-settings:
- bsv
- bitcoin
nakedret:
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
# make an issue if func has more lines of code than this setting, and it has naked returns; default is 30
max-func-lines: 30
prealloc:
# XXX: we don't recommend using this linter before doing performance profiling.
Expand All @@ -260,7 +217,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 @@ -280,17 +237,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 on line 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 All @@ -308,7 +265,7 @@ linters-settings:
# Allow leading comments to be separated with empty liens
allow-separated-leading-comment: false
gofumpt:
# Choose whether or not to use the extra rules that are disabled
# Choose whether to use the extra rules that are disabled
# by default
extra-rules: false

Expand All @@ -328,6 +285,7 @@ linters:
enable:
- megacheck
- govet
- gofmt
- gosec
- bodyclose
- revive
Expand All @@ -339,48 +297,92 @@ linters:
- exhaustive
- sqlclosecheck
- nolintlint
- gci
#- goconst
#- lll
- asciicheck
- bidichk
- bodyclose
- containedctx
- unused
- dogsled
- durationcheck
- errchkjson
- 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:
- dupl
- gochecknoglobals
- gocritic # use this for very opinionated linting
- godot
- goerr113
- nestif
- nlreturn
- testpackage
- whitespace
- wsl
- testifylint
- 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
- goerr113 # 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
- errname # this needs some refactoring
#- 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 from this option we use default exclude patterns,
# But independently of this option we use default exclude patterns,
# it can be disabled by `exclude-use-default: false`. To list all
# excluded by default patterns execute `golangci-lint run --help`
exclude:
- Using the variable on range scope .* in function literal
- abcdef

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

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

# Exclude known linters from partially hard-vendored code,
# which is impossible to exclude via "nolint" comments.
Expand All @@ -394,6 +396,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 @@ -406,9 +418,13 @@ issues:
exclude-use-default: false

# The default value is false. If set to true exclude and exclude-rules
# regular expressions become case sensitive.
# 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 @@ -431,17 +447,17 @@ 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.
# - Code climate: https://docs.codeclimate.com/docs/issues#issue-severity
# - Checkstyle: https://checkstyle.sourceforge.io/property_types.html#severity
# - GitHub: https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-error-message
# - Github: https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-error-message
default-severity: error

# The default value is false.
# If set to true severity-rules regular expressions become case sensitive.
# If set to true severity-rules regular expressions become case-sensitive.
case-sensitive: false

# Default value is empty list.
Expand Down

0 comments on commit bf3a40c

Please sign in to comment.