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

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

Closed
5 tasks done
lyarwood opened this issue Aug 9, 2023 · 2 comments
Closed
5 tasks done
Labels
duplicate This issue or pull request already exists question Further information is requested

Comments

@lyarwood
Copy link

lyarwood commented Aug 9, 2023

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.).
@lyarwood lyarwood added the bug Something isn't working label Aug 9, 2023
@boring-cyborg
Copy link

boring-cyborg bot commented Aug 9, 2023

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 Aug 9, 2023
@ldez
Copy link
Member

ldez commented Aug 9, 2023

duplicate of #3453

@ldez ldez closed this as completed Aug 9, 2023
@ldez ldez added the duplicate This issue or pull request already exists label Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants