Skip to content

golangci-lint run --disable-all does not disable all linters #3453

Closed
@stdedos

Description

@stdedos

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

$ golangci-lint run -v --disable-all 
INFO [config_reader] Config search paths: [./ /home/stdedos/Documents/RelexOy/shift-optimization-algorithm /home/stdedos/Documents/RelexOy /home/stdedos/Documents /home/stdedos /home /] 
INFO [config_reader] Used config file golang-utilities/test_scripts/.golangci.yml 
INFO [lintersdb] Active 10 linters: [exhaustive gocritic gofumpt goimports gomnd prealloc revive stylecheck unparam wastedassign] 
INFO [loader] Go packages loading at mode 575 (files|name|types_sizes|compiled_files|deps|exports_file|imports) took 223.491004ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 9.90698ms 
...

I am trying to do $ golangci-lint run -v --disable-all -E goimports, with the intention of only running goimports.
golangci-lint runs successfully, but my intention fails miserably.

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 1.50.1 built from 8926a95f on 2022-10-22T10:50:47Z

Configuration file

$ cat .golangci.yml
run:
  timeout: 10m

linters:
  fast: false
  enable:
    - revive
    - unparam
    - wastedassign
    - exhaustive
    - gomnd
    - gofumpt
    - goimports
    - stylecheck
    - prealloc
    - gocritic

linters-settings:
  govet:
    check-shadowing: true
  goimports:
    local-prefixes: <local prefix>
  gocritic:
    enabled-checks:
      # first default checks
      - appendAssign
      - argOrder
      - assignOp
      - badCall
      - badCond
      - captLocal
      - caseOrder
      - codegenComment
      # - commentFormatting # conflict with gofumpt and --fix
      - defaultCaseOrder
      - deprecatedComment
      - dupArg
      - dupBranchBody
      - dupCase
      - dupSubExpr
      - elseif
      - exitAfterDefer
      - flagDeref
      - flagName
      - ifElseChain
      - mapKey
      - newDeref
      - offBy1
      - regexpMust
      - singleCaseSwitch
      - sloppyLen
      - sloppyTypeAssert
      - switchTrue
      - typeSwitchVar
      - underef
      - unlambda
      - unslice
      - valSwap
      - wrapperFunc
      # non-defaults
      # perf
      - appendCombine
      - equalFold
      - indexAlloc
      - preferDecodeRune
      - preferFprint
      - preferStringWriter
      - preferWriteByte
      - rangeExprCopy
      - sliceClear
      - stringXbytes
      # style
      - boolExprSimplify
      - commentedOutImport
      - deferUnlambda
      - emptyStringTest
      - hexLiteral
      - httpNoBody
      - importShadow
      - initClause
      - methodExprCall
      - preferFilepathJoin
      - ptrToRefParam
      - redundantSprint
      - regexpSimplify
      - stringConcatSimplify
      - timeExprSimplify
      # - typeDefFirst # disabled for generics
      - typeUnparen
      - unlabelStmt
      - unnecessaryBlock
      - yodaStyleExpr
      # diagnostics
      - badLock
      - badRegexp
      - builtinShadowDecl
      - emptyDecl
      - evalOrder
      # - externalErrorReassign # disabled for generics
      - filepathJoin
      - nilValReturn
      - regexpPattern
      - returnAfterHttpError
      - sloppyReassign
      - sortSlice
      - sprintfQuotedString
      - sqlQuery
      # - suspiciousSorting # add this when updating linter
      - syncMapLoadAndDelete
      - truncateCmp
      - unnecessaryDefer
      - weakCond

issues:
  exclude-rules:
    - linters:
        - revive
      text: "var-naming: don't use leading k in Go names"
    - linters:
        - revive
      text: "package-comments: should have a package comment"
    - linters:
      - unparam
      text: "always receives"
  include:
    - EXC0012
    - EXC0013
    - EXC0014

severity:
  default-severity: Major

output:
  format: code-climate
  uniq-by-line: false

Go environment

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

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
# paste output here

Code example or link to a public repository

Private repo 🤷
// add your code here

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions