Skip to content

revive: overriding one linter rule disables other rules #5747

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

Closed
6 of 7 tasks
kkettinger opened this issue Apr 18, 2025 · 2 comments
Closed
6 of 7 tasks

revive: overriding one linter rule disables other rules #5747

kkettinger opened this issue Apr 18, 2025 · 2 comments
Labels
question Further information is requested

Comments

@kkettinger
Copy link

kkettinger commented Apr 18, 2025

Welcome

  • Yes, I'm using a binary release within 2 latest releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've read the typecheck section of the FAQ.
  • Yes, I've tried with the standalone linter if available (e.g., gocritic, go vet, etc.).
  • I agree to follow this project's Code of Conduct

How did you install golangci-lint?

Official binary

Description of the problem

Using this minimal .golangci.yml yields around 12 errors in my project (exported, package-comments):

version: "2"
linters:
  default: none
  enable:
    - revive
12 issues:
* revive: 12

Now i add linter settings to ignore package-comments errors for revive:

version: "2"
linters:
  default: none
  enable:
    - revive
  settings:
    revive:
      rules:
        - name: package-comments
          disabled: true

Running golangci-lint again, suddenly the exported errors are gone:

0 issues.

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 2.1.2 built with go1.24.2 from 00a561d9 on 2025-04-15T13:26:47Z

Configuration

version: "2"
linters:
  default: none
  enable:
    - revive
  settings:
    revive:
      rules:
        - name: package-comments
          disabled: true

Go environment

$ go version && go env
go version go1.24.1 linux/amd64
AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE='on'
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/kk/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/kk/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build4256416931=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/kk/projects/misc/tinysa/go-tinysa/go.mod'
GOMODCACHE='/home/kk/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/kk/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/kk/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.24.1'
GOWORK=''
PKG_CONFIG='pkg-config'

Verbose output of running

Without revive settings:

