Skip to content

panic in a linter should lead to a non-zero return code #1974

Closed
@ashanbrown

Description

@ashanbrown
  • 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. (https://golangci-lint.run/usage/linters/)
Description of the problem

Release v1.40.0 had an issue with govet that leads to panics. When this panic occurred, the linter would appear to pass. The panic was logged to the screen based on the behavior described at #1537 (comment). In my own case, golangci-lint runs via pre-commit.com so the panic logged in the output wasn't even visible. This behavior created a false sense of security when upgrading the golangci-lint version in a build, leading me to believe that the new version was good even though we had taken a step backward in verifying the areas covered by govet. I think golangci-lint should return a nonzero error code.

At

r.Log.Warnf("Can't run linter %s: %v", lc.Linter.Name(), err)
, we can see that panics are logged as a failure to run a linter, but are ultimately ignored for the status code.

Verbose output of running
WARN [linters context] Panic: unusedwrite: package "main" (isInitialPkg: true, needAnalyzeSource: true): interface conversion: interface {} is nil, not *buildssa.SSA: goroutine 20325 [running]:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions