Skip to content

Commit

Permalink
Fixed linter deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1836 committed Apr 29, 2024
1 parent 5868537 commit d3d2cb5
Showing 1 changed file with 124 additions and 77 deletions.
201 changes: 124 additions & 77 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: 5m
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 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 @@ -166,24 +142,25 @@ linters-settings:
gofmt:
# simplify code: gofmt with `-s` option, true by default
simplify: true
goheader:
values:
const:
# define here const type values in format k:v, for example:
# YEAR: 2020
# COMPANY: MY COMPANY
regexp:
# define here regexp type values, for example
# AUTHOR: .*@mycompany\.com
template:
""
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 @@ -197,25 +174,25 @@ linters-settings:
# enable or disable analyzers by name
enable:
- atomicalign
- shadow
enable-all: false
#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 @@ -240,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 @@ -256,21 +233,21 @@ linters-settings:
unparam:
# Inspect exported functions, default is false. Set to true if no external program/library imports your code.
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
# if it's called for sub-dir of a project it can't find external interfaces. All text editor integrations
# if it's called for subdir of a project it can't find external interfaces. All text editor integrations
# 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 sub-dir of a project it can't find function 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 @@ -308,61 +285,127 @@ linters:
enable:
- megacheck
- govet
- gofmt
- gosec
- bodyclose
- revive
- unconvert
- dupl
- misspell
- ineffassign
- dogsled
- prealloc
- exportloopref
- exhaustive
- sqlclosecheck
- nolintlint
- gci
- 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
- 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
#- 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
# 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:
# Exclude some linters from running on tests files.
- path: _test\.go
linters:
- gocyclo
- errcheck
- dupl
- gosec

# Exclude known linters from partially "hard-vendored" code,
# Exclude known linters from partially hard-vendored code,
# which is impossible to exclude via "nolint" comments.
- path: internal/hmac/
text: "weak cryptographic primitive"
linters:
- gosec

# Exclude some "staticcheck" messages
# Exclude some staticcheck messages
- linters:
- 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 @@ -378,13 +421,17 @@ 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

# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
max-same-issues: 0

# Show only new issues: if there are "un-staged" changes or untracked files,
# Show only new issues: if there are unstaged changes or untracked files,
# only those changes are analyzed, else only changes in HEAD~ are analyzed.
# It's a super-useful option for integration of golangci-lint into existing
# large codebase. It's not practical to fix all existing issues at the moment
Expand All @@ -400,13 +447,13 @@ 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.
Expand Down

0 comments on commit d3d2cb5

Please sign in to comment.