Commit 82fa8efa authored by Anna.Kozlova's avatar Anna.Kozlova
Browse files

unused assignment: respect report initialization setting in fields (IDEA-183162)

parent 32736f15
Showing with 12 additions and 1 deletion
+12 -1
......@@ -158,7 +158,9 @@ public class DefUseInspectionBase extends AbstractBaseJavaLocalInspectionTool {
for (final FieldWrite fieldWrite : fieldWrites) {
if (wasDefinitelyAssigned) {
if (fieldWrite.isInitializer()) {
reportInitializerProblem(field, holder, isOnTheFly);
if (REPORT_REDUNDANT_INITIALIZER) {
reportInitializerProblem(field, holder, isOnTheFly);
}
}
else {
for (PsiAssignmentExpression assignment : fieldWrite.getAssignments()) {
......
class C {
private String str = null;
}
\ No newline at end of file
......@@ -57,6 +57,12 @@ public class DefUseTest extends LightCodeInsightFixtureTestCase {
public void testNestedTryFinallyInEndlessLoop() { doTest(); }
public void testNestedTryFinallyInForLoop() { doTest(); }
public void testFieldInitializer() { doTest(); }
public void testFieldIgnoringRedundantInitializer() {
DefUseInspection inspection = new DefUseInspection();
inspection.REPORT_REDUNDANT_INITIALIZER = false;
myFixture.enableInspections(inspection);
myFixture.testHighlighting(getTestName(false) + ".java");
}
private void doTest() {
myFixture.enableInspections(new DefUseInspection());
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment