mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 23:39:39 +07:00
DFA: do not report explicit Boolean.TRUE/Boolean.FALSE as always true/false
GitOrigin-RevId: ad6eeba399d80a343ca87fd2fc11539a22331c9e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
01080b23c5
commit
a6e017ef0e
@@ -802,6 +802,16 @@ public abstract class DataFlowInspectionBase extends AbstractBaseJavaLocalInspec
|
||||
// For conditional the root cause (constant condition or both branches constant) should be already reported for branches
|
||||
if (anchor instanceof PsiConditionalExpression) return true;
|
||||
PsiExpression expression = (PsiExpression)anchor;
|
||||
if (expression instanceof PsiReferenceExpression) {
|
||||
PsiReferenceExpression ref = (PsiReferenceExpression)expression;
|
||||
if ("TRUE".equals(ref.getReferenceName()) || "FALSE".equals(ref.getReferenceName())) {
|
||||
PsiElement target = ref.resolve();
|
||||
if (target instanceof PsiField) {
|
||||
PsiClass containingClass = ((PsiField)target).getContainingClass();
|
||||
if (containingClass != null && CommonClassNames.JAVA_LANG_BOOLEAN.equals(containingClass.getQualifiedName())) return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
PsiElement parent = PsiUtil.skipParenthesizedExprUp(expression.getParent());
|
||||
// Don't report "x" in "x == null" as will be anyways reported as "always true"
|
||||
if (parent instanceof PsiBinaryExpression && ExpressionUtils.getValueComparedWithNull((PsiBinaryExpression)parent) != null) return true;
|
||||
|
||||
Reference in New Issue
Block a user