-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add support for SuggestedFixes #1779
Comments
I'm working on and for now, I'm able to apply suggestions from For the other, the problem is a bit more complex because the fix must be applied on multiple lines. |
I think we need to print the suggested fixes if they are not applied (without |
In some cases, it will be very weird to display the suggestions, because a suggestion can be a |
agree |
we can print a |
@ldez |
I think we can support both as the first step, but I'm thinking about it, I need more time. |
Here is the code of how to apply SuggestedFixes: https://github.com/golang/tools/blob/54dc8c5edb561003330ec7e649333181bbd0a9bd/go/analysis/internal/checker/checker.go#L316 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@ldez I guess this will be the next major feature after the generics issues are fixed? The developer productivity and happiness enabled by just clicking Apply Suggested fixes is quite significant on a Go ecosystem scale. |
This issue is not related to GitHub review suggestions. |
Is there anything that can be done about this on a per-linter basis? In nunnatsa/ginkgolinter#63 (comment) it was pointed out that for some linters, fixing already works. |
I plan to handle the topic by a breaking change, I don't want to introduce several ways to handle fixes. |
Would you discourage and/or reject a PR for a linter specific implementation converting suggested fixes to replacements? I've added support for suggested fixers in a linter that only adds or removes a newline so converting it would be fairly simple. However maybe it's better to spend the time on a generic solution instead? |
I think that it's the right thing for a linter to support For now, it's better to not introduce partial or linter-specific support/converter, this is why the current PRs on the topic are still blocked. |
|
the commit of the change: golang/tools@dbd6001 |
Additional linters that support
It's not clear to me if FYI, until SuggestedFixes for all linters is supported in golangci-lint, you can individually install linters that support SuggestedFixes and run:
While some
The other
|
Is your feature request related to a problem? Please describe.
Add support for SuggestedFixes.
https://github.com/golang/tools/blob/b4639ccb830b1c9602f1c96eba624bbbe20650ea/go/analysis/doc/suggested_fixes.md
Describe the solution you'd like
Be able to apply automatically the fixes via
--fix
.Describe alternatives you've considered
Display the suggestion as extra information.
Additional context
https://github.com/golang/tools/blob/b4639ccb830b1c9602f1c96eba624bbbe20650ea/go/analysis/diagnostic.go#L23-L28
Current linters that support
SuggestedFixes
:goerr113
ruleguard
staticcheck
nlreturn
exportloopref
exhaustive
govet
Related to #1728
The text was updated successfully, but these errors were encountered: