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:
6
pmd/test-data/NullAssignment1.java
Normal file
6
pmd/test-data/NullAssignment1.java
Normal file
@ -0,0 +1,6 @@
|
||||
public class NullAssignment1 {
|
||||
public Object foo() {
|
||||
Object x = null; // OK
|
||||
return x;
|
||||
}
|
||||
}
|
10
pmd/test-data/NullAssignment2.java
Normal file
10
pmd/test-data/NullAssignment2.java
Normal file
@ -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
|
||||
}
|
||||
}
|
8
pmd/test-data/NullAssignment3.java
Normal file
8
pmd/test-data/NullAssignment3.java
Normal file
@ -0,0 +1,8 @@
|
||||
public class NullAssignment3 {
|
||||
public void foo() {
|
||||
Object x;
|
||||
if (x == null) { // This is OK
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user