Super-linter: Invoking golangci-lint run on individual files breaks linters in packages.

Created on 18 Jun 2020  路  17Comments  路  Source: github/super-linter

Describe the bug
When golangci-lint is invoked against a single file, as it is here:

https://github.com/github/super-linter/blob/1e08ff6363cb45c5714b1c30039d896972287173/lib/linter.sh#L1939

This fails to properly lint a package if types are defined in another file.

To Reproduce
Steps to reproduce the behavior:

  1. Create two Go files, main.go and foo.go.
  2. Define Foo in foo.go.
  3. Run golangci-lint run in that package, it lints fine.
  4. Run the super-linter against that package, it fails to lint with: ERROR:[level=warning msg="[runner] Can't run linter unused: buildssa: analysis skipped: errors in package: [/github/workspace/main.go:8:8: undeclared name: Foo]"

See an example run here: https://github.com/RussellRollins/super-lint-error/runs/785695971

Expected behavior
This passes linting without failures.

Screenshots
Screen Shot 2020-06-18 at 3 34 24 PM

Additional context
I can see how the current solution is used to enable the "lint only changed files" feature, but this will fall down for relatively simple Go setups.

bug

Most helpful comment

Still valid!

All 17 comments

We encountered the same issue and this makes SuperLinter with Golang basically unusable.
An option to run the linter on whole directories when VALIDATE_ALL_CODEBASE is True would be extremely helpful

Hi @RussellRollins, I created a PR #370 which aims at fixing this issue. The owners of the repo want to gather some more feedback from other GO developer. If you have some time to spare can you have a look at it and leave your opinion there? Thanks!

This issue has been automatically marked as stale because it has not had recent activity.
It will be closed in 14 days if no further activity occurs.
Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 馃 label or comment on the issue.

Slow your roll bot. This is still valid.

Sorry for the noise. Trying to keep this from getting closed.

still valid; super-linter is totally broken for golang :(

This issue has been automatically marked as stale because it has not had recent activity.
It will be closed in 14 days if no further activity occurs.
Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 馃 label or comment on the issue.

Still valid!

This issue has been automatically marked as stale because it has not had recent activity.
It will be closed in 14 days if no further activity occurs.
Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 馃 label or comment on the issue.

still valid

Related to #888

What would be the workaround besides disabling Super-Linter completely for go? Having the same issue.

This issue has been automatically marked as stale because it has not had recent activity.
It will be closed in 14 days if no further activity occurs.
Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 馃 label or comment on the issue.

Not stale

This issue has been automatically marked as stale because it has not had recent activity.
It will be closed in 14 days if no further activity occurs.
Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 馃 label or comment on the issue.

not stale

This issue has been automatically marked as stale because it has not had recent activity.
It will be closed in 14 days if no further activity occurs.
Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 馃 label or comment on the issue.

not stale

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sergey-muntyanu picture sergey-muntyanu  路  4Comments

jasonkarns picture jasonkarns  路  5Comments

lechen26 picture lechen26  路  5Comments

dshevtsov picture dshevtsov  路  3Comments

bazzadp picture bazzadp  路  3Comments