Test data for the new Null Assignment rule.

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@1284 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
David Dixon-Peugh
2002-12-13 14:46:00 +00:00
parent 3eed10210f
commit 28aa9034b2
3 changed files with 24 additions and 0 deletions

@ -0,0 +1,6 @@
public class NullAssignment1 {
public Object foo() {
Object x = null; // OK
return x;
}
}

@ -0,0 +1,10 @@
public class NullAssignment2 {
public void foo() {
Object x;
x = new Object();
for (int y = 0; y < 10; y++) {
System.err.println(y);
}
x = null; // This is bad
}
}

@ -0,0 +1,8 @@
public class NullAssignment3 {
public void foo() {
Object x;
if (x == null) { // This is OK
return;
}
}
}