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

Remove Unused depends on -Xmaxwarns on Scala 2.13 #1264

Closed
melezov opened this issue Oct 29, 2020 · 5 comments
Closed

Remove Unused depends on -Xmaxwarns on Scala 2.13 #1264

melezov opened this issue Oct 29, 2020 · 5 comments

Comments

@melezov
Copy link

melezov commented Oct 29, 2020

The Remove Unused Scalafix rule seems to be attached to the -Xmaxwarns scala compiler option.

The documentation of the -Xmaxwarns does not seem to reflect that processing will change, only the presentation of the warnings:

-Xmaxwarns <n> Maximum warnings to print

If the -Xmaxwarns is not set, it defaults to 100.
It means that if the unused imports/code is not within these "printed" warnings, it will not have been processed on Scala 2.13

This is a regression from Scala 2.12.x, where this setting did not seem to affect the scalafix rule execution.

Specific versions I'm referring to: Scala 2.13.3/2.12.12

@mlachkar
Copy link
Collaborator

In fact the rule RemoveUnusued depends on this parameter, but I don't know what we can do to change this behavior.
We can document this setting that impact removeUnusued and all rules that depends on Warn messages.
@bjaglin
1 - Could we modify the default value on the project where the scalafix plugin is enabled , or just during the run of scalafix, as we do for -Xfatal-warning
2- Report as warning in withConfiguration for RemoveUnusued that this value could be increased ?

@bjaglin
Copy link
Collaborator

bjaglin commented Jun 30, 2021

1 - That looks like a good idea indeed to leverage scalacenter/sbt-scalafix#196, although I am not sure what's a good value?
2 - This looks like something #1199 could signal. Since we have the scalacOptions, we know the value of -Xmaxwarns (implicit default or explicit), so provided all warnings are reported as diagnostics in semanticdb, we could even fail the build when we detect that we have exactly as many diagnostics as the maximum number of warns, since there is a good chance we are missing out some.

@mlachkar
Copy link
Collaborator

mlachkar commented Jul 1, 2021

Actually after thinking more seriously about this, semanticdb should not depend on this to record warnings. I m working on a fix on scalemeta side. Those parameters are supposed to change the number of warning or errors printed.

@mlachkar
Copy link
Collaborator

mlachkar commented Jul 1, 2021

linked to scalameta/scalameta#2402

@mlachkar
Copy link
Collaborator

RemoveUnused doesn't depend on Maxwarn anymore!
Thanks for reporting this issue

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

3 participants