Skip to content

CheckAnalyzers doesn't seem to respect exclude or nosec (e.g. G602) #1175

Closed
@imirkin

Description

@imirkin

I'm getting false positives with rule G602 and v2.20.0. I can't seem to find a way of supressing them. Adding to -exclude on the cmdline doesn't work, nor does adding // #nosec G602 comments.

As an aside, the code is fine... it's like

if len(x) == 1 {
  ...
} else if len(x) == 2 {
  if x[0].foo() == bar {
    return Pair{x[0], x[1]}
  } else if x[0].baz() == bar {
    return Pair{x[1], x[0]}
  }
} else {
  ...
}

and it generates errors for each of the 4 lines inside the len(x) == 2 block. But the fact that it's not excludable is most worrying.

Downgrading to v2.17.0 is not an option as I now get a panic when it is built with Go 1.22 (upgrading from Go 1.20).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions