-
Notifications
You must be signed in to change notification settings - Fork 185
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 not working #592
Comments
Do you have scalafix enabled in your "build build"?
|
Hmm nevermind, I thought those warnings are from the build itself, they are from an sbt plugin. |
@avdv can you provide a minimal reproduction? Ideally from the standard library. Is this a regression from 0.5.7? What happens if you run |
Sorry, should have been more specific. Yes, this is from an SBT plugin, but I also tried it in another SBT project. I am using SBT 1.1.0, Scala 2.12.4. The scalacOptions are looking OK and the semanticdb files are generated. |
What happens if you run scalafixCli --rules RemoveUnusedImports? |
Is this a regression from 0.5.7? |
Can you provide a small source file that reproduces the bug? :) |
Hi @olafurpg, I have tried with 0.5.7, but still no dice. I have prepared a fresh SBT project with Also, I had used scalafix downloaded with coursier manually to no avail. But then, I ran SBT with |
OK, seems the culprit is not coursier as suspected, but clippy:
I still do not understand why running scalafix manually did not work either. (I just ran |
Thanks for investigating @avdv Interesting, I suspect there is a bad interplay between the clippy compiler plugin and semanticdb-scalac. RemoveUnusedImports uses the messages reported by the compiler so this bug makes sense if clippy is changing the reporter |
clippy looks btw super cool! Want to try it out 😄 |
Clippy does hijack the reporter and inject new messages but it also leaves the original message so it should be possible to make them play well together. |
thanks @ShaneDelmore, that makes total sense now, I compiled (read: generated the semanticdb's) with clippy on, so running scalafix on the command line later did still not recognize the import errors -- same input -> same output.
Oh yes, I guess I'm so used to its output that I forgot that the messages look different usually... 😉 |
There is not much that could be done by scalafix about this, I think. Should we close this issue? |
@avdv we should add a note about this in the documentation. Maybe open an issue on the clippy side. I'm not sure why we are not being able to consume those errors. |
Yes, I did open an issue here: softwaremill/scala-clippy#61 Somehow clippy does not leave the original message in the semanticdb file. |
The relevant piece of code in scalameta is https://github.com/scalameta/scalameta/blob/2bc7cfd081b45bfbb2e16c60eb906fa208a597cb/semanticdb/scalac/library/src/main/scala/scala/meta/internal/semanticdb/scalac/HijackReporter.scala#L12 We set the reporter to our own custom implementation that records all messages and forwards them to the underlying reporter. The ordering of the compiler plugins may impact if it works or not. You can try |
I'm not sure what can be done on the scalafix side to improve this situation. The bug either needs to be addressed in clippy or semanticdb-scalac. |
Hi.
I am trying to use scalafix 0.5.10 with a SBT project. A quick test with
scalafix ProcedureSyntax
was successful.But running
scalafix RemoveUnusedImports
does not change anything, although the Scala compiler spits out 11 "Unused import" warnings:The imports are still there.
I also tried to run scalafix manually, using the
--stdout
option, but with the same result. The files are printed as they are processed, but still contain the unused imports.Using
--verbose
does not help either. What can I do to debug this?The text was updated successfully, but these errors were encountered: