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

Lint Go modules #4984

Merged
merged 10 commits into from
Dec 16, 2023
Merged

Lint Go modules #4984

merged 10 commits into from
Dec 16, 2023

Conversation

ferrarimarco
Copy link
Collaborator

@ferrarimarco ferrarimarco commented Dec 12, 2023

Fixes #3596
Fixes #4430

Proposed Changes

  1. Implement a new mode for the Go linter to run against a directory. This is useful to lint an entire Go project, instead of linting individual files.
  2. Introduce a new variable: VALIDATE_GO_MODULES, defaults to true, to enable the this new mode.
  3. Fail if there are Go modules to lint, and the user enabled both individual Go files linting and Go modules linting because this may cause false positives.

Readiness Checklist

Author/Contributor

  • I included all the needed documentation for this change.
  • I provided the necessary tests.

Reviewing Maintainer

  • Label as breaking if this is a large, fundamental change.
  • Label as either: automation, bug, documentation, enhancement, infrastructure.

BEGIN_COMMIT_OVERRIDE
feat: lint Go modules (#4984)
END_COMMIT_OVERRIDE

@ferrarimarco ferrarimarco added enhancement New feature or request O: backlog 🤖 Backlog, stale ignores this label labels Dec 12, 2023
@ferrarimarco ferrarimarco self-assigned this Dec 12, 2023
@anantdamle
Copy link

anantdamle commented Dec 13, 2023

The variable option is not useful because of following two reasons.
(1) If the repo is a single project, its redundant
(2) If the repo is multi-language project,
(a) the code contributor can conveniently not enable it for their folder
(b) There can be multiple go-lang modules (/directories)

I propose a recursive search for a go.mod file and run it against all those folders.

@ferrarimarco
Copy link
Collaborator Author

ferrarimarco commented Dec 13, 2023

The variable option is not useful because of following two reasons.
(1) If the repo is a single project, its redundant

True. It's still worth having it to maintain backward compatibility with the current behavior.

(2) If the repo is multi-language project, (a) the code contributor can conveniently not enable it for their folder (b) There can be multiple go-lang modules (/directories)

I don't get (a), but (b) is true.

I propose a recursive search for a go.mod file and run it against all those folders.

That's a nice idea. With this, the GO_DIRECTORY variable will not be needed.

@ferrarimarco ferrarimarco marked this pull request as ready for review December 13, 2023 11:19
@ferrarimarco ferrarimarco changed the title Lint Go projects by directory Lint Go modules Dec 13, 2023
README.md Outdated Show resolved Hide resolved
Copy link
Contributor

@zkoppert zkoppert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@ferrarimarco ferrarimarco added this pull request to the merge queue Dec 16, 2023
Merged via the queue into main with commit 3031780 Dec 16, 2023
3 checks passed
@ferrarimarco ferrarimarco deleted the golangci-on-dirs branch December 16, 2023 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request O: backlog 🤖 Backlog, stale ignores this label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support .golangci.yml config file for Golang linter golangci-lint in super-linter produces false positives
3 participants