acyclic
acyclic copied to clipboard
Doesn’t play well with `-Ywarn-unused-import`.
We use -Ywarn-unused-import (and -Xfatal-warnings), and get
Unused import
import acyclic.file
on any file I add it to.
I don’t know of any way to silence an unused import warning (e.g., using @SuppressWarnings), but I’d happily do that if possible.
@sellout maybe this plugin can help? https://github.com/ghik/silencer (disclaimer: haven't used it myself)
One solution would be to make the acyclic plugin remove that import when it sees it. If anyone wants to send a PR doing so, I'll gladly merge it
Or you could use -P:acyclic:force which would remove the need for those imports in the first place, assuming your entire codebase is already compliant
Yeah, our codebase is far from compliant. We’ll need to add the import one file at a time.
If the acyclic imports defined some def workaroundUnusedImportWarning: Unit = () then would that solve the problem? File level imports could then
import acyclic.file
object MyClass {
file.workaroundUnusedImportWarning
Adding -P:acyclic:force doesn't help if you want to prevent package level cycles (an awesome feature by the way).
Silencer is fine for handling this, but I'm curious for why you didn't use annotations instead of an import? That feels like it would read better and be less surprising.
EDIT: annotations were a stupid idea. I see now why you did it this way. You can't put annotations on a package.
If anyone still needs this, you can silence (that is what the s at the end stands for) these warnings with the newish Wconf compiler option:
-Wconf:cat=unused-imports&origin=acyclic\.skipped:s