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

RemoveUnusedImports should handle unused import aliases #189

Closed
jonas opened this issue Jun 2, 2017 · 1 comment
Closed

RemoveUnusedImports should handle unused import aliases #189

jonas opened this issue Jun 2, 2017 · 1 comment
Labels
Milestone

Comments

@jonas
Copy link

jonas commented Jun 2, 2017

Scalafix 0.4 doesn't remove unused imports which are aliased:

import scala.collection.mutable.{Set  MutableSet, Map  MutableMap}

The following patch will cause the unused import rewrite test to fail:

diff --git i/scalafix-tests/input/src/main/scala/test/RemoveUnusedImports.scala w/scalafix-tests/input/src/main/scala/test/RemoveUnusedImports.scala
index 9b64c9c..e410565 100644
--- i/scalafix-tests/input/src/main/scala/test/RemoveUnusedImports.scala
+++ w/scalafix-tests/input/src/main/scala/test/RemoveUnusedImports.scala
@@ -11,6 +11,8 @@ import scala.util.{Success => Successful, Random}
 import scala.sys.process._
 import scala.concurrent.{CancellationException, ExecutionException, ExecutionContext}
 import scala.runtime.{RichBoolean}
+import scala.collection.mutable.{Set ⇒ MutableSet, Map ⇒ MutableMap}
+import scala.collection.mutable.{Seq => MutableSeq}
 import scala.concurrent.{ // formatting caveat
   CancellationException,
   ExecutionException,

Observed in sangria-graphql/sangria#250, specifically this line which had to be fixed manually.

@olafurpg
Copy link
Contributor

olafurpg commented Jun 3, 2017

Thank you for reporting! I opened #190 which I believe fixes this bug.

olafurpg added a commit that referenced this issue Jun 3, 2017
Handle Importee.Rename in RemoveUnusedImports, fixes #189
@olafurpg olafurpg modified the milestone: v0.4.1 Jun 7, 2017
bjaglin pushed a commit to liancheng/scalafix that referenced this issue May 23, 2023
Bumps [olafurpg/setup-scala](https://github.com/olafurpg/setup-scala) from 11 to 12.
- [Release notes](https://github.com/olafurpg/setup-scala/releases)
- [Commits](olafurpg/setup-scala@v11...v12)

---
updated-dependencies:
- dependency-name: olafurpg/setup-scala
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants