Skip to content

Commit c704960

Browse files
committed
chore: remove v1 exclusion configuration
1 parent fab6467 commit c704960

17 files changed

+161
-1097
lines changed

Diff for: .golangci.next.reference.yml

+72-110
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,78 @@ 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 don't ignore "typecheck" errors.
266+
exclusions:
267+
# Mode of the generated files analysis.
268+
#
269+
# - `strict`: sources are excluded by following strictly 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 `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+
- stdErrorHandling
286+
- commonFalsePositives
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 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+
# There is no need to include all autogenerated files,
324+
# we confidently recognize autogenerated files.
325+
# If it's not, please let us know.
326+
# "/" will be replaced by current OS file path separator to properly work on Windows.
327+
# Default: []
328+
paths:
329+
- ".*\\.my\\.go$"
330+
- lib/bad.go
331+
# Which file paths to not exclude.
332+
# Default: []
333+
paths-except:
334+
- ".*\\.my\\.go$"
335+
- lib/bad.go
264336

265337
formatters:
266338
# Enable specific formatter.
@@ -3940,116 +4012,6 @@ linters-settings:
39404012

39414013

39424014
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-
40534015
# Maximum issues count per one linter.
40544016
# Set to 0 to disable.
40554017
# Default: 50

Diff for: jsonschema/golangci.next.jsonschema.json

