Commit 0eb23eda
0eb23eda539cMerged
Svyatoslav Dumchenko <[email protected]> ยท 5 years ago ยท 1 file ยท +1 added
Description
add golangci-lint configuration
Details
- Commit
- 0eb23eda539c
- Parent
- 63d88ca3bdad
.golangci.ymladdedView file
1+
# options for analysis running2+
run:3+
timeout: 5m4+
5+
linters:6+
enable-all: true7+
disable:8+
- interfacer9+
- wrapcheck10+
- maligned11+
- scopelint12+
- golint13+
- nlreturn14+
- gochecknoglobals15+
- tagliatelle16+
- deadcode17+
- ifshort18+
- gomnd19+
- goerr11320+
- godot21+
- wsl22+
23+
# all available settings of specific linters24+
linters-settings:25+
26+
cyclop:27+
# the maximal code complexity to report28+
max-complexity: 1029+
# the maximal average package complexity. If it's higher than 0.0 (float) the check is enabled (default 0.0)30+
package-average: 0.031+
# should ignore tests (default false)32+
skip-tests: false33+
34+
dogsled:35+
# checks assignments with too many blank identifiers; default is 236+
max-blank-identifiers: 237+
38+
dupl:39+
# tokens count to trigger issue, 150 by default40+
threshold: 10041+
42+
errcheck:43+
# report about not checking of errors in type assertions: `a := b.(MyStruct)`;44+
# default is false: such cases aren't reported by default.45+
check-type-assertions: false46+
47+
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;48+
# default is false: such cases aren't reported by default.49+
check-blank: false50+
51+
# [deprecated] comma-separated list of pairs of the form pkg:regex52+
# the regex is used to ignore names within pkg. (default "fmt:.*").53+
# see https://github.com/kisielk/errcheck#the-deprecated-method for details54+
ignore: fmt:.*,io/ioutil:^Read.*55+
56+
errorlint:57+
# Check whether fmt.Errorf uses the %w verb for formatting errors. See the readme for caveats58+
errorf: true59+
# Check for plain type assertions and type switches60+
asserts: true61+
# Check for plain error comparisons62+
comparison: true63+
64+
exhaustive:65+
# check switch statements in generated files also66+
check-generated: false67+
# indicates that switch statements are to be considered exhaustive if a68+
# 'default' case is present, even if all enum members aren't listed in the69+
# switch70+
default-signifies-exhaustive: false71+
72+
exhaustivestruct:73+
# Struct Patterns is list of expressions to match struct packages and names74+
# The struct packages have the form example.com/package.ExampleStruct75+
# The matching patterns can use matching syntax from https://pkg.go.dev/path#Match76+
# If this list is empty, all structs are tested.77+
struct-patterns:78+
- '*.Test'79+
- 'example.com/package.ExampleStruct'80+
81+
forbidigo:82+
# Forbid the following identifiers (identifiers are written using regexp):83+
forbid:84+
- ^print.*$85+
- 'fmt\.Print.*'86+
# Exclude godoc examples from forbidigo checks. Default is true.87+
exclude_godoc_examples: false88+
89+
funlen:90+
lines: 6091+
statements: 4092+
93+
gci:94+
# put imports beginning with prefix after 3rd-party packages;95+
# only support one prefix96+
# if not set, use goimports.local-prefixes97+
local-prefixes: github.com/org/project98+
99+
gocognit:100+
# minimal code complexity to report, 30 by default (but we recommend 10-20)101+
min-complexity: 10102+
103+
nestif:104+
# minimal complexity of if statements to report, 5 by default105+
min-complexity: 4106+
107+
goconst:108+
# minimal length of string constant, 3 by default109+
min-len: 3110+
# minimal occurrences count to trigger, 3 by default111+
min-occurrences: 3112+
113+
gocritic:114+
enabled-tags:115+
- diagnostic116+
- experimental117+
- opinionated118+
- performance119+
- style120+
121+
disabled-checks:122+
- commentedOutCode123+
- typeSwitchVar124+
- whyNoLint125+
126+
settings:127+
captLocal: # must be valid enabled check name128+
# whether to restrict checker to params only (default true)129+
paramsOnly: true130+
elseif:131+
# whether to skip balanced if-else pairs (default true)132+
skipBalanced: true133+
hugeParam:134+
# size in bytes that makes the warning trigger (default 80)135+
sizeThreshold: 80136+
nestingReduce:137+
# min number of statements inside a branch to trigger a warning (default 5)138+
bodyWidth: 5139+
rangeExprCopy:140+
# size in bytes that makes the warning trigger (default 512)141+
sizeThreshold: 512142+
# whether to check test functions (default true)143+
skipTestFuncs: true144+
rangeValCopy:145+
# size in bytes that makes the warning trigger (default 128)146+
sizeThreshold: 32147+
# whether to check test functions (default true)148+
skipTestFuncs: true149+
ruleguard:150+
# path to a gorules file for the ruleguard checker151+
rules: ''152+
truncateCmp:153+
# whether to skip int/uint/uintptr types (default true)154+
skipArchDependent: true155+
underef:156+
# whether to skip (*x).method() calls where x is a pointer receiver (default true)157+
skipRecvDeref: true158+
unnamedResult:159+
# whether to check exported functions160+
checkExported: true161+
162+
gocyclo:163+
# minimal code complexity to report, 30 by default (but we recommend 10-20)164+
min-complexity: 10165+
166+
gofmt:167+
# simplify code: gofmt with `-s` option, true by default168+
simplify: true169+
170+
gofumpt:171+
# Choose whether or not to use the extra rules that are disabled172+
# by default173+
extra-rules: false174+
175+
goimports:176+
177+
gomoddirectives:178+
# Allow local `replace` directives. Default is false.179+
replace-local: false180+
# List of allowed `replace` directives. Default is empty.181+
replace-allow-list:182+
- launchpad.net/gocheck183+
# Allow to not explain why the version has been retracted in the `retract` directives. Default is false.184+
retract-allow-no-explanation: false185+
# Forbid the use of the `exclude` directives. Default is false.186+
exclude-forbidden: false187+
188+
gosec:189+
# To select a subset of rules to run.190+
# Available rules: https://github.com/securego/gosec#available-rules191+
includes:192+
- G401193+
- G306194+
- G101195+
# To specify a set of rules to explicitly exclude.196+
# Available rules: https://github.com/securego/gosec#available-rules197+
excludes:198+
- G204199+
# To specify the configuration of rules.200+
# The configuration of rules is not fully documented by gosec:201+
# https://github.com/securego/gosec#configuration202+
# https://github.com/securego/gosec/blob/569328eade2ccbad4ce2d0f21ee158ab5356a5cf/rules/rulelist.go#L60-L102203+
config:204+
G306: "0600"205+
G101:206+
pattern: "(?i)example"207+
ignore_entropy: false208+
entropy_threshold: "80.0"209+
per_char_threshold: "3.0"210+
truncate: "32"211+
212+
gosimple:213+
# Select the Go version to target. The default is '1.13'.214+
go: "1.16"215+
# https://staticcheck.io/docs/options#checks216+
checks: [ "all" ]217+
218+
govet:219+
# report about shadowed variables220+
check-shadowing: false221+
222+
# settings per analyzer223+
settings:224+
printf: # analyzer name, run `go tool vet help` to see all analyzers225+
funcs: # run `go tool vet help printf` to see available settings for `printf` analyzer226+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof227+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf228+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf229+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf230+
231+
enable-all: true232+
disable:233+
- shadow234+
235+
lll:236+
# max line length, lines longer will be reported. Default is 120.237+
# '\t' is counted as 1 character by default, and can be changed with the tab-width option238+
line-length: 120239+
# tab width in spaces. Default to 1.240+
tab-width: 1241+
242+
makezero:243+
# Allow only slices initialized with a length of zero. Default is false.244+
always: false245+
246+
misspell:247+
# Correct spellings using locale preferences for US or UK.248+
# Default is to use a neutral variety of English.249+
# Setting locale to US will correct the British spelling of 'colour' to 'color'.250+
locale: US251+
252+
nakedret:253+
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30254+
max-func-lines: 30255+
256+
prealloc:257+
# XXX: we don't recommend using this linter before doing performance profiling.258+
# For most programs usage of prealloc will be a premature optimization.259+
260+
# Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.261+
# True by default.262+
simple: true263+
range-loops: true # Report preallocation suggestions on range loops, true by default264+
for-loops: false # Report preallocation suggestions on for loops, false by default265+
266+
promlinter:267+
# Promlinter cannot infer all metrics name in static analysis.268+
# Enable strict mode will also include the errors caused by failing to parse the args.269+
strict: false270+
# Please refer to https://github.com/yeya24/promlinter#usage for detailed usage.271+
disabled-linters:272+
# - "Help"273+
# - "MetricUnits"274+
# - "Counter"275+
# - "HistogramSummaryReserved"276+
# - "MetricTypeInName"277+
# - "ReservedChars"278+
# - "CamelCase"279+
# - "lintUnitAbbreviations"280+
281+
predeclared:282+
# comma-separated list of predeclared identifiers to not report on283+
ignore: ""284+
# include method names and field names (i.e., qualified names) in checks285+
q: false286+
287+
nolintlint:288+
# Enable to ensure that nolint directives are all used. Default is true.289+
allow-unused: false290+
# Disable to ensure that nolint directives don't have a leading space. Default is true.291+
allow-leading-space: true292+
# Exclude following linters from requiring an explanation. Default is [].293+
allow-no-explanation: []294+
# Enable to require an explanation of nonzero length after each nolint directive. Default is false.295+
require-explanation: false296+
# Enable to require nolint directives to mention the specific linter being suppressed. Default is false.297+
require-specific: true298+
299+
staticcheck:300+
# Select the Go version to target. The default is '1.13'.301+
go: "1.16"302+
# https://staticcheck.io/docs/options#checks303+
checks: [ "all" ]304+
305+
stylecheck:306+
# Select the Go version to target. The default is '1.13'.307+
go: "1.16"308+
# https://staticcheck.io/docs/options#checks309+
checks: [ "all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022" ]310+
# https://staticcheck.io/docs/options#dot_import_whitelist311+
dot-import-whitelist:312+
- fmt313+
# https://staticcheck.io/docs/options#initialisms314+
initialisms: [ "ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS" ]315+
# https://staticcheck.io/docs/options#http_status_code_whitelist316+
http-status-code-whitelist: [ "200", "400", "404", "500" ]317+
318+
testpackage:319+
# regexp pattern to skip files320+
skip-regexp: (export|internal)_test\.go321+
322+
thelper:323+
# The following configurations enable all checks. It can be omitted because all checks are enabled by default.324+
# You can enable only required checks deleting unnecessary checks.325+
test:326+
first: true327+
name: true328+
begin: true329+
benchmark:330+
first: true331+
name: true332+
begin: true333+
tb:334+
first: true335+
name: true336+
begin: true337+
338+
unparam:339+
# Inspect exported functions, default is false. Set to true if no external program/library imports your code.340+
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:341+
# if it's called for subdir of a project it can't find external interfaces. All text editor integrations342+
# with golangci-lint call it on a directory with the changed file.343+
check-exported: false344+
345+
unused:346+
go: "1.16"347+
348+
whitespace:349+
multi-if: false # Enforces newlines (or comments) after every multi-line if statement350+
multi-func: false # Enforces newlines (or comments) after every multi-line function signature351+
352+
severity:353+
# Default value is empty string.354+
# Set the default severity for issues. If severity rules are defined and the issues355+
# do not match or no severity is provided to the rule this will be the default356+
# severity applied. Severities should match the supported severity names of the357+
# selected out format.358+
# - Code climate: https://docs.codeclimate.com/docs/issues#issue-severity359+
# - Checkstyle: https://checkstyle.sourceforge.io/property_types.html#severity360+
# - Github: https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-error-message361+
default-severity: error362+
363+
# The default value is false.364+
# If set to true severity-rules regular expressions become case sensitive.365+
case-sensitive: false366+
367+
# Default value is empty list.368+
# When a list of severity rules are provided, severity information will be added to lint369+
# issues. Severity rules have the same filtering capability as exclude rules except you370+
# are allowed to specify one matcher per severity rule.371+
# Only affects out formats that support setting severity information.372+
rules:373+
- linters:374+
- dupl375+
- revive376+
- funlen377+
- lll378+
- godox379+
- gocognit380+
- nestif381+
- gocyclo382+
- cyclop383+
severity: warning