Skip to content

Commit 7bcac43

Browse files
authored
feat: remove v1 exclusion configuration (#5451)
1 parent fab6467 commit 7bcac43

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+468
-1401
lines changed

.github/workflows/pr.yml

+7-5
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ jobs:
4141
# - 1.18beta1 -> 1.18.0-beta.1
4242
# - 1.18rc1 -> 1.18.0-rc.1
4343
go-version: ${{ env.GO_VERSION }}
44-
- name: lint
45-
uses: golangci/golangci-lint-action@v6.5.0
46-
with:
47-
version: latest
44+
# TODO(ldez): must add uncommented when golangci-lint-action@v7.0.0 (with golangci-lint v2 support) will be created.
45+
# - name: lint
46+
# uses: golangci/golangci-lint-action@v6.5.0
47+
# with:
48+
# version: latest
4849

4950
tests-on-windows:
5051
needs: golangci-lint # run after golangci-lint action to not produce duplicated errors
@@ -147,7 +148,8 @@ jobs:
147148

148149
- run: ./golangci-lint config
149150
- run: ./golangci-lint config path
150-
- run: ./golangci-lint config verify --schema jsonschema/golangci.jsonschema.json
151+
# TODO(ldez) after v2: golangci.next.jsonschema.json -> golangci.jsonschema.json
152+
- run: ./golangci-lint config verify --schema jsonschema/golangci.next.jsonschema.json
151153

152154
- run: ./golangci-lint help
153155
- run: ./golangci-lint help linters

.golangci.next.reference.yml

+69-110
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,75 @@ linters:
261261
# Default: false
262262
fast: true
263263

264+
# Defines a set of rules to ignore issues.
265+
# It does not skip the analysis, and so does not ignore "typecheck" errors.
266+
exclusions:
267+
# Mode of the generated files analysis.
268+
#
269+
# - `strict`: sources are excluded by strictly following the Go generated file convention.
270+
# Source files that have lines matching only the following regular expression will be excluded: `^// Code generated .* DO NOT EDIT\.$`
271+
# This line must appear before the first non-comment, non-blank text in the file.
272+
# https://go.dev/s/generatedcode
273+
# - `lax`: sources are excluded if they contain lines like `autogenerated file`, `code generated`, `do not edit`, etc.
274+
# - `disable`: disable the generated files exclusion.
275+
#
276+
# Default: lax
277+
generated: strict
278+
# Log a warning if an exclusion rule is unused.
279+
# Default: false
280+
warn-unused: true
281+
# Predefined exclusion rules.
282+
# Default: []
283+
presets:
284+
- comments
285+
- std-error-handling
286+
- common-false-positives
287+
- legacy
288+
289+
# Excluding configuration per-path, per-linter, per-text and per-source.
290+
rules:
291+
# Exclude some linters from running on tests files.
292+
- path: _test\.go
293+
linters:
294+
- gocyclo
295+
- errcheck
296+
- dupl
297+
- gosec
298+
299+
# Run some linter only for test files by excluding its issues for everything else.
300+
- path-except: _test\.go
301+
linters:
302+
- forbidigo
303+
304+
# Exclude known linters from partially hard-vendored code,
305+
# which is impossible to exclude via `nolint` comments.
306+
# `/` will be replaced by the current OS file path separator to properly work on Windows.
307+
- path: internal/hmac/
308+
text: "weak cryptographic primitive"
309+
linters:
310+
- gosec
311+
312+
# Exclude some `staticcheck` messages.
313+
- linters:
314+
- staticcheck
315+
text: "SA9003:"
316+
317+
# Exclude `lll` issues for long lines with `go:generate`.
318+
- linters:
319+
- lll
320+
source: "^//go:generate "
321+
322+
# Which file paths to exclude: they will be analyzed, but issues from them won't be reported.
323+
# "/" will be replaced by the current OS file path separator to properly work on Windows.
324+
# Default: []
325+
paths:
326+
- ".*\\.my\\.go$"
327+
- lib/bad.go
328+
# Which file paths to not exclude.
329+
# Default: []
330+
paths-except:
331+
- ".*\\.my\\.go$"
332+
- lib/bad.go
264333

265334
formatters:
266335
# Enable specific formatter.
@@ -3940,116 +4009,6 @@ linters-settings:
39404009

39414010

39424011
issues:
3943-
# List of regexps of issue texts to exclude.
3944-
#
3945-
# But independently of this option we use default exclude patterns,
3946-
# it can be disabled by `exclude-use-default: false`.
3947-
# To list all excluded by default patterns execute `golangci-lint run --help`
3948-
#
3949-
# Default: https://golangci-lint.run/usage/false-positives/#default-exclusions
3950-
exclude:
3951-
- abcdef
3952-
3953-
# Excluding configuration per-path, per-linter, per-text and per-source
3954-
exclude-rules:
3955-
# Exclude some linters from running on tests files.
3956-
- path: _test\.go
3957-
linters:
3958-
- gocyclo
3959-
- errcheck
3960-
- dupl
3961-
- gosec
3962-
3963-
# Run some linter only for test files by excluding its issues for everything else.
3964-
- path-except: _test\.go
3965-
linters:
3966-
- forbidigo
3967-
3968-
# Exclude known linters from partially hard-vendored code,
3969-
# which is impossible to exclude via `nolint` comments.
3970-
# `/` will be replaced by current OS file path separator to properly work on Windows.
3971-
- path: internal/hmac/
3972-
text: "weak cryptographic primitive"
3973-
linters:
3974-
- gosec
3975-
3976-
# Exclude some `staticcheck` messages.
3977-
- linters:
3978-
- staticcheck
3979-
text: "SA9003:"
3980-
3981-
# Exclude `lll` issues for long lines with `go:generate`.
3982-
- linters:
3983-
- lll
3984-
source: "^//go:generate "
3985-
3986-
# Independently of option `exclude` we use default exclude patterns,
3987-
# it can be disabled by this option.
3988-
# To list all excluded by default patterns execute `golangci-lint run --help`.
3989-
# Default: true
3990-
exclude-use-default: false
3991-
3992-
# If set to true, `exclude` and `exclude-rules` regular expressions become case-sensitive.
3993-
# Default: false
3994-
exclude-case-sensitive: false
3995-
3996-
# Which dirs to exclude: issues from them won't be reported.
3997-
# Can use regexp here: `generated.*`, regexp is applied on full path,
3998-
# including the path prefix if one is set.
3999-
# Default dirs are skipped independently of this option's value (see exclude-dirs-use-default).
4000-
# "/" will be replaced by current OS file path separator to properly work on Windows.
4001-
# Default: []
4002-
exclude-dirs:
4003-
- src/external_libs
4004-
- autogenerated_by_my_lib
4005-
4006-
# Enables exclude of directories:
4007-
# - vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
4008-
# Default: true
4009-
exclude-dirs-use-default: false
4010-
4011-
# Which files to exclude: they will be analyzed, but issues from them won't be reported.
4012-
# There is no need to include all autogenerated files,
4013-
# we confidently recognize autogenerated files.
4014-
# If it's not, please let us know.
4015-
# "/" will be replaced by current OS file path separator to properly work on Windows.
4016-
# Default: []
4017-
exclude-files:
4018-
- ".*\\.my\\.go$"
4019-
- lib/bad.go
4020-
4021-
# Mode of the generated files analysis.
4022-
#
4023-
# - `strict`: sources are excluded by following strictly the Go generated file convention.
4024-
# Source files that have lines matching only the following regular expression will be excluded: `^// Code generated .* DO NOT EDIT\.$`
4025-
# This line must appear before the first non-comment, non-blank text in the file.
4026-
# https://go.dev/s/generatedcode
4027-
# - `lax`: sources are excluded if they contain lines `autogenerated file`, `code generated`, `do not edit`, etc.
4028-
# - `disable`: disable the generated files exclusion.
4029-
#
4030-
# Default: lax
4031-
exclude-generated: strict
4032-
4033-
# The list of ids of default excludes to include or disable.
4034-
# https://golangci-lint.run/usage/false-positives/#default-exclusions
4035-
# Default: []
4036-
include:
4037-
- EXC0001
4038-
- EXC0002
4039-
- EXC0003
4040-
- EXC0004
4041-
- EXC0005
4042-
- EXC0006
4043-
- EXC0007
4044-
- EXC0008
4045-
- EXC0009
4046-
- EXC0010
4047-
- EXC0011
4048-
- EXC0012
4049-
- EXC0013
4050-
- EXC0014
4051-
- EXC0015
4052-
40534012
# Maximum issues count per one linter.
40544013
# Set to 0 to disable.
40554014
# Default: 50

.golangci.yml

+63-56
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#
1212
# See the file `.golangci.reference.yml` to have a list of all available configuration options.
1313

14+
version: "2"
15+
1416
linters:
1517
disable-all: true
1618
# This list of linters is not a recommendation (same thing for all this configuration file).
@@ -31,8 +33,6 @@ linters:
3133
- gocritic
3234
- gocyclo
3335
- godox
34-
- gofmt
35-
- goimports
3636
- mnd
3737
- goprintffuncname
3838
- gosec
@@ -53,7 +53,68 @@ linters:
5353
- unparam
5454
- unused
5555
- whitespace
56+
exclusions:
57+
presets:
58+
- comments
59+
- std-error-handling
60+
- common-false-positives
61+
- legacy
62+
paths:
63+
- test/testdata_etc # test files
64+
- internal/go # extracted from Go code
65+
- internal/x # extracted from x/tools code
66+
- pkg/goformatters/gci/internal # extracted from gci code
67+
- pkg/goanalysis/runner_checker.go # extracted from x/tools code
68+
rules:
69+
- path: (.+)_test\.go
70+
linters:
71+
- dupl
72+
- mnd
73+
- lll
74+
75+
# Deprecated linter options.
76+
- path: pkg/golinters/errcheck/errcheck.go
77+
linters: [staticcheck]
78+
text: "SA1019: errCfg.Exclude is deprecated: use ExcludeFunctions instead"
79+
- path: pkg/golinters/errcheck/errcheck.go
80+
linters: [staticcheck]
81+
text: "SA1019: errCfg.Ignore is deprecated: use ExcludeFunctions instead"
82+
- path: pkg/golinters/govet/govet.go
83+
linters: [staticcheck]
84+
text: "SA1019: cfg.CheckShadowing is deprecated: the linter should be enabled inside Enable."
85+
- path: pkg/golinters/godot/godot.go
86+
linters: [staticcheck]
87+
text: "SA1019: settings.CheckAll is deprecated: use Scope instead"
88+
- path: pkg/goformatters/gci/gci.go
89+
linters: [staticcheck]
90+
text: "SA1019: settings.LocalPrefixes is deprecated: use Sections instead."
5691

92+
# Related to `run.go`, it cannot be removed.
93+
- path: pkg/golinters/gofumpt/gofumpt.go
94+
linters: [staticcheck]
95+
text: "SA1019: settings.LangVersion is deprecated: use the global `run.go` instead."
96+
97+
# Based on existing code, the modifications should be limited to make maintenance easier.
98+
- path: pkg/golinters/unused/unused.go
99+
linters: [gocritic]
100+
text: "rangeValCopy: each iteration copies 160 bytes \\(consider pointers or indexing\\)"
101+
102+
# Related to the result of computation but divided multiple times by 1024.
103+
- path: test/bench/bench_test.go
104+
linters: [gosec]
105+
text: "G115: integer overflow conversion uint64 -> int"
106+
107+
formatters:
108+
enable:
109+
- gofmt
110+
- goimports
111+
settings:
112+
gofmt:
113+
rewrite-rules:
114+
- pattern: 'interface{}'
115+
replacement: 'any'
116+
goimports:
117+
local-prefixes: github.com/golangci/golangci-lint
57118

58119
linters-settings:
59120
depguard:
@@ -95,12 +156,6 @@ linters-settings:
95156
godox:
96157
keywords:
97158
- FIXME
98-
gofmt:
99-
rewrite-rules:
100-
- pattern: 'interface{}'
101-
replacement: 'any'
102-
goimports:
103-
local-prefixes: github.com/golangci/golangci-lint
104159
mnd:
105160
# don't include the "operation" and "assign"
106161
checks:
@@ -146,53 +201,5 @@ linters-settings:
146201
- name: unused-parameter
147202
- name: unused-receiver
148203

149-
issues:
150-
exclude-rules:
151-
- path: (.+)_test\.go
152-
linters:
153-
- dupl
154-
- mnd
155-
- lll
156-
157-
# Deprecated linter options.
158-
- path: pkg/golinters/errcheck/errcheck.go
159-
linters: [staticcheck]
160-
text: "SA1019: errCfg.Exclude is deprecated: use ExcludeFunctions instead"
161-
- path: pkg/golinters/errcheck/errcheck.go
162-
linters: [staticcheck]
163-
text: "SA1019: errCfg.Ignore is deprecated: use ExcludeFunctions instead"
164-
- path: pkg/golinters/govet/govet.go
165-
linters: [staticcheck]
166-
text: "SA1019: cfg.CheckShadowing is deprecated: the linter should be enabled inside Enable."
167-
- path: pkg/golinters/godot/godot.go
168-
linters: [staticcheck]
169-
text: "SA1019: settings.CheckAll is deprecated: use Scope instead"
170-
- path: pkg/goformatters/gci/gci.go
171-
linters: [staticcheck]
172-
text: "SA1019: settings.LocalPrefixes is deprecated: use Sections instead."
173-
174-
# Related to `run.go`, it cannot be removed.
175-
- path: pkg/golinters/gofumpt/gofumpt.go
176-
linters: [staticcheck]
177-
text: "SA1019: settings.LangVersion is deprecated: use the global `run.go` instead."
178-
179-
# Based on existing code, the modifications should be limited to make maintenance easier.
180-
- path: pkg/golinters/unused/unused.go
181-
linters: [gocritic]
182-
text: "rangeValCopy: each iteration copies 160 bytes \\(consider pointers or indexing\\)"
183-
184-
# Related to the result of computation but divided multiple times by 1024.
185-
- path: test/bench/bench_test.go
186-
linters: [gosec]
187-
text: "G115: integer overflow conversion uint64 -> int"
188-
189-
exclude-dirs:
190-
- test/testdata_etc # test files
191-
- internal/go # extracted from Go code
192-
- internal/x # extracted from x/tools code
193-
- pkg/goformatters/gci/internal # extracted from gci code
194-
exclude-files:
195-
- pkg/goanalysis/runner_checker.go # extracted from x/tools code
196-
197204
run:
198205
timeout: 5m

0 commit comments

Comments
 (0)