-
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
respect -Xlint or -Xlint:unused scalac options in RemoveUnused rule #1163
Conversation
) | ||
if (!hasWarnUnused) { | ||
Configured.error( | ||
s"""|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 that starts with -Ywarn-unused or -Wunused (2.13 only)""".stripMargin | ||
|option like -Ywarn-unused, -Xlint:unused, or -Wunused (2.13 only).""".stripMargin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't add -Xlint
to suggestions in the error message since -Xlint
is for multi purposes.
630e378
to
555f2d2
Compare
) | ||
if (!hasWarnUnused) { | ||
Configured.error( | ||
s"""|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 that starts with -Ywarn-unused or -Wunused (2.13 only)""".stripMargin | ||
|option like -Ywarn-unused, -Xlint:unused (2.12.2 or above), or -Wunused (2.13 only)""".stripMargin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused warnings by -Xlint
or -Xlint:unused
are effective since Scala 2.12.2.
scala/bug#10270
scala/scala#5402
So suggesting -Xlint:unused
is not relevant in Scala 2.12.1 or lower while Scalafix still supports 2.11 . To be safer, I would clarify which versions are supported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 Thank you!
This PullRequests suppress RemoveUnused configuration error if scalac options contain
-Xlint
or-Xlint:unused
, both of which generate and add unused diagnostics message string into SemanticDB.Note: There might be discussions at the following point.
-Xlint linting options notation
Currently this PullRequest supports no explicit linting option (just
-Xlint
) or only a linting option per a line (-Xlint:unused
) for implementation simplicity. IMHO this covers majority of-Xlint
usage, as long as I check with "-Xlint" GitHub search.This PR does NOT support multiple linting options together like
-Xlint:unused,constant
, wildcard like-Xlint:_
, nor unary operator like-Xlint:-constant,_
.If we want to support multiple linting options notation or else above, it may need to introduce a simple scalac option parser (or just check in a naive way, like
option.startsWith("-Xlint:") && (option.contains("_") || option.contains("unused")) && !option.contains("-unused")
?).