Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove v1 exclusion configuration #5451

Merged
merged 8 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ jobs:
# - 1.18beta1 -> 1.18.0-beta.1
# - 1.18rc1 -> 1.18.0-rc.1
go-version: ${{ env.GO_VERSION }}
- name: lint
uses: golangci/[email protected]
with:
version: latest
# TODO(ldez): must add uncommented when [email protected] (with golangci-lint v2 support) will be created.
# - name: lint
# uses: golangci/[email protected]
# with:
# version: latest

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

- run: ./golangci-lint config
- run: ./golangci-lint config path
- run: ./golangci-lint config verify --schema jsonschema/golangci.jsonschema.json
# TODO(ldez) after v2: golangci.next.jsonschema.json -> golangci.jsonschema.json
- run: ./golangci-lint config verify --schema jsonschema/golangci.next.jsonschema.json

- run: ./golangci-lint help
- run: ./golangci-lint help linters
Expand Down
179 changes: 69 additions & 110 deletions .golangci.next.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,75 @@ linters:
# Default: false
fast: true

# Defines a set of rules to ignore issues.
# It does not skip the analysis, and so does not ignore "typecheck" errors.
exclusions:
# Mode of the generated files analysis.
#
# - `strict`: sources are excluded by strictly following the Go generated file convention.
# Source files that have lines matching only the following regular expression will be excluded: `^// Code generated .* DO NOT EDIT\.$`
# This line must appear before the first non-comment, non-blank text in the file.
# https://go.dev/s/generatedcode
# - `lax`: sources are excluded if they contain lines like `autogenerated file`, `code generated`, `do not edit`, etc.
# - `disable`: disable the generated files exclusion.
#
# Default: lax
generated: strict
# Log a warning if an exclusion rule is unused.
# Default: false
warn-unused: true
# Predefined exclusion rules.
# Default: []
presets:
- comments
- std-error-handling
- common-false-positives
- legacy

# Excluding configuration per-path, per-linter, per-text and per-source.
rules:
# Exclude some linters from running on tests files.
- path: _test\.go
linters:
- gocyclo
- errcheck
- dupl
- gosec

# Run some linter only for test files by excluding its issues for everything else.
- path-except: _test\.go
linters:
- forbidigo

# Exclude known linters from partially hard-vendored code,
# which is impossible to exclude via `nolint` comments.
# `/` will be replaced by the current OS file path separator to properly work on Windows.
- path: internal/hmac/
text: "weak cryptographic primitive"
linters:
- gosec

# Exclude some `staticcheck` messages.
- linters:
- staticcheck
text: "SA9003:"

# Exclude `lll` issues for long lines with `go:generate`.
- linters:
- lll
source: "^//go:generate "

# Which file paths to exclude: they will be analyzed, but issues from them won't be reported.
# "/" will be replaced by the current OS file path separator to properly work on Windows.
# Default: []
paths:
- ".*\\.my\\.go$"
- lib/bad.go
# Which file paths to not exclude.
# Default: []
paths-except:
- ".*\\.my\\.go$"
- lib/bad.go

formatters:
# Enable specific formatter.
Expand Down Expand Up @@ -3940,116 +4009,6 @@ linters-settings:


issues:
# List of regexps of issue texts to exclude.
#
# But independently of this option we use default exclude patterns,
# it can be disabled by `exclude-use-default: false`.
# To list all excluded by default patterns execute `golangci-lint run --help`
#
# Default: https://golangci-lint.run/usage/false-positives/#default-exclusions
exclude:
- abcdef

# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
# Exclude some linters from running on tests files.
- path: _test\.go
linters:
- gocyclo
- errcheck
- dupl
- gosec

# Run some linter only for test files by excluding its issues for everything else.
- path-except: _test\.go
linters:
- forbidigo

# Exclude known linters from partially hard-vendored code,
# which is impossible to exclude via `nolint` comments.
# `/` will be replaced by current OS file path separator to properly work on Windows.
- path: internal/hmac/
text: "weak cryptographic primitive"
linters:
- gosec

# Exclude some `staticcheck` messages.
- linters:
- staticcheck
text: "SA9003:"

# Exclude `lll` issues for long lines with `go:generate`.
- linters:
- lll
source: "^//go:generate "

# Independently of option `exclude` we use default exclude patterns,
# it can be disabled by this option.
# To list all excluded by default patterns execute `golangci-lint run --help`.
# Default: true
exclude-use-default: false

# If set to true, `exclude` and `exclude-rules` regular expressions become case-sensitive.
# Default: false
exclude-case-sensitive: false

# Which dirs to exclude: issues from them won't be reported.
# Can use regexp here: `generated.*`, regexp is applied on full path,
# including the path prefix if one is set.
# Default dirs are skipped independently of this option's value (see exclude-dirs-use-default).
# "/" will be replaced by current OS file path separator to properly work on Windows.
# Default: []
exclude-dirs:
- src/external_libs
- autogenerated_by_my_lib

# Enables exclude of directories:
# - vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
# Default: true
exclude-dirs-use-default: false

# Which files to exclude: they will be analyzed, but issues from them won't be reported.
# There is no need to include all autogenerated files,
# we confidently recognize autogenerated files.
# If it's not, please let us know.
# "/" will be replaced by current OS file path separator to properly work on Windows.
# Default: []
exclude-files:
- ".*\\.my\\.go$"
- lib/bad.go

# Mode of the generated files analysis.
#
# - `strict`: sources are excluded by following strictly the Go generated file convention.
# Source files that have lines matching only the following regular expression will be excluded: `^// Code generated .* DO NOT EDIT\.$`
# This line must appear before the first non-comment, non-blank text in the file.
# https://go.dev/s/generatedcode
# - `lax`: sources are excluded if they contain lines `autogenerated file`, `code generated`, `do not edit`, etc.
# - `disable`: disable the generated files exclusion.
#
# Default: lax
exclude-generated: strict

