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

Remove unused imports. #239

Merged
merged 2 commits into from
Jun 30, 2017
Merged

Conversation

olafurpg
Copy link
Contributor

I've been delaying this commit for too long hoping to fix it with
scalafix. However, it turns out that we can't yet use scalahost in the
scalafix repo because of scalameta/scalameta#979.

I could not get myself to manually remove the imports so I implemented
instead an sbt plugin called sbt-messagehost that collects reported messages
from the compilerReporter in sbt and writes .semanticdb files. Using
messagehost, I was able to run RemoveUnusedImports on the scalafix
codebase. I suspect messagehost may become popular as a lightweight
alternative to scalahost.

I plan to publish messagehost later, it will not be part of the scalafix
repo.

I've been delaying this commit for too long hoping to fix it with
scalafix. However, it turns out that we can't yet use scalahost in the
scalafix repo because of scalameta/scalameta#979.

I could not get myself to manually remove the imports so I implemented
instead an sbt plugin called sbt-messagehost that collects reported messages
from the compilerReporter in sbt and writes .semanticdb files. Using
messagehost, I was able to run RemoveUnusedImports on the scalafix
codebase. I suspect messagehost may become popular as a lightweight
alternative to scalahost.

I plan to publish messagehost later, it will not be part of the scalafix
repo.
@olafurpg olafurpg merged commit 1729032 into scalacenter:master Jun 30, 2017
@olafurpg olafurpg deleted the remove-imports branch June 30, 2017 17:15
@ShaneDelmore
Copy link
Contributor

This is a great idea. I have been wanting to automate removing unused imports as they are a little annoying to have to keep removing manually but not wanting the full weight of semantic db for a case where the compiler message clearly has the needed information. Love this ❤️

@olafurpg
Copy link
Contributor Author

olafurpg commented Jul 1, 2017

Glad you like the idea @ShaneDelmore I needed to make minor accommodations in RemoveUnusedImport to work with sbt-messagehost's offset positions instead of range positions, but it was not too tricky.

bjaglin pushed a commit to liancheng/scalafix that referenced this pull request May 23, 2023
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.

2 participants