Skip to content

Commit af9c17c

Browse files
committed
chore: Add lint task to Taskfile.yml
1 parent 454df64 commit af9c17c

File tree

2 files changed

+159
-0
lines changed

2 files changed

+159
-0
lines changed

.golang-ci.yml

+154
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
linters-settings:
2+
dupl:
3+
threshold: 100
4+
funlen:
5+
lines: -1 # the number of lines (code + empty lines) is not a right metric and leads to code without empty line or one-liner.
6+
statements: 50
7+
goconst:
8+
min-len: 2
9+
min-occurrences: 3
10+
gocritic:
11+
enabled-tags:
12+
- diagnostic
13+
- experimental
14+
- opinionated
15+
- performance
16+
- style
17+
disabled-checks:
18+
- dupImport # https://github.com/go-critic/go-critic/issues/845
19+
- ifElseChain
20+
- octalLiteral
21+
- whyNoLint
22+
gocyclo:
23+
min-complexity: 15
24+
gofmt:
25+
rewrite-rules:
26+
- pattern: 'interface{}'
27+
replacement: 'any'
28+
goimports:
29+
local-prefixes: github.com/golangci/golangci-lint
30+
gomnd:
31+
# don't include the "operation" and "assign"
32+
checks:
33+
- argument
34+
- case
35+
- condition
36+
- return
37+
ignored-numbers:
38+
- '0'
39+
- '1'
40+
- '2'
41+
- '3'
42+
ignored-functions:
43+
- strings.SplitN
44+
45+
# govet:
46+
# settings:
47+
# printf:
48+
# funcs:
49+
# - (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
50+
# - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
51+
# - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
52+
# - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
53+
errorlint:
54+
asserts: false
55+
lll:
56+
line-length: 140
57+
misspell:
58+
locale: US
59+
nolintlint:
60+
allow-unused: false # report any unused nolint directives
61+
require-explanation: false # don't require an explanation for nolint directives
62+
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
63+
revive:
64+
rules:
65+
- name: unexported-return
66+
disabled: true
67+
- name: unused-parameter
68+
69+
linters:
70+
disable-all: true
71+
enable:
72+
- bodyclose
73+
# - depguard
74+
- dogsled
75+
- dupl
76+
- errcheck
77+
- errorlint
78+
- exportloopref
79+
- funlen
80+
- gocheckcompilerdirectives
81+
- gochecknoinits
82+
- goconst
83+
- gocritic
84+
- gocyclo
85+
- gofmt
86+
- goimports
87+
- gomnd
88+
- goprintffuncname
89+
- gosec
90+
- gosimple
91+
- govet
92+
- ineffassign
93+
- lll
94+
- misspell
95+
- nakedret
96+
- noctx
97+
- nolintlint
98+
- revive
99+
- staticcheck
100+
- stylecheck
101+
- typecheck
102+
- unconvert
103+
- unparam
104+
- unused
105+
- whitespace
106+
107+
# don't enable:
108+
# - asciicheck
109+
# - scopelint
110+
# - gochecknoglobals
111+
# - gocognit
112+
# - godot
113+
# - godox
114+
# - goerr113
115+
# - interfacer
116+
# - maligned
117+
# - nestif
118+
# - prealloc
119+
# - testpackage
120+
# - wsl
121+
122+
issues:
123+
# Excluding configuration per-path, per-linter, per-text and per-source
124+
exclude-rules:
125+
- path: _test\.go
126+
linters:
127+
- gomnd
128+
129+
- path: pkg/golinters/errcheck.go
130+
text: "SA1019: errCfg.Exclude is deprecated: use ExcludeFunctions instead"
131+
- path: pkg/commands/run.go
132+
text: "SA1019: lsc.Errcheck.Exclude is deprecated: use ExcludeFunctions instead"
133+
- path: pkg/commands/run.go
134+
text: "SA1019: e.cfg.Run.Deadline is deprecated: Deadline exists for historical compatibility and should not be used."
135+
136+
- path: pkg/golinters/gofumpt.go
137+
text: "SA1019: settings.LangVersion is deprecated: use the global `run.go` instead."
138+
- path: pkg/golinters/staticcheck_common.go
139+
text: "SA1019: settings.GoVersion is deprecated: use the global `run.go` instead."
140+
- path: pkg/lint/lintersdb/manager.go
141+
text: "SA1019: (.+).(GoVersion|LangVersion) is deprecated: use the global `run.go` instead."
142+
- path: pkg/golinters/unused.go
143+
text: "rangeValCopy: each iteration copies 160 bytes \\(consider pointers or indexing\\)"
144+
- path: test/(fix|linters)_test.go
145+
text: "string `gocritic.go` has 3 occurrences, make it a constant"
146+
147+
# Due to a change inside go-critic v0.10.0, some reports have been removed,
148+
# but as we run analysis with the previous version of golangci-lint this leads to a paradoxical situation.
149+
# This exclusion will be removed when the next version of golangci-lint (v1.56.0) will be released.
150+
- path: pkg/golinters/nolintlint/nolintlint.go
151+
text: "hugeParam: (i|b) is heavy \\(\\d+ bytes\\); consider passing it by pointer"
152+
153+
run:
154+
timeout: 5m

Taskfile.yml

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ tasks:
99
cmds:
1010
- task -a
1111

12+
lint:
13+
desc: "Run linter"
14+
cmds:
15+
- golangci-lint run -c .golang-ci.yml
16+
1217
binary:
1318
desc: "Build binary"
1419
cmds:

0 commit comments

Comments
 (0)