# The list of ids of default excludes to include or disable.
# https://golangci-lint.run/usage/false-positives/#default-exclusions
# Default: []
include:
- EXC0001
- EXC0002
- EXC0003
- EXC0004
- EXC0005
- EXC0006
- EXC0007
- EXC0008
- EXC0009
- EXC0010
- EXC0011
- EXC0012
- EXC0013
- EXC0014
- EXC0015

# Maximum issues count per one linter.
# Set to 0 to disable.
# Default: 50
Expand Down
119 changes: 63 additions & 56 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#
# See the file `.golangci.reference.yml` to have a list of all available configuration options.

version: "2"

linters:
disable-all: true
# This list of linters is not a recommendation (same thing for all this configuration file).
Expand All @@ -31,8 +33,6 @@ linters:
- gocritic
- gocyclo
- godox
- gofmt
- goimports
- mnd
- goprintffuncname
- gosec
Expand All @@ -53,7 +53,68 @@ linters:
- unparam
- unused
- whitespace
exclusions:
presets:
- comments
- std-error-handling
- common-false-positives
- legacy
paths:
- test/testdata_etc # test files
- internal/go # extracted from Go code
- internal/x # extracted from x/tools code
- pkg/goformatters/gci/internal # extracted from gci code
- pkg/goanalysis/runner_checker.go # extracted from x/tools code
rules:
- path: (.+)_test\.go
linters:
- dupl
- mnd
- lll

# Deprecated linter options.
- path: pkg/golinters/errcheck/errcheck.go
linters: [staticcheck]
text: "SA1019: errCfg.Exclude is deprecated: use ExcludeFunctions instead"
- path: pkg/golinters/errcheck/errcheck.go
linters: [staticcheck]
text: "SA1019: errCfg.Ignore is deprecated: use ExcludeFunctions instead"
- path: pkg/golinters/govet/govet.go
linters: [staticcheck]
text: "SA1019: cfg.CheckShadowing is deprecated: the linter should be enabled inside Enable."
- path: pkg/golinters/godot/godot.go
linters: [staticcheck]
text: "SA1019: settings.CheckAll is deprecated: use Scope instead"
- path: pkg/goformatters/gci/gci.go
linters: [staticcheck]
text: "SA1019: settings.LocalPrefixes is deprecated: use Sections instead."

# Related to `run.go`, it cannot be removed.
- path: pkg/golinters/gofumpt/gofumpt.go
linters: [staticcheck]
text: "SA1019: settings.LangVersion is deprecated: use the global `run.go` instead."

# Based on existing code, the modifications should be limited to make maintenance easier.
- path: pkg/golinters/unused/unused.go
linters: [gocritic]
text: "rangeValCopy: each iteration copies 160 bytes \\(consider pointers or indexing\\)"

# Related to the result of computation but divided multiple times by 1024.
- path: test/bench/bench_test.go
linters: [gosec]
text: "G115: integer overflow conversion uint64 -> int"

formatters:
enable:
- gofmt
- goimports
settings:
gofmt:
rewrite-rules:
- pattern: 'interface{}'
replacement: 'any'
goimports:
local-prefixes: github.com/golangci/golangci-lint

linters-settings:
depguard:
Expand Down Expand Up @@ -95,12 +156,6 @@ linters-settings:
godox:
keywords:
- FIXME
gofmt:
rewrite-rules:
- pattern: 'interface{}'
replacement: 'any'
goimports:
local-prefixes: github.com/golangci/golangci-lint
mnd:
# don't include the "operation" and "assign"
checks:
Expand Down Expand Up @@ -146,53 +201,5 @@ linters-settings:
- name: unused-parameter
- name: unused-receiver

issues:
exclude-rules:
- path: (.+)_test\.go
linters:
- dupl
- mnd
- lll

# Deprecated linter options.
- path: pkg/golinters/errcheck/errcheck.go
linters: [staticcheck]
text: "SA1019: errCfg.Exclude is deprecated: use ExcludeFunctions instead"
- path: pkg/golinters/errcheck/errcheck.go
linters: [staticcheck]
text: "SA1019: errCfg.Ignore is deprecated: use ExcludeFunctions instead"
- path: pkg/golinters/govet/govet.go
linters: [staticcheck]
text: "SA1019: cfg.CheckShadowing is deprecated: the linter should be enabled inside Enable."
- path: pkg/golinters/godot/godot.go
linters: [staticcheck]
text: "SA1019: settings.CheckAll is deprecated: use Scope instead"
- path: pkg/goformatters/gci/gci.go
linters: [staticcheck]
text: "SA1019: settings.LocalPrefixes is deprecated: use Sections instead."

# Related to `run.go`, it cannot be removed.
- path: pkg/golinters/gofumpt/gofumpt.go
linters: [staticcheck]
text: "SA1019: settings.LangVersion is deprecated: use the global `run.go` instead."

# Based on existing code, the modifications should be limited to make maintenance easier.
- path: pkg/golinters/unused/unused.go
linters: [gocritic]
text: "rangeValCopy: each iteration copies 160 bytes \\(consider pointers or indexing\\)"

# Related to the result of computation but divided multiple times by 1024.
- path: test/bench/bench_test.go
linters: [gosec]
text: "G115: integer overflow conversion uint64 -> int"

exclude-dirs:
- test/testdata_etc # test files
- internal/go # extracted from Go code
- internal/x # extracted from x/tools code
- pkg/goformatters/gci/internal # extracted from gci code
exclude-files:
- pkg/goanalysis/runner_checker.go # extracted from x/tools code

run:
timeout: 5m
Loading
Loading