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

Error information shows "update your build to use at least one Scala compiler option like -Ywarn-unused", but it is already enabled in maven #1536

Closed
tribbloid opened this issue Feb 7, 2022 · 4 comments

Comments

@tribbloid
Copy link

I'm using the command line launch:

$ scalafix --verbose
warning: Name RemoveUnusedImports is deprecated. Use RemoveUnused instead (since 0.6.0)
warning: Name RemoveUnusedTerms is deprecated. Use RemoveUnused instead (since 0.6.0)
error: 2 errors
[E0] The Scala compiler option "-Ywarn-unused" is required to use RemoveUnused.
To fix this problem, update your build to use at least one Scala compiler
option like -Ywarn-unused, -Xlint:unused (2.12.2 or above), or -Wunused (2.13 only)
[E1] The Scala compiler option "-Ywarn-unused" is required to use RemoveUnused.
To fix this problem, update your build to use at least one Scala compiler
option like -Ywarn-unused, -Xlint:unused (2.12.2 or above), or -Wunused (2.13 only)

But -Ywarn-unused is already enabled in maven. Is there an option to correctly identify it?

@bjaglin
Copy link
Collaborator

bjaglin commented Feb 7, 2022

All the scalac options used to compile sources must be passed as arguments when using the CLI (see --scalac-options in https://scalacenter.github.io/scalafix/docs/users/installation.html#help). Partly to check the setup and partly because it is needed (to know the semanticdb locations for example).

Since this can be a hassle, you can try https://github.com/evis/scalafix-maven-plugin if you use maven as build tool. It is a community plugin that allows you to automatically setup scalafix.

@tribbloid
Copy link
Author

that may not be possible, the semanticDB plugin was known to cause problem in our project, but it has to be enabled for a key feature of scalafix we use (optimise imports)

Is there a way to inline it or optimise imports without semanticDB?

@bjaglin
Copy link
Collaborator

bjaglin commented Feb 8, 2022

Semantic rules require semanticdb to run. You can reorganize/sort imports using https://github.com/NeQuissimus/sort-imports or even https://scalameta.org/scalafmt/docs/configuration.html#imports-expand, but semantic information is mandatory if you want more advanced behavior (https://scalacenter.github.io/scalafix/docs/rules/RemoveUnused.html or https://github.com/liancheng/scalafix-organize-imports).

What issue did you face with the semanticdb plugin?

@bjaglin
Copy link
Collaborator

bjaglin commented Feb 9, 2022

Let's follow up on https://github.com/scalameta/scalameta since scalafix works as intended here

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

2 participants