+1-102
Original file line numberDiff line numberDiff line change
@@ -4254,7 +4254,7 @@
42544254
"properties": {
42554255
"generated": {
42564256
"enum": ["strict", "lax", "disable"],
4257-
"default": "lax"
4257+
"default": "strict"
42584258
},
42594259
"warn-unused": {
42604260
"type": "boolean",
@@ -4374,107 +4374,6 @@
43744374
"type": "object",
43754375
"additionalProperties": false,
43764376
"properties": {
4377-
"exclude": {
4378-
"description": "List of regular expressions of issue texts to exclude.\nBut independently from this option we use default exclude patterns. Their usage can be controlled through `exclude-use-default`.",
4379-
"type": "array",
4380-
"items": {
4381-
"type": "string"
4382-
}
4383-
},
4384-
"exclude-rules": {
4385-
"description": "Exclude configuration per-path, per-linter, per-text and per-source",
4386-
"type": "array",
4387-
"items": {
4388-
"type": "object",
4389-
"additionalProperties": false,
4390-
"properties": {
4391-
"path": {
4392-
"type": "string"
4393-
},
4394-
"path-except": {
4395-
"type": "string"
4396-
},
4397-
"linters": {
4398-
"type": "array",
4399-
"items": {
4400-
"$ref": "#/definitions/linter-names"
4401-
}
4402-
},
4403-
"text": {
4404-
"type": "string"
4405-
},
4406-
"source": {
4407-
"type": "string"
4408-
}
4409-
}
4410-
}
4411-
},
4412-
"exclude-use-default": {
4413-
"description": "Independently from option `exclude` we use default exclude patterns. This behavior can be disabled by this option.",
4414-
"type": "boolean",
4415-
"default": true
4416-
},
4417-
"exclude-case-sensitive": {
4418-
"description": "If set to true, exclude and exclude-rules regular expressions become case sensitive.",
4419-
"type": "boolean",
4420-
"default": false
4421-
},
4422-
"exclude-generated": {
4423-
"description": "Mode of the generated files analysis.",
4424-
"enum": ["lax", "strict", "disable"],
4425-
"default": "lax"
4426-
},
4427-
"exclude-dirs": {
4428-
"description": "Which directories to exclude: issues from them won't be reported.",
4429-
"type": "array",
4430-
"items": {
4431-
"description": "You can use regexp here. The regexp is applied on the full path.\n\"/\" will be replaced by current OS file path separator to properly work on Windows.",
4432-
"type": "string",
4433-
"examples": ["generated.*"]
4434-
},
4435-
"default": [],
4436-
"examples": [["src/external_libs", "autogenerated_by_my_lib"]]
4437-
},
4438-
"exclude-dirs-use-default": {
4439-
"description": "Enable exclusion of directories \"vendor\", \"third_party\", \"testdata\", \"examples\", \"Godeps\", and \"builtin\".",
4440-
"type": "boolean",
4441-
"default": true
4442-
},
4443-
"exclude-files": {
4444-
"description": "Which files to exclude: they will be analyzed, but issues from them will not be reported.",
4445-
"type": "array",
4446-
"items": {
4447-
"description": "You can use regexp here. There is no need to include all autogenerated files, we confidently recognize them. If that is not the case, please let us know.\n\"/\" will be replaced by current OS file path separator to properly work on Windows.",
4448-
"type": "string",
4449-
"examples": [".*\\.my\\.go$"]
4450-
},
4451-
"default": [],
4452-
"examples": [[".*\\.my\\.go$", "lib/bad.go"]]
4453-
},
4454-
"include": {
4455-
"description": "The list of ids of default excludes to include or disable.",
4456-
"type": "array",
4457-
"items": {
4458-
"enum": [
4459-
"EXC0001",
4460-
"EXC0002",
4461-
"EXC0003",
4462-
"EXC0004",
4463-
"EXC0005",
4464-
"EXC0006",
4465-
"EXC0007",
4466-
"EXC0008",
4467-
"EXC0009",
4468-
"EXC0010",
4469-
"EXC0011",
4470-
"EXC0012",
4471-
"EXC0013",
4472-
"EXC0014",
4473-
"EXC0015"
4474-
]
4475-
},
4476-
"default": []
4477-
},
44784377
"max-issues-per-linter": {
44794378
"description": "Maximum issues count per one linter. Set to 0 to disable.",
44804379
"type": "integer",

Diff for: pkg/commands/flagsets.go

-29
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ import (
99
"github.com/spf13/viper"
1010

1111
"github.com/golangci/golangci-lint/pkg/commands/internal"
12-
"github.com/golangci/golangci-lint/pkg/config"
1312
"github.com/golangci/golangci-lint/pkg/exitcodes"
1413
"github.com/golangci/golangci-lint/pkg/lint/lintersdb"
15-
"github.com/golangci/golangci-lint/pkg/result/processors"
1614
)
1715

1816
const defaultMaxIssuesPerLinter = 50
@@ -130,27 +128,13 @@ func setupOutputFormatsFlagSet(v *viper.Viper, fs *pflag.FlagSet) {
130128

131129
//nolint:gomnd // magic numbers here is ok
132130
func setupIssuesFlagSet(v *viper.Viper, fs *pflag.FlagSet) {
133-
internal.AddHackedStringSliceP(fs, "exclude", "e", color.GreenString("Exclude issue by regexp"))
134-
internal.AddFlagAndBind(v, fs, fs.Bool, "exclude-use-default", "issues.exclude-use-default", true,
135-
getDefaultIssueExcludeHelp())
136-
internal.AddFlagAndBind(v, fs, fs.Bool, "exclude-case-sensitive", "issues.exclude-case-sensitive", false,
137-
color.GreenString("If set to true exclude and exclude rules regular expressions are case-sensitive"))
138-
139131
internal.AddFlagAndBind(v, fs, fs.Int, "max-issues-per-linter", "issues.max-issues-per-linter", defaultMaxIssuesPerLinter,
140132
color.GreenString("Maximum issues count per one linter. Set to 0 to disable"))
141133
internal.AddFlagAndBind(v, fs, fs.Int, "max-same-issues", "issues.max-same-issues", 3,
142134
color.GreenString("Maximum count of issues with the same text. Set to 0 to disable"))
143135
internal.AddFlagAndBind(v, fs, fs.Bool, "uniq-by-line", "issues.uniq-by-line", true,
144136
color.GreenString("Make issues output unique by line"))
145137

146-
internal.AddHackedStringSlice(fs, "exclude-files", color.GreenString("Regexps of files to exclude"))
147-
internal.AddHackedStringSlice(fs, "exclude-dirs", color.GreenString("Regexps of directories to exclude"))
148-
internal.AddFlagAndBind(v, fs, fs.Bool, "exclude-dirs-use-default", "issues.exclude-dirs-use-default", true,
149-
formatList("Use or not use default excluded directories:", processors.StdExcludeDirRegexps))
150-
151-
internal.AddFlagAndBind(v, fs, fs.String, "exclude-generated", "issues.exclude-generated", config.GeneratedModeLax,
152-
color.GreenString("Mode of the generated files analysis"))
153-
154138
const newDesc = "Show only new issues: if there are unstaged changes or untracked files, only those changes " +
155139
"are analyzed, else only changes in HEAD~ are analyzed.\nIt's a super-useful option for integration " +
156140
"of golangci-lint into existing large codebase.\nIt's not practical to fix all existing issues at " +
@@ -186,16 +170,3 @@ func formatList(head string, items []string, foot ...string) string {
186170

187171
return strings.Join(parts, "\n")
188172
}
189-
190-
func getDefaultIssueExcludeHelp() string {
191-
parts := []string{color.GreenString("Use or not use default excludes:")}
192-
193-
for _, ep := range config.DefaultExcludePatterns {
194-
parts = append(parts,
195-
fmt.Sprintf(" - %s (%s): %s", color.BlueString(ep.ID), color.CyanString(ep.Linter), ep.Why),
196-
fmt.Sprintf(` Pattern: %s`, color.YellowString(`'`+ep.Pattern+`'`)),
197-
)
198-
}
199-
200-
return strings.Join(parts, "\n")
201-
}

0 commit comments

Comments
 (0)