mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 11:50:54 +07:00
identical if branches: duplicates should be treated according to their treatment to replace: do not delete if branch with another return value (IDEA-71539)
This commit is contained in:
@@ -176,7 +176,7 @@ public class IfStatementWithIdenticalBranchesInspection
|
||||
return;
|
||||
}
|
||||
final Match match = finder.isDuplicate(branch, true);
|
||||
if (match != null) {
|
||||
if (match != null && match.getReturnValue() == null) {
|
||||
registerStatementError(ifStatement, statement);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package com.siyeh.igtest.controlflow.if_statement_with_identical_branches;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class IfStatementWithIdenticalBranches {
|
||||
|
||||
void one() {
|
||||
@@ -100,3 +104,27 @@ public class IfStatementWithIdenticalBranches {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class NotADup {
|
||||
public String getElementDescription(Object element, Collection location, Dup d, Dup d1) {
|
||||
if (location instanceof List) {
|
||||
if (element instanceof String) {
|
||||
return notNullize(element);
|
||||
}
|
||||
} else if (location instanceof Set) {
|
||||
if (element instanceof String) {
|
||||
return message(element);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String notNullize(Object element) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private String message(String element) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,49 +2,35 @@
|
||||
<problems>
|
||||
<problem>
|
||||
<file>IfStatementWithIdenticalBranches.java</file>
|
||||
<line>6</line>
|
||||
<line>10</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'if' statement with identical branches</problem_class>
|
||||
<description><code>if</code> statement with identical branches #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>IfStatementWithIdenticalBranches.java</file>
|
||||
<line>11</line>
|
||||
<line>15</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'if' statement with identical branches</problem_class>
|
||||
<description><code>if</code> statement with identical branches #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>IfStatementWithIdenticalBranches.java</file>
|
||||
<line>19</line>
|
||||
<line>23</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'if' statement with identical branches</problem_class>
|
||||
<description><code>if</code> statement with identical branches #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>IfStatementWithIdenticalBranches.java</file>
|
||||
<line>40</line>
|
||||
<line>44</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'if' statement with identical branches</problem_class>
|
||||
<description><code>if</code> statement with identical branches #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>IfStatementWithIdenticalBranches.java</file>
|
||||
<line>60</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'if' statement with identical branches</problem_class>
|
||||
<description><code>if</code> statement with identical branches #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>IfStatementWithIdenticalBranches.java</file>
|
||||
<line>92</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'if' statement with identical branches</problem_class>
|
||||
<description><code>if</code> statement with identical branches #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>IfStatementWithIdenticalBranches.java</file>
|
||||
<line>94</line>
|
||||
<line>64</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'if' statement with identical branches</problem_class>
|
||||
<description><code>if</code> statement with identical branches #loc</description>
|
||||
</problem>
|
||||
@@ -55,4 +41,18 @@
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'if' statement with identical branches</problem_class>
|
||||
<description><code>if</code> statement with identical branches #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>IfStatementWithIdenticalBranches.java</file>
|
||||
<line>98</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'if' statement with identical branches</problem_class>
|
||||
<description><code>if</code> statement with identical branches #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>IfStatementWithIdenticalBranches.java</file>
|
||||
<line>100</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'if' statement with identical branches</problem_class>
|
||||
<description><code>if</code> statement with identical branches #loc</description>
|
||||
</problem>
|
||||
</problems>
|
||||
Reference in New Issue
Block a user