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

Improve -Wunused:locals,privates by tracking use of vars (if set or not) #16639

Closed
PaulCoral opened this issue Jan 9, 2023 · 0 comments · Fixed by #17160
Closed

Improve -Wunused:locals,privates by tracking use of vars (if set or not) #16639

PaulCoral opened this issue Jan 9, 2023 · 0 comments · Fixed by #17160
Labels
area:linting Linting warnings enabled with -W or -Xlint itype:enhancement
Milestone

Comments

@PaulCoral
Copy link
Contributor

In merged PR #16157, -Wunused:locals -Wunused:privates only checks if the definitions are used (read).

As suggested in the mentioned PR, the idea would be to improve these warnings as in Scala 2 -Ywarn-unused:<args> and to track also whether vars are set or not, see this Scala 2 test example.

@prolativ prolativ added itype:enhancement area:reporting Error reporting including formatting, implicit suggestions, etc labels Jan 9, 2023
@jchyb jchyb added area:linting Linting warnings enabled with -W or -Xlint and removed area:reporting Error reporting including formatting, implicit suggestions, etc labels Feb 12, 2023
szymon-rd added a commit that referenced this issue May 16, 2023
…7160)

This PR is related to my Bachelor Semester Project, supervised by
@anatoliykmetyuk.

The latter consist in improving and implementing more Scala 3 linter
options (see #15503), with #16639 as a starting issue fixed in this PR.

- During the traversal in CheckUnused.scala (Miniphase & local
TreeTraverser), when reaching an `Assign` case, symbols are collected as
set, and then used to filter used locals and privates variable at
reporting time.
- Adapt test suit, and Add more test accordingly.
- Note that for a same variable the unused warning always has priority
and shadows the unset warning.

That feature follows the Scala 2 `-Ywarn-unused:<args>` behavior.
@Kordyjan Kordyjan added this to the 3.3.1 milestone Aug 1, 2023
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:enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants