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

no suggested fixes in analyzer report #146

Closed
SVilgelm opened this issue Mar 5, 2023 · 3 comments · Fixed by #148
Closed

no suggested fixes in analyzer report #146

SVilgelm opened this issue Mar 5, 2023 · 3 comments · Fixed by #148

Comments

@SVilgelm
Copy link
Contributor

SVilgelm commented Mar 5, 2023

Hi, I'm creating my own (yes, one more) linter :) based on the multichecker and import gci as a lib, pkg/analyzer.
Everything works fine, the GCI provides an error message, but it does not provide the suggested fixes, so the files cannot be formatted automatically :-(

Could you please extend the analyzer to include the fixes as well?

Thank you!

What version of GCI are you using?

v0.9.1
@daixiang0
Copy link
Owner

golangci-lint use this to fix, you can learn from it.

@SVilgelm
Copy link
Contributor Author

SVilgelm commented Mar 6, 2023

I know about that approach, but it will not work in my case, I need the suggested fixes.
This sill take much longer, but I will need to create a wrapper on top of the gci analyzer to add the fixes.

@daixiang0
Copy link
Owner

Agree, you need to create a wrapper to get the fixes as golangci-lint does for many other linters.

If you are interested in optimizing it, I am happy to review it. Or I will label as won't fix and close since it is not a common requirement.

Thank you for choosing GCI!

SVilgelm added a commit to SVilgelm/gci that referenced this issue Mar 8, 2023
Added `GetSuggestedFix` function creates unified diff for `unmodifiedFile` and `formattedFile`.
Then analyzes the diff and creates `analysis.SuggestedFix` if needed.

The Analyzer checks the result of `GetSuggestedFix` function and reports as `analysis.Diagnostic`.

Fix daixiang0#146

Signed-off-by: Sergey Vilgelm <sergey@vilgelm.com>
SVilgelm added a commit to SVilgelm/gci that referenced this issue Mar 9, 2023
Added `GetSuggestedFix` function creates unified diff for `unmodifiedFile` and `formattedFile`.
Then analyzes the diff and creates `analysis.SuggestedFix` if needed.

The Analyzer checks the result of `GetSuggestedFix` function and reports as `analysis.Diagnostic`.

Fix daixiang0#146

Signed-off-by: Sergey Vilgelm <sergey@vilgelm.com>
daixiang0 pushed a commit that referenced this issue Mar 9, 2023
Added `GetSuggestedFix` function creates unified diff for `unmodifiedFile` and `formattedFile`.
Then analyzes the diff and creates `analysis.SuggestedFix` if needed.

The Analyzer checks the result of `GetSuggestedFix` function and reports as `analysis.Diagnostic`.

Fix #146

Signed-off-by: Sergey Vilgelm <sergey@vilgelm.com>
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 a pull request may close this issue.

2 participants