-
-
Notifications
You must be signed in to change notification settings - Fork 237
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
Change golangci-lint
lint mode to project
#3509
Conversation
Besides, it looks like the Said that, as an alternative, the solution to this issue might simply be removing |
It seems `list_of_files` is not the right choice as default lint mode for the `golangci-lint` linter, for several reasons. In such mode, the changed `.go` files are sent in a single call to the linter. The first issue with that is that, as the linter [Quick Start](https://golangci-lint.run/welcome/quick-start/) guide explicitly states, files must come from the same package. The second issue is that the linter tries to compile each file via `types.Checker` and, unless the source file is self-contained and has no references to things declared in other source files of the codebase, the compilation will fail, even if the references are towards the same package. Such compilation errors are reported by `golangci-lint` and labeled as `typecheck` (which is not a linter) (see [why do you have `typecheck` errors?](https://golangci-lint.run/welcome/faq/#why-do-you-have-typecheck-errors) section of the documentation). The same problem has also been reported in [`golangci-lint oxsecurity#1574`](golangci/golangci-lint#1574) by an user who configured his editor to run the linter on single files. As commented by a core maintainer [here](golangci/golangci-lint#1574 (comment)) `typecheck` is not included in the "fast" linters list and, therefore, cannot be run on single files.
Mode "list_of_files" is critical to VALIDATE_ALL_CODEBASE=false users, who want to analyze only files updated within a PR Using project mode will be default analyze all go files undepending VALIDATE_ALL_CODEBASE mode, i'm not sure go project users will like it But your argumentation is convincing, can I summarize it by "not using project mode by default with golangci-lint generates crappy results" ? ^^ If so, i'll merge the PR :) |
Actually, I am not convinced it's just about "crappy results", as MegaLinter simply fails. If you feel that setting |
@wandering-tales I never wrote a single line in go, that's why I strongly rely on your opinion :) Is typecheck a relevant rule ? |
And more further on running it on a single file or a group of files:
Said that, I fear the only viable option to make |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wandering-tales I'm convinced by your explanations, thanks for your analysis and the PR :)
Many thanks to you for the quick feedback! |
You can already check with beta version :) |
It doesn't exist anymore. oxsecurity/megalinter#3535 oxsecurity/megalinter#3509
It seems
list_of_files
is not the right choice as default lint mode for thegolangci-lint
linter, for several reasons.In such mode, the changed
.go
files are sent in a single call to the linter.The first issue with that is that, as the linter Quick Start guide explicitly states, files must come from the same package.
The second issue is that the linter tries to compile each file via
types.Checker
and, unless the source file is self-contained and has no references to things declared in other source files of the codebase, the compilation will fail, even if the references are towards the same package.Such compilation errors are reported by
golangci-lint
and labeled astypecheck
(which is not a linter) (see why do you havetypecheck
errors? section of the documentation).The same problem has also been reported in
golangci-lint #1574
by an user who configured his editor to run the linter on single files. As commented by a core maintainer here,typecheck
is not included in the "fast" linters list and, therefore, cannot be run on single files.Proposed Changes
golangci-lint
lint mode toproject
Readiness Checklist
Author/Contributor
Reviewing Maintainer
breaking
if this is a large fundamental changeautomation
,bug
,documentation
,enhancement
,infrastructure
, orperformance