docs: improve linters settings section (#2499)
This commit is contained in:
parent
a471733b81
commit
83ff65a7e2
@ -128,6 +128,26 @@ linters-settings:
|
|||||||
# default: true (disabled)
|
# default: true (disabled)
|
||||||
disable-dec-num-check: false
|
disable-dec-num-check: false
|
||||||
|
|
||||||
|
depguard:
|
||||||
|
list-type: denylist
|
||||||
|
include-go-root: false
|
||||||
|
packages:
|
||||||
|
- github.com/sirupsen/logrus
|
||||||
|
packages-with-error-message:
|
||||||
|
# specify an error message to output when a denied package is used
|
||||||
|
- github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
|
||||||
|
# create additional guards that follow the same configuration pattern
|
||||||
|
# results from all guards are aggregated together
|
||||||
|
additional-guards:
|
||||||
|
- list-type: denylist
|
||||||
|
include-go-root: false
|
||||||
|
packages:
|
||||||
|
- github.com/stretchr/testify
|
||||||
|
# specify rules by which the linter ignores certain files for consideration
|
||||||
|
ignore-file-rules:
|
||||||
|
- "**/*_test.go"
|
||||||
|
- "**/mock/**/*.go"
|
||||||
|
|
||||||
dogsled:
|
dogsled:
|
||||||
# checks assignments with too many blank identifiers; default is 2
|
# checks assignments with too many blank identifiers; default is 2
|
||||||
max-blank-identifiers: 2
|
max-blank-identifiers: 2
|
||||||
@ -163,9 +183,9 @@ linters-settings:
|
|||||||
- io.Copy(os.Stdout)
|
- io.Copy(os.Stdout)
|
||||||
|
|
||||||
errchkjson:
|
errchkjson:
|
||||||
# with check-error-free-encoding set to true, errchkjson does warn about errors
|
# With check-error-free-encoding set to true, errchkjson does warn about errors
|
||||||
# from json encoding functions that are safe to be ignored,
|
# from json encoding functions that are safe to be ignored,
|
||||||
# because they are not possible to happen (default false)
|
# because they are not possible to happen.
|
||||||
#
|
#
|
||||||
# if check-error-free-encoding is set to true and errcheck linter is enabled,
|
# if check-error-free-encoding is set to true and errcheck linter is enabled,
|
||||||
# it is recommended to add the following exceptions to prevent from false positives:
|
# it is recommended to add the following exceptions to prevent from false positives:
|
||||||
@ -175,9 +195,12 @@ linters-settings:
|
|||||||
# exclude-functions:
|
# exclude-functions:
|
||||||
# - encoding/json.Marshal
|
# - encoding/json.Marshal
|
||||||
# - encoding/json.MarshalIndent
|
# - encoding/json.MarshalIndent
|
||||||
# - (*encoding/json.Encoder).Encode
|
#
|
||||||
check-error-free-encoding: false
|
# default: false
|
||||||
# if report-no-exported is true, encoding a struct without exported fields is reported as issue (default false)
|
check-error-free-encoding: true
|
||||||
|
|
||||||
|
# Issue on struct encoding that doesn't have exported fields.
|
||||||
|
# default: false
|
||||||
report-no-exported: false
|
report-no-exported: false
|
||||||
|
|
||||||
errorlint:
|
errorlint:
|
||||||
@ -210,11 +233,12 @@ linters-settings:
|
|||||||
- 'example.com/package.ExampleStruct'
|
- 'example.com/package.ExampleStruct'
|
||||||
|
|
||||||
forbidigo:
|
forbidigo:
|
||||||
# Forbid the following identifiers (identifiers are written using regexp):
|
# Forbid the following identifiers (list of regexp):
|
||||||
forbid:
|
forbid:
|
||||||
- ^print.*$
|
- ^print.*$
|
||||||
- 'fmt\.Print.*'
|
- 'fmt\.Print.*'
|
||||||
# Exclude godoc examples from forbidigo checks. Default is true.
|
# Exclude godoc examples from forbidigo checks.
|
||||||
|
# default: true
|
||||||
exclude_godoc_examples: false
|
exclude_godoc_examples: false
|
||||||
|
|
||||||
funlen:
|
funlen:
|
||||||
@ -228,25 +252,34 @@ linters-settings:
|
|||||||
local-prefixes: github.com/org/project
|
local-prefixes: github.com/org/project
|
||||||
|
|
||||||
gocognit:
|
gocognit:
|
||||||
# minimal code complexity to report, 30 by default (but we recommend 10-20)
|
# Minimal code complexity to report
|
||||||
|
# default: 30, (but we recommended 10-20)
|
||||||
min-complexity: 10
|
min-complexity: 10
|
||||||
|
|
||||||
goconst:
|
goconst:
|
||||||
# minimal length of string constant, 3 by default
|
# Minimal length of string constant
|
||||||
|
# default: 3
|
||||||
min-len: 3
|
min-len: 3
|
||||||
# minimum occurrences of constant string count to trigger issue, 3 by default
|
# Minimum occurrences of constant string count to trigger issue
|
||||||
|
# default: 3
|
||||||
min-occurrences: 3
|
min-occurrences: 3
|
||||||
# ignore test files, false by default
|
# Ignore test files
|
||||||
|
# default: false
|
||||||
ignore-tests: false
|
ignore-tests: false
|
||||||
# look for existing constants matching the values, true by default
|
# Look for existing constants matching the values
|
||||||
|
# default: true
|
||||||
match-constant: true
|
match-constant: true
|
||||||
# search also for duplicated numbers, false by default
|
# Search also for duplicated numbers.
|
||||||
|
# default: false
|
||||||
numbers: false
|
numbers: false
|
||||||
# minimum value, only works with goconst.numbers, 3 by default
|
# Minimum value, only works with goconst.numbers
|
||||||
|
# default: 3
|
||||||
min: 3
|
min: 3
|
||||||
# maximum value, only works with goconst.numbers, 3 by default
|
# Maximum value, only works with goconst.numbers
|
||||||
|
# default: 3
|
||||||
max: 3
|
max: 3
|
||||||
# ignore when constant is not used as function argument, true by default
|
# Ignore when constant is not used as function argument
|
||||||
|
# default: true
|
||||||
ignore-calls: true
|
ignore-calls: true
|
||||||
|
|
||||||
gocritic:
|
gocritic:
|
||||||
@ -468,6 +501,12 @@ linters-settings:
|
|||||||
# reason: "testing if blocked version constraint works." # Reason why the version constraint exists. (Optional)
|
# reason: "testing if blocked version constraint works." # Reason why the version constraint exists. (Optional)
|
||||||
local_replace_directives: false # Set to true to raise lint issues for packages that are loaded from a local path via replace directive
|
local_replace_directives: false # Set to true to raise lint issues for packages that are loaded from a local path via replace directive
|
||||||
|
|
||||||
|
gosimple:
|
||||||
|
# Select the Go version to target. The default is '1.13'.
|
||||||
|
go: "1.15"
|
||||||
|
# https://staticcheck.io/docs/options#checks
|
||||||
|
checks: [ "all" ]
|
||||||
|
|
||||||
gosec:
|
gosec:
|
||||||
# To select a subset of rules to run.
|
# To select a subset of rules to run.
|
||||||
# Available rules: https://github.com/securego/gosec#available-rules
|
# Available rules: https://github.com/securego/gosec#available-rules
|
||||||
@ -498,12 +537,6 @@ linters-settings:
|
|||||||
per_char_threshold: "3.0"
|
per_char_threshold: "3.0"
|
||||||
truncate: "32"
|
truncate: "32"
|
||||||
|
|
||||||
gosimple:
|
|
||||||
# Select the Go version to target. The default is '1.13'.
|
|
||||||
go: "1.15"
|
|
||||||
# https://staticcheck.io/docs/options#checks
|
|
||||||
checks: [ "all" ]
|
|
||||||
|
|
||||||
govet:
|
govet:
|
||||||
# report about shadowed variables
|
# report about shadowed variables
|
||||||
check-shadowing: true
|
check-shadowing: true
|
||||||
@ -526,26 +559,6 @@ linters-settings:
|
|||||||
- shadow
|
- shadow
|
||||||
disable-all: false
|
disable-all: false
|
||||||
|
|
||||||
depguard:
|
|
||||||
list-type: denylist
|
|
||||||
include-go-root: false
|
|
||||||
packages:
|
|
||||||
- github.com/sirupsen/logrus
|
|
||||||
packages-with-error-message:
|
|
||||||
# specify an error message to output when a denied package is used
|
|
||||||
- github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
|
|
||||||
# create additional guards that follow the same configuration pattern
|
|
||||||
# results from all guards are aggregated together
|
|
||||||
additional-guards:
|
|
||||||
- list-type: denylist
|
|
||||||
include-go-root: false
|
|
||||||
packages:
|
|
||||||
- github.com/stretchr/testify
|
|
||||||
# specify rules by which the linter ignores certain files for consideration
|
|
||||||
ignore-file-rules:
|
|
||||||
- "**/*_test.go"
|
|
||||||
- "**/mock/**/*.go"
|
|
||||||
|
|
||||||
ifshort:
|
ifshort:
|
||||||
# Maximum length of variable declaration measured in number of lines, after which linter won't suggest using short syntax.
|
# Maximum length of variable declaration measured in number of lines, after which linter won't suggest using short syntax.
|
||||||
# Has higher priority than max-decl-chars.
|
# Has higher priority than max-decl-chars.
|
||||||
@ -591,7 +604,6 @@ linters-settings:
|
|||||||
# You can specify idiomatic endings for interface
|
# You can specify idiomatic endings for interface
|
||||||
- (or|er)$
|
- (or|er)$
|
||||||
|
|
||||||
# Reject patterns
|
|
||||||
reject:
|
reject:
|
||||||
- github.com\/user\/package\/v4\.Type
|
- github.com\/user\/package\/v4\.Type
|
||||||
|
|
||||||
@ -668,30 +680,26 @@ linters-settings:
|
|||||||
range-loops: true # Report preallocation suggestions on range loops, true by default
|
range-loops: true # Report preallocation suggestions on range loops, true by default
|
||||||
for-loops: false # Report preallocation suggestions on for loops, false by default
|
for-loops: false # Report preallocation suggestions on for loops, false by default
|
||||||
|
|
||||||
promlinter:
|
|
||||||
# Promlinter cannot infer all metrics name in static analysis.
|
|
||||||
# Enable strict mode will also include the errors caused by failing to parse the args.
|
|
||||||
strict: false
|
|
||||||
# Please refer to https://github.com/yeya24/promlinter#usage for detailed usage.
|
|
||||||
disabled-linters:
|
|
||||||
# - "Help"
|
|
||||||
# - "MetricUnits"
|
|
||||||
# - "Counter"
|
|
||||||
# - "HistogramSummaryReserved"
|
|
||||||
# - "MetricTypeInName"
|
|
||||||
# - "ReservedChars"
|
|
||||||
# - "CamelCase"
|
|
||||||
# - "lintUnitAbbreviations"
|
|
||||||
|
|
||||||
predeclared:
|
predeclared:
|
||||||
# comma-separated list of predeclared identifiers to not report on
|
# comma-separated list of predeclared identifiers to not report on
|
||||||
ignore: ""
|
ignore: ""
|
||||||
# include method names and field names (i.e., qualified names) in checks
|
# include method names and field names (i.e., qualified names) in checks
|
||||||
q: false
|
q: false
|
||||||
|
|
||||||
rowserrcheck:
|
promlinter:
|
||||||
packages:
|
# Promlinter cannot infer all metrics name in static analysis.
|
||||||
- github.com/jmoiron/sqlx
|
# Enable strict mode will also include the errors caused by failing to parse the args.
|
||||||
|
strict: false
|
||||||
|
# Please refer to https://github.com/yeya24/promlinter#usage for detailed usage.
|
||||||
|
disabled-linters:
|
||||||
|
- "Help"
|
||||||
|
- "MetricUnits"
|
||||||
|
- "Counter"
|
||||||
|
- "HistogramSummaryReserved"
|
||||||
|
- "MetricTypeInName"
|
||||||
|
- "ReservedChars"
|
||||||
|
- "CamelCase"
|
||||||
|
- "UnitAbbreviations"
|
||||||
|
|
||||||
revive:
|
revive:
|
||||||
# see https://github.com/mgechev/revive#available-rules for details.
|
# see https://github.com/mgechev/revive#available-rules for details.
|
||||||
@ -996,6 +1004,10 @@ linters-settings:
|
|||||||
severity: warning
|
severity: warning
|
||||||
disable: false
|
disable: false
|
||||||
|
|
||||||
|
rowserrcheck:
|
||||||
|
packages:
|
||||||
|
- github.com/jmoiron/sqlx
|
||||||
|
|
||||||
staticcheck:
|
staticcheck:
|
||||||
# Select the Go version to target. The default is '1.13'.
|
# Select the Go version to target. The default is '1.13'.
|
||||||
go: "1.15"
|
go: "1.15"
|
||||||
@ -1030,6 +1042,11 @@ linters-settings:
|
|||||||
avro: snake
|
avro: snake
|
||||||
mapstructure: kebab
|
mapstructure: kebab
|
||||||
|
|
||||||
|
tenv:
|
||||||
|
# The option `all` will run against whole test files (`_test.go`) regardless of method/function signatures.
|
||||||
|
# By default, only methods that take `*testing.T`, `*testing.B`, and `testing.TB` as arguments are checked.
|
||||||
|
all: false
|
||||||
|
|
||||||
testpackage:
|
testpackage:
|
||||||
# regexp pattern to skip files
|
# regexp pattern to skip files
|
||||||
skip-regexp: (export|internal)_test\.go
|
skip-regexp: (export|internal)_test\.go
|
||||||
@ -1050,10 +1067,6 @@ linters-settings:
|
|||||||
name: true
|
name: true
|
||||||
begin: true
|
begin: true
|
||||||
|
|
||||||
tenv:
|
|
||||||
# The option `all` will run against whole test files (`_test.go`) regardless of method/function signatures.
|
|
||||||
# By default, only methods that take `*testing.T`, `*testing.B`, and `testing.TB` as arguments are checked.
|
|
||||||
all: false
|
|
||||||
|
|
||||||
unparam:
|
unparam:
|
||||||
# Inspect exported functions, default is false. Set to true if no external program/library imports your code.
|
# Inspect exported functions, default is false. Set to true if no external program/library imports your code.
|
||||||
@ -1062,9 +1075,9 @@ linters-settings:
|
|||||||
# with golangci-lint call it on a directory with the changed file.
|
# with golangci-lint call it on a directory with the changed file.
|
||||||
check-exported: false
|
check-exported: false
|
||||||
|
|
||||||
unused:
|
varcheck:
|
||||||
# Select the Go version to target. The default is '1.13'.
|
# Check usage of exported fields and variables.
|
||||||
go: "1.15"
|
exported-fields: true
|
||||||
|
|
||||||
varnamelen:
|
varnamelen:
|
||||||
# The longest distance, in source lines, that is being considered a "small scope." (defaults to 5)
|
# The longest distance, in source lines, that is being considered a "small scope." (defaults to 5)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user