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

-Wunused:imports should specify origin of diagnostic (fully-qualified selector string representation) #21807

Open
som-snytt opened this issue Oct 18, 2024 · 0 comments
Assignees
Labels
area:linting Linting warnings enabled with -W or -Xlint itype:bug

Comments

@som-snytt
Copy link
Contributor

Compiler version

3.5.2

Minimized code

Scala 2 allows suppressing pesky "unused imports" by -Wconf:origin=p.m:s.

That is handy not only to work around false positives but to permit certain imports to go unused rather than deleting and restoring them incidentally. For example, one may wish to import core.Contexts.* everywhere, even if unused; or,

import scala.util.chaining.given

for its occasional utility.

➜  snips cat unused-import.scala

package example

import annotation.*

class C {
}
➜  snips scalac -d /tmp/sandbox -Xsource:3 -Werror -Wunused unused-import.scala
unused-import.scala:4: warning: Unused import
import annotation.*
                  ^
error: No warnings can be incurred under -Werror.
1 warning
1 error
➜  snips scalac -d /tmp/sandbox -Xsource:3 -Werror -Wunused -Wconf:origin=scala.annotation._:s unused-import.scala
➜  snips

Output

The configuration is parsed but not matched.

Expectation

I see the guy promised to add it (see the ticket) but here's another ticket to remind him. Adding origin was this PR and the lint effort he mentions is this other PR. Apparently, he just forgot, because he just tried it to work around this issue and it doesn't work yet.

Maybe also add a cat= category for linting, if it's not too much trouble. Or at least error IDs, etc, as has been requested elsewhere.

@som-snytt som-snytt added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label area:linting Linting warnings enabled with -W or -Xlint and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Oct 18, 2024
@som-snytt som-snytt self-assigned this Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:linting Linting warnings enabled with -W or -Xlint itype:bug
Projects
None yet
Development

No branches or pull requests

1 participant