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

Doesn’t play well with -Ywarn-unused-import. #16

Open
sellout opened this issue Aug 31, 2016 · 7 comments
Open

Doesn’t play well with -Ywarn-unused-import. #16

sellout opened this issue Aug 31, 2016 · 7 comments

Comments

@sellout
Copy link

sellout commented Aug 31, 2016

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.

@rintcius
Copy link

rintcius commented May 12, 2017

@sellout maybe this plugin can help? https://github.com/ghik/silencer (disclaimer: haven't used it myself)

@lihaoyi
Copy link
Member

lihaoyi commented May 12, 2017

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

@lihaoyi
Copy link
Member

lihaoyi commented May 20, 2017

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

@sellout
Copy link
Author

sellout commented May 20, 2017

Yeah, our codebase is far from compliant. We’ll need to add the import one file at a time.

@Daenyth
Copy link
Contributor

Daenyth commented Apr 16, 2020

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

@caoilte
Copy link

caoilte commented Apr 22, 2020

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.

@cornerman
Copy link

cornerman commented Jan 9, 2024

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

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

No branches or pull requests

6 participants