[java] Extract reaching definitions analysis out of UnusedAssignmentRule#3311
Conversation
This removes some noisyness that is better caught by unusedPrivateField
This uses the new dataflow and is in theory more precise, but also will report more things.
…-assignment-singular-field-that-kind-of-thing
…-assignment-singular-field-that-kind-of-thing
…ed-assignment-singular-field-that-kind-of-thing
Update AvoidThrowingNullPointerException
…-assignment-singular-field-that-kind-of-thing
…-assignment-singular-field-that-kind-of-thing
…-assignment-singular-field-that-kind-of-thing
Needs use-def chains...
…ngular-field-that-kind-of-thing
…ngular-field-that-kind-of-thing
…ngular-field-that-kind-of-thing
ConsecutiveLiteralAppendsRule mostly
…ngular-field-that-kind-of-thing
…ngular-field-that-kind-of-thing
…ngular-field-that-kind-of-thing
Generated by 🚫 Danger |
…ngular-field-that-kind-of-thing
adangel
left a comment
There was a problem hiding this comment.
Thanks!
At some point, we should create unit tests for the dataflow implementation....
As far as I see, this PR
- fixes #1899
I'll add this to the release notes.
The other referenced missingbreakinswitch bugs are still open, I assume (at least, there are no test cases):
Then there is the renaming of "MissingBreakInSwitch" into "ImplicitSwitchFallThrough" (Problem 2 of #2894).
I'd suggest to make this a separate issue. Then we can rename it already in PMD 6 and remove the deprecated
rule reference in PMD 7.
Ok, I tested them. You've fixed them already. |
|
Thanks for the review. |
oowekyala:java-dfa-reaching-defs-unused-assignment-singular-field-that-kind-of-thing [java] Extract reaching definitions analysis out of UnusedAssignmentRule #3311
Describe the PR
This way the data-flow information it collects can be used by more rules. This reimplements several rules using this information.
SingularField and ImmutableField should be more precise and more general. MissingBreakInSwitch is updated according to #2894, ie, its implementation strategy uses control flow information to detect fall-through, instead of blindly counting breaks. The remaining piece to fix this issue, is to rename the rule to "FallThroughSwitchCase".
Also part of these changes aim to reduce the importance of AbstractLombokAwareRule, by identifying the actual annotations that each rule should care about instead of just ignoring all lombok annotations for all those rules.
Related issues
Updates rules:
Ready?
./mvnw clean verifypasses (checked automatically by github actions)