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

Fix a performance regression #995 #998

Merged
merged 3 commits into from
Jun 22, 2024

Conversation

dominiquelefevre
Copy link
Contributor

@dominiquelefevre dominiquelefevre commented Jun 3, 2024

  • Support go workspaces when detecting the go version.
  • Do not invoke go list for every package.

Closes #995

When a module is part of a workspace, a call to `go list -m` lists all
modules in the workspace, and we need to parse multiple modinfos.
@ldez
Copy link
Contributor

ldez commented Jun 3, 2024

I think you should add a better PR title.

I still need a way to fully bypass the Go detection and set a Go version.

@dominiquelefevre
Copy link
Contributor Author

Commit titles and messages contain enough information. If you have a specific PR title in mind, feel free to propose it.

Go version chooses the correct set of warnings to enable, so the version detection is a must.

@ldez
Copy link
Contributor

ldez commented Jun 3, 2024

Commit titles and messages contain enough information. If you have a specific PR title in mind, feel free to propose it.

I suggest: "fix: performance regression"
And add "Fix #995" inside the PR description.

Go version chooses the correct set of warnings to enable, so the version detection is a must.

The Go detection is done inside golangci-lint, golangci-lint doesn't work as revive, so a way to set the Go version is a requirement for us.

@dominiquelefevre dominiquelefevre changed the title Fix #995 Fix a performance regression #995 Jun 3, 2024
@dominiquelefevre
Copy link
Contributor Author

dominiquelefevre commented Jun 3, 2024

The Go detection is done inside golangci-lint, golangci-lint doesn't work as revive, so a way to set the Go version is a requirement for us.

I am not familiar with the way golangci-lint integrates revive and how you intend to use it. Please send patches to add hooks that you need.

@@ -63,16 +63,48 @@ var (
func (l *Linter) Lint(packages [][]string, ruleSet []Rule, config Config) (<-chan Failure, error) {
failures := make(chan Failure)

perModVersions := make(map[string]*goversion.Version)
perPkgVersions := make([]*goversion.Version, len(packages))
for n, files := range packages {
Copy link
Contributor

Choose a reason for hiding this comment

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

🤔 why do you try to detect the Go version per package?
Is it related to sub-modules?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Revive's CLI makes it possible to specify many unrelated directories to lint. In the extreme case, every package may come from a different module. Thus per-package detection.

@ldez
Copy link
Contributor

ldez commented Jun 3, 2024

I am not familiar with the way golangci-lint integrates revive and how you intend to use it.

We need to specify the Go version through this function:

func (l *Linter) Lint(packages [][]string, ruleSet []Rule, config Config) (<-chan Failure, error) {

@dominiquelefevre
Copy link
Contributor Author

Added an option to override the language version detection to struct Config. @ldez, it should fit your description.

@dominiquelefevre
Copy link
Contributor Author

Ping @denisvmedia, @chavacava, @ldez.

@dominiquelefevre
Copy link
Contributor Author

Hey, is this repo alive? Can somebody review the PR? @denisvmedia , @chavacava , @ldez ?

@chavacava
Copy link
Collaborator

Hi @dominiquelefevre, thanks for the PR.
I'm abroad with restricted internet and PC access. I'll check the PR as soon as I'm back home (next weekend)

@chavacava chavacava merged commit 0df1bb0 into mgechev:master Jun 22, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regressions related to 4242f24
3 participants