Merge pull request #7076 from yyforyongyu/tune-linters

golangci: fine-tune enabled linters
This commit is contained in:
Oliver Gugger
2022-10-25 09:44:57 +02:00
committed by GitHub

View File

@@ -29,20 +29,25 @@ linters-settings:
govet: govet:
# Don't report about shadowed variables # Don't report about shadowed variables
check-shadowing: false check-shadowing: false
gofmt: gofmt:
# simplify code: gofmt with `-s` option, true by default # simplify code: gofmt with `-s` option, true by default
simplify: true simplify: true
tagliatelle: tagliatelle:
case: case:
rules: rules:
json: snake json: snake
whitespace: whitespace:
multi-func: true multi-func: true
multi-if: true multi-if: true
gosec: gosec:
excludes: excludes:
- G402 # Look for bad TLS connection settings. - G402 # Look for bad TLS connection settings.
- G306 # Poor file permissions used when writing to a new file. - G306 # Poor file permissions used when writing to a new file.
staticcheck: staticcheck:
go: "1.18" go: "1.18"
checks: ["-SA1019"] checks: ["-SA1019"]
@@ -56,11 +61,22 @@ linters-settings:
funlen: funlen:
# Checks the number of lines in a function. # Checks the number of lines in a function.
# If lower than 0, disable the check. # If lower than 0, disable the check.
# Default: 60 lines: 200
lines: 60
# Checks the number of statements in a function. # Checks the number of statements in a function.
# Default: 40 statements: 80
statements: 40
dupl:
# Tokens count to trigger issue.
threshold: 200
nestif:
# Minimal complexity of if statements to report.
min-complexity: 10
nlreturn:
# Size of the block (including return statement that is still "OK")
# so no return split required.
block-size: 3
linters: linters:
@@ -98,6 +114,55 @@ linters:
- tparallel - tparallel
- unparam - unparam
- wastedassign - wastedassign
- ifshort
- varcheck
- deadcode
# Disable gofumpt as it has weird behavior regarding formatting multiple
# lines for a function which is in conflict with our contribution
# guidelines. See https://github.com/mvdan/gofumpt/issues/235.
- gofumpt
# Disable whitespace linter as it has conflict rules against our
# contribution guidelines. See https://github.com/bombsimon/wsl/issues/109.
#
# TODO(yy): bring it back when the above issue is fixed.
- wsl
# Allow using default empty values.
- exhaustruct
# Allow exiting case select faster by putting everything in default.
- exhaustive
# Allow tests to be put in the same package.
- testpackage
# Don't run the cognitive related linters.
- gocognit
- gocyclo
- maintidx
- cyclop
# Allow customized interfaces to be returned from functions.
- ireturn
# Disable too many blank identifiers check. We won't be able to run this
# unless a large refactor has been applied to old code.
- dogsled
# We don't wrap errors.
- wrapcheck
# Allow dynamic errors.
- goerr113
# We use ErrXXX instead.
- errname
# Disable nil check to allow returning multiple nil values.
- nilnil
issues: issues:
# Only show newly introduced problems. # Only show newly introduced problems.
@@ -110,6 +175,7 @@ issues:
linters: linters:
- gosec - gosec
- funlen - funlen
- path: test* - path: test*
linters: linters:
- gosec - gosec
@@ -146,7 +212,6 @@ issues:
- path: lntest/itest/.* - path: lntest/itest/.*
linters: linters:
- unused - unused
- deadcode
- unparam - unparam
- govet - govet
# itest case can be very long so we disable long function check. # itest case can be very long so we disable long function check.