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

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.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 19
  • Comments: 26 (10 by maintainers)

Commits related to this issue

Most upvoted comments

still not stale, but whatever, doesn’t look like it will get any attention

not stale

Still valid!

not stale

Not stale

still valid

not stale, although at this point I’m just going to unsubscribe from the issue.

Best of luck to anyone who still cares about this.