Skip to content

The --disable-all switch appears to be always ignored in favour of the config? #3998

@lyarwood

Description

@lyarwood

Welcome

Description of the problem

I'm unable to disable all linters from the command line when a local config is present, this is awkward as I'd like to reuse linters-settings from the local config for a second run against a different set of directories than the first. For example:

$ yq .linters .golangci.yml 
disable-all: true
enable:
  - bodyclose
  - dogsled
  - dupl
  - errcheck
  - exportloopref
  - exhaustive
  - funlen
  - ginkgolinter
  - gochecknoinits
  - goconst
  - gocritic
  - gocyclo
  - gofmt
  - goheader
  - goimports
  - gomnd
  - goprintffuncname
  - gosec
  - gosimple
  - govet
  - ineffassign
  - lll
  - misspell
  - nakedret
  - noctx
  - nolintlint
  - rowserrcheck
  - staticcheck
  - stylecheck
  - typecheck
  - unconvert
  - unparam
  - unused
  - whitespace
$ yq .linters-settings.ginkgolinter .golangci.yml 
forbid-focus-container: true
$ golangci-lint run --disable-all -E ginkgolinter --verbose
[..]
INFO [lintersdb] Active 33 linters: [bodyclose dogsled dupl errcheck exhaustive exportloopref funlen ginkgolinter gochecknoinits goconst gocritic gocyclo gofmt goheader goimports gomnd goprintffuncname gosec gosimple govet ineffassign lll misspell nakedret noctx nolintlint rowserrcheck staticcheck stylecheck unconvert unparam unused whitespace] 

Providing --no-config avoids this but I then loose the ginkgolinter configuration. Without a way of passing these options in through the command line the only real workaround here is to write a second minimal config.

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 1.54.0 built with go1.21.0 from c1d8c565 on 2023-08-09T11:50:00Z

Configuration

# golangci configuration

linters-settings:
  dupl:
    threshold: 100
  funlen:
    lines: 100
    statements: 50
  gci:
    local-prefixes: github.com/kubevirt/kubevirt
  goconst:
    min-len: 2
    min-occurrences: 2
  gocritic:
    enabled-tags:
      - diagnostic
      - experimental
      - opinionated
      - performance
      - style
    disabled-checks:
      - dupImport # https://github.com/go-critic/go-critic/issues/845
      - ifElseChain
      - octalLiteral
      - paramTypeCombine
      - whyNoLint
      - wrapperFunc
    settings:
      hugeParam:
        sizeThreshold: 1024
      rangeValCopy:
        sizeThreshold: 1024
  gocyclo:
    min-complexity: 15
  goimports:
    local-prefixes: kubevirt.io/kubevirt
  gomnd:
    settings:
      mnd:
        # don't include the "operation" and "assign"
        checks: argument,case,condition,return
  govet:
    check-shadowing: true
  lll:
    line-length: 140
  maligned:
    suggest-new: true
  misspell:
    locale: US
  nolintlint:
    allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space)
    allow-unused: false # report any unused nolint directives
    require-explanation: false # don't require an explanation for nolint directives
    require-specific: false # don't require nolint directives to be specific about which linter is being skipped
  stylecheck:
    dot-import-whitelist:
      - "github.com/onsi/ginkgo/v2"
      - "github.com/onsi/gomega"
  ginkgolinter:
    forbid-focus-container: true
linters:
  disable-all: true
  enable:
    - bodyclose
    - dogsled
    - dupl
    - errcheck
    - exportloopref
    - exhaustive
    - funlen
    - ginkgolinter
    - gochecknoinits
    - goconst
    - gocritic
    - gocyclo
    - gofmt
    - goheader
    - goimports
    - gomnd
    - goprintffuncname
    - gosec
    - gosimple
    - govet
    - ineffassign
    - lll
    - misspell
    - nakedret
    - noctx
    - nolintlint
    - rowserrcheck
    - staticcheck
    - stylecheck
    - typecheck
    - unconvert
    - unparam
    - unused
    - whitespace

  # don't enable:
  # - asciicheck
  # - scopelint
  # - gochecknoglobals
  # - gocognit
  # - godot
  # - godox
  # - goerr113
  # - interfacer
  # - maligned
  # - nestif
  # - prealloc
  # - testpackage
  # - revive
  # - wsl

Go environment

$ go version 
go version go1.19.10 linux/amd64
</details>

### Verbose output of running

<details>

```console
See above

Code example or link to a public repository

// add your code here

Validation

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already existsquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions