Skip to content

Disabling alias silently disables enabled linters #3746

@matthewhughes934

Description

@matthewhughes934

Welcome

  • Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc.).
  • Yes, I've tried with the standalone linter if available (e.g., gocritic, go vet, etc.). (https://golangci-lint.run/usage/linters/)

Description of the problem

Given the file:

$ cat bare.go 
package barepkg

func SomeFunc() {
	if 1 == 1 {}	// trigger staticcheck error
}

Running with staticcheck reports an issue as expected:

$ ./golangci-lint run --no-config --enable staticcheck bare.go 
bare.go:4:2: SA9003: empty branch (staticcheck)
	if 1 == 1 {}	// trigger staticcheck error
	^

Disabling and enabling staticcheck errors as expected:

$ ./golangci-lint run --no-config --enable staticcheck --disable staticcheck bare.go 
ERRO Running error: linter "staticcheck" can't be disabled and enabled at one moment 

but Disabling megacheck (alias for staticcheck) and enabling staticcheck silently disables staticcheck:

$ ./golangci-lint run --no-config --enable staticcheck --disable megacheck bare.go
$ echo $?
0

Version of golangci-lint

Tested on 1.52.1 and the current head of master: ca05239

$ golangci-lint --version
golangci-lint has version 1.52.1 built with go1.20.2 from d92b38cc on 2023-03-21T19:48:38Z
$ ./golangci-lint --version
golangci-lint has version (devel) built with go1.20.2 from (unknown, mod sum: "") on (unknown

Configuration file

No config, see flags in description

Go environment

$ go version && go env | sed 's/mjh/me/g'
go version go1.20.2 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/me/.cache/go-build"
GOENV="/home/me/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/me/.local/share/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/me/.local/share/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.20.2"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/me/src/golangci-lint/go.mod"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build635768465=/tmp/go-build -gno-record-gcc-switches

Verbose output of running

Adding verbosity to example above

$ golangci-lint cache clean
$ ./golangci-lint run --verbose --no-config --enable staticcheck --disable megacheck bare.go 
INFO [lintersdb] Active 4 linters: [errcheck govet ineffassign typecheck] 
INFO [loader] Go packages loading at mode 575 (imports|name|types_sizes|deps|files|compiled_files|exports_file) took 12.13721ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 165.104µs 
INFO [linters_context/goanalysis] analyzers took 0s with no stages 
INFO [runner] processing took 33.805µs with stages: max_same_issues: 1.956µs, path_prettifier: 1.955µs, cgo: 1.886µs, skip_dirs: 1.886µs, uniq_by_line: 1.886µs, nolint: 1.886µs, autogenerated_exclude: 1.886µs, fixer: 1.816µs, max_per_file_from_linter: 1.467µs, sort_results: 1.467µs, severity-rules: 1.467µs, exclude: 1.467µs, identifier_marker: 1.467µs, path_prefixer: 1.467µs, filename_unadjuster: 1.466µs, source_code: 1.397µs, diff: 1.397µs, exclude-rules: 1.397µs, max_from_linter: 1.397µs, path_shortener: 1.396µs, skip_files: 1.396µs 
INFO [runner] linters took 536.516µs with stages: goanalysis_metalinter: 395.718µs 
INFO File cache stats: 0 entries of total size 0B 
INFO Memory: 2 samples, avg is 31.6MB, max is 31.6MB 
INFO Execution took 18.626256ms 

Code example or link to a public repository

See description

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: configRelated to .golangci.yml and/or cli optionsbugSomething isn't workingwon't fixThis will not be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions