IDEA-15281 A method/constructor parameter which is written (before read) should be treated as redundant implemented

This commit is contained in:
Danila Ponomarenko
2012-05-18 19:15:24 +04:00
parent 9e1f37939e
commit 2968482da4
23 changed files with 669 additions and 181 deletions
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>Test.java</file>
<line>2</line>
<description>Parameter can be converted to a variable</description>
</problem>
</problems>
@@ -0,0 +1,8 @@
class Temp {
public Temp(int p) {
for (int i = 0; i < 10; i++) {
p = i;
System.out.print(p);
}
}
}
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>Test.java</file>
<line>4</line>
<description>Parameter can be converted to a variable</description>
</problem>
</problems>
@@ -0,0 +1,13 @@
class Temp {
public boolean flag;
void test(int p) {
if (flag) {
p = 1;
}
else {
p = 2;
}
System.out.print(p);
}
}
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>Test.java</file>
<line>3</line>
<description>Parameter can be converted to a variable</description>
</problem>
</problems>
@@ -0,0 +1,7 @@
class Temp {
void test(int p) {
p = 1;
System.out.print(p);
}
}
@@ -0,0 +1,9 @@
// "Convert to local variable" "true"
class Temp {
public Temp() {
for (int i = 0; i < 10; i++) {
<caret>int p = i;
System.out.print(p);
}
}
}
@@ -0,0 +1,15 @@
// "Convert to local variable" "true"
class Temp {
public boolean flag;
void test() {
<caret>int p;
if (flag) {
p = 1;
}
else {
p = 2;
}
System.out.print(p);
}
}
@@ -0,0 +1,8 @@
// "Convert to local variable" "true"
class Temp {
void test() {
<caret>int p = 1;
System.out.print(p);
}
}
@@ -0,0 +1,9 @@
// "Convert to local variable" "true"
class Temp {
public Temp(int <caret>p) {
for (int i = 0; i < 10; i++) {
p = i;
System.out.print(p);
}
}
}
@@ -0,0 +1,14 @@
// "Convert to local variable" "true"
class Temp {
public boolean flag;
void test(int <caret>p) {
if (flag) {
p = 1;
}
else {
p = 2;
}
System.out.print(p);
}
}
@@ -0,0 +1,8 @@
// "Convert to local variable" "true"
class Temp {
void test(int <caret>p) {
p = 1;
System.out.print(p);
}
}