$ golangci-lint cache clean
$ golangci-lint run -v
INFO golangci-lint has version 2.1.2 built with go1.24.2 from 00a561d9 on 2025-04-15T13:26:47Z 
INFO [config_reader] Config search paths: [./ /home/kk/projects/misc/tinysa/go-tinysa /home/kk/projects/misc/tinysa /home/kk/projects/misc /home/kk/projects /home/kk /home /] 
INFO [config_reader] Used config file .golangci.yml 
INFO maxprocs: Leaving GOMAXPROCS=16: CPU quota undefined 
INFO [goenv] Read go env for 2.830929ms: map[string]string{"GOCACHE":"/home/kk/.cache/go-build", "GOROOT":"/usr/local/go"} 
INFO [lintersdb] Active 1 linters: [revive]       
INFO [loader] Go packages loading at mode 8199 (compiled_files|files|name) took 75.45262ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 2.053424ms 
INFO [linters_context/goanalysis] analyzers took 908.594413ms with top 10 stages: the_only_name: 908.511028ms, typecheck: 83.385µs 
INFO [runner/max_same_issues] 4/7 issues with text "package-comments: should have a package comment" were hidden, use --max-same-issues 
INFO [runner] Issues before processing: 16, after processing: 12 
INFO [runner] Processors filtering stat (in/out): exclusion_paths: 16/16, nolint_filter: 16/16, uniq_by_line: 16/16, max_per_file_from_linter: 16/16, source_code: 12/12, path_shortener: 12/12, severity-rules: 12/12, path_prettifier: 12/12, sort_results: 12/12, cgo: 16/16, filename_unadjuster: 16/16, path_relativity: 16/16, generated_file_filter: 16/16, exclusion_rules: 16/16, max_same_issues: 16/12, max_from_linter: 12/12, diff: 16/16, fixer: 16/16, path_absoluter: 16/16, invalid_issue: 16/16 
INFO [runner] processing took 580.117µs with stages: nolint_filter: 329.487µs, generated_file_filter: 120.786µs, source_code: 58.55µs, max_same_issues: 18.716µs, sort_results: 9.608µs, path_relativity: 9.026µs, uniq_by_line: 8.325µs, invalid_issue: 5.12µs, cgo: 4.94µs, max_from_linter: 3.466µs, path_prettifier: 2.956µs, max_per_file_from_linter: 2.755µs, filename_unadjuster: 2.485µs, path_shortener: 1.052µs, path_absoluter: 921ns, fixer: 521ns, exclusion_paths: 461ns, exclusion_rules: 452ns, diff: 370ns, severity-rules: 120ns 
INFO [runner] linters took 471.54607ms with stages: goanalysis_metalinter: 470.913956ms 
device.go:10:6: exported: exported type Device should have comment or be unexported (revive)
type Device struct {
     ^
device_models.go:3:6: exported: exported type Model should have comment or be unexported (revive)
type Model string
     ^
device_models.go:6:2: exported: exported const ModelBasic should have comment (or a comment on this block) or be unexported (revive)
        ModelBasic Model = "tinySA"
        ^
device_options.go:30:6: exported: exported type DeviceOption should have comment or be unexported (revive)
type DeviceOption func(*deviceOptions)
     ^
device_options.go:32:1: exported: exported function WithBaudRate should have comment or be unexported (revive)
func WithBaudRate(baudRate int) DeviceOption {
^
device_options.go:38:1: exported: exported function WithLogger should have comment or be unexported (revive)
func WithLogger(logger *slog.Logger) DeviceOption {
^
device_options.go:44:1: exported: exported function WithReadTimeout should have comment or be unexported (revive)
func WithReadTimeout(timeout time.Duration) DeviceOption {
^
device_options.go:50:1: exported: exported function WithResponseTimeout should have comment or be unexported (revive)
func WithResponseTimeout(timeout time.Duration) DeviceOption {
^
errors.go:5:5: exported: exported var ErrCommandResponseTimeout should have comment or be unexported (revive)
var ErrCommandResponseTimeout = errors.New("command response timeout")
    ^
examples/raw_command/main.go:1:1: package-comments: should have a package comment (revive)
package main
^
examples/sweep/main.go:1:1: package-comments: should have a package comment (revive)
package main
^
examples/trace_data/main.go:1:1: package-comments: should have a package comment (revive)
package main
^
12 issues:
* revive: 12
INFO File cache stats: 7 entries of total size 4.2KiB 
INFO Memory: 7 samples, avg is 46.4MB, max is 49.0MB 
INFO Execution took 552.338867ms               

With revive settings:

$ golangci-lint cache clean
$ golangci-lint run -v
INFO golangci-lint has version 2.1.2 built with go1.24.2 from 00a561d9 on 2025-04-15T13:26:47Z 
INFO [config_reader] Config search paths: [./ /home/kk/projects/misc/tinysa/go-tinysa /home/kk/projects/misc/tinysa /home/kk/projects/misc /home/kk/projects /home/kk /home /] 
INFO [config_reader] Used config file .golangci.yml 
INFO maxprocs: Leaving GOMAXPROCS=16: CPU quota undefined 
INFO [goenv] Read go env for 3.449748ms: map[string]string{"GOCACHE":"/home/kk/.cache/go-build", "GOROOT":"/usr/local/go"} 
INFO [lintersdb] Active 1 linters: [revive]       
INFO [loader] Go packages loading at mode 8199 (name|compiled_files|files) took 80.398942ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 2.304223ms 
INFO [linters_context/goanalysis] analyzers took 2.686788ms with top 10 stages: the_only_name: 2.572005ms, typecheck: 114.783µs 
INFO [runner] processing took 3.244µs with stages: exclusion_paths: 531ns, max_same_issues: 380ns, exclusion_rules: 350ns, path_absoluter: 290ns, nolint_filter: 270ns, max_per_file_from_linter: 170ns, path_relativity: 160ns, path_shortener: 151ns, diff: 131ns, source_code: 130ns, max_from_linter: 110ns, filename_unadjuster: 80ns, path_prettifier: 70ns, uniq_by_line: 61ns, sort_results: 60ns, cgo: 60ns, severity-rules: 60ns, fixer: 60ns, generated_file_filter: 60ns, invalid_issue: 60ns 
INFO [runner] linters took 5.046507ms with stages: goanalysis_metalinter: 5.003987ms 
0 issues.
INFO File cache stats: 0 entries of total size 0B 
INFO Memory: 2 samples, avg is 38.0MB, max is 40.1MB 
INFO Execution took 91.608425ms                   

A minimal reproducible example or link to a public repository

// add your code here

Validation

  • Yes, I've included all information above (version, config, etc.).

Supporter

@kkettinger kkettinger added the bug Something isn't working label Apr 18, 2025
Copy link

boring-cyborg bot commented Apr 18, 2025

Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.

@ldez ldez added question Further information is requested and removed bug Something isn't working labels Apr 18, 2025
@ldez ldez changed the title Overriding one linter rule disables other rules revive: overriding one linter rule disables other rules Apr 18, 2025
@ldez
Copy link
Member

ldez commented Apr 18, 2025

Hello,

This is the behavior of revive, this is not related to something specific to golangci-lint.

@ldez ldez closed this as completed Apr 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants