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

x/tools/go/analysis/internal/checker: -fix should remove unneeded imports #72035

Open
adonovan opened this issue Feb 28, 2025 · 1 comment
Open
Assignees
Labels
ToolProposal Issues describing a requested change to a Go tool or command-line program. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@adonovan
Copy link
Member

The -fix flag of each {single,multi}checker tool applies as many fixes as possible without textual conflicts. However, semantic conflicts are still possible. The most common kind of semantic conflict is to leave unused imports in the file. Consider: if a file contains two fixes, each of which removes one use of an import, then each fix is safe to apply in isolation, but when applied together the import becomes unused.

This is sufficiently common that it is worth making the fixer's final step to check for unused imports and remove them, ideally without having to re-typecheck the file.

@gabyhelp
Copy link

Related Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

@gabyhelp gabyhelp added the ToolProposal Issues describing a requested change to a Go tool or command-line program. label Feb 28, 2025
@seankhliao seankhliao changed the title go/analysis/internal/checker: -fix should remove unneeded imports xltools/go/analysis/internal/checker: -fix should remove unneeded imports Feb 28, 2025
@seankhliao seankhliao changed the title xltools/go/analysis/internal/checker: -fix should remove unneeded imports x/tools/go/analysis/internal/checker: -fix should remove unneeded imports Feb 28, 2025
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Feb 28, 2025
@gopherbot gopherbot added this to the Unreleased milestone Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ToolProposal Issues describing a requested change to a Go tool or command-line program. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants