You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[java] SimplifyConditional: False negative when null check and instanceof are separated by other && conditions #6513
Description:
The SimplifyConditional rule only detects the pattern x != null && x instanceof Type when the null check is directly adjacent to the instanceof expression.
When additional conditions are inserted in the && chain, the rule fails to trigger even though the null check before instanceof remains completely redundant (semantically identical after removal).
This is very common in real-world code, where developers frequently insert additional non-null checks or other conditions in the middle of the && chain .
PMD should report a violation at line 10 with the message:
"No need to check for null before an instanceof"
But currently it only reports the first if, completely missing the second one. This is a false-negative.
Activity
[java] Fix SimplifyConditional false negative when null check and ins…
[java] Fix pmd#6513: SimplifyConditional detects null check separated…
[java] Fix pmd#6513: detect the redundant null check at any position …
[java] Fix pmd#6513: detect the redundant null check at any position …
[java] Fix pmd#6513: dedicated message when the null check alone cann…
[java] Fix pmd#6513: SimplifyConditional detects null check separated…