Moved CPD.EOL to PMD.EOL to prevent PMD dependence on CPD
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@2037 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -8,6 +8,7 @@ import net.sourceforge.pmd.ast.ASTReturnStatement;
|
||||
import net.sourceforge.pmd.ast.ASTUnmodifiedClassDeclaration;
|
||||
import net.sourceforge.pmd.ast.SimpleNode;
|
||||
import net.sourceforge.pmd.cpd.CPD;
|
||||
import net.sourceforge.pmd.PMD;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
@ -17,10 +18,10 @@ import java.util.Set;
|
||||
public class SimpleNodeTest extends ParserTst {
|
||||
|
||||
private static final String METHOD_DIFF_LINES =
|
||||
"public class Test {" + CPD.EOL +
|
||||
" public void foo() {" + CPD.EOL +
|
||||
" int x;" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class Test {" + PMD.EOL +
|
||||
" public void foo() {" + PMD.EOL +
|
||||
" int x;" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
public void testMethodDiffLines() throws Throwable {
|
||||
@ -30,8 +31,8 @@ public class SimpleNodeTest extends ParserTst {
|
||||
}
|
||||
|
||||
private static final String METHOD_SAME_LINE =
|
||||
"public class Test {" + CPD.EOL +
|
||||
" public void foo() {}" + CPD.EOL +
|
||||
"public class Test {" + PMD.EOL +
|
||||
" public void foo() {}" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
public void testMethodSameLine() throws Throwable {
|
||||
@ -49,7 +50,7 @@ public class SimpleNodeTest extends ParserTst {
|
||||
}
|
||||
|
||||
private static final String QUALIFIED_NAME =
|
||||
"import java.io.File;" + CPD.EOL +
|
||||
"import java.io.File;" + PMD.EOL +
|
||||
"public class Foo{}";
|
||||
|
||||
public void testNames() throws Throwable {
|
||||
|
@ -8,6 +8,7 @@ import net.sourceforge.pmd.cpd.Match;
|
||||
import net.sourceforge.pmd.cpd.MatchAlgorithm;
|
||||
import net.sourceforge.pmd.cpd.SourceCode;
|
||||
import net.sourceforge.pmd.cpd.Tokens;
|
||||
import net.sourceforge.pmd.PMD;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.util.HashMap;
|
||||
@ -25,11 +26,11 @@ public class MatchAlgorithmTest extends TestCase {
|
||||
|
||||
public static String getSampleCode() {
|
||||
return
|
||||
LINE_1 + CPD.EOL +
|
||||
LINE_2 + CPD.EOL +
|
||||
LINE_3 + CPD.EOL +
|
||||
LINE_4 + CPD.EOL +
|
||||
LINE_5 + CPD.EOL +
|
||||
LINE_1 + PMD.EOL +
|
||||
LINE_2 + PMD.EOL +
|
||||
LINE_3 + PMD.EOL +
|
||||
LINE_4 + PMD.EOL +
|
||||
LINE_5 + PMD.EOL +
|
||||
LINE_6;
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import net.sourceforge.pmd.cpd.CPD;
|
||||
import net.sourceforge.pmd.cpd.JavaTokenizer;
|
||||
import net.sourceforge.pmd.cpd.SourceCode;
|
||||
import net.sourceforge.pmd.cpd.Tokens;
|
||||
import net.sourceforge.pmd.PMD;
|
||||
|
||||
import java.io.StringReader;
|
||||
|
||||
@ -19,6 +20,6 @@ public class SourceCodeTest extends TestCase {
|
||||
|
||||
assertEquals(MatchAlgorithmTest.LINE_1, sourceCode.getSlice(0,0));
|
||||
assertEquals(MatchAlgorithmTest.LINE_2, sourceCode.getSlice(1,1));
|
||||
assertEquals(MatchAlgorithmTest.LINE_1 + CPD.EOL + MatchAlgorithmTest.LINE_2, sourceCode.getSlice(0,1));
|
||||
assertEquals(MatchAlgorithmTest.LINE_1 + PMD.EOL + MatchAlgorithmTest.LINE_2, sourceCode.getSlice(0,1));
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import net.sourceforge.pmd.cpd.Mark;
|
||||
import net.sourceforge.pmd.cpd.Match;
|
||||
import net.sourceforge.pmd.cpd.Renderer;
|
||||
import net.sourceforge.pmd.cpd.XMLRenderer;
|
||||
import net.sourceforge.pmd.PMD;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -32,7 +33,7 @@ public class XMLRendererTest extends TestCase
|
||||
match.setSourceCodeSlice("code fragment");
|
||||
list.add(match);
|
||||
String report = renderer.render(list.iterator());
|
||||
assertEquals("<?xml version=\"1.0\"?><pmd-cpd><duplication lines=\"6\" tokens=\"75\"><file line=\"48\" path=\"/var/Foo.java\"/><file line=\"73\" path=\"/var/Foo.java\"/><codefragment><![CDATA[" + CPD.EOL + "code fragment" + CPD.EOL + "]]></codefragment></duplication></pmd-cpd>", report);
|
||||
assertEquals("<?xml version=\"1.0\"?><pmd-cpd><duplication lines=\"6\" tokens=\"75\"><file line=\"48\" path=\"/var/Foo.java\"/><file line=\"73\" path=\"/var/Foo.java\"/><codefragment><![CDATA[" + PMD.EOL + "code fragment" + PMD.EOL + "]]></codefragment></duplication></pmd-cpd>", report);
|
||||
}
|
||||
|
||||
public void testRender_MultipleMatch()
|
||||
@ -48,7 +49,7 @@ public class XMLRendererTest extends TestCase
|
||||
list.add(match1);
|
||||
list.add(match2);
|
||||
String report = renderer.render(list.iterator());
|
||||
assertEquals("<?xml version=\"1.0\"?><pmd-cpd><duplication lines=\"6\" tokens=\"75\"><file line=\"48\" path=\"/var/Foo.java\"/><file line=\"73\" path=\"/var/Foo.java\"/><codefragment><![CDATA[" + CPD.EOL + "code fragment" + CPD.EOL + "]]></codefragment></duplication><duplication lines=\"7\" tokens=\"76\"><file line=\"49\" path=\"/var/Foo2.java\"/><file line=\"74\" path=\"/var/Foo2.java\"/><codefragment><![CDATA[" + CPD.EOL + "code fragment 2" + CPD.EOL + "]]></codefragment></duplication></pmd-cpd>", report);
|
||||
assertEquals("<?xml version=\"1.0\"?><pmd-cpd><duplication lines=\"6\" tokens=\"75\"><file line=\"48\" path=\"/var/Foo.java\"/><file line=\"73\" path=\"/var/Foo.java\"/><codefragment><![CDATA[" + PMD.EOL + "code fragment" + PMD.EOL + "]]></codefragment></duplication><duplication lines=\"7\" tokens=\"76\"><file line=\"49\" path=\"/var/Foo2.java\"/><file line=\"74\" path=\"/var/Foo2.java\"/><codefragment><![CDATA[" + PMD.EOL + "code fragment 2" + PMD.EOL + "]]></codefragment></duplication></pmd-cpd>", report);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,40 +2,41 @@ package test.net.sourceforge.pmd.rules;
|
||||
|
||||
import net.sourceforge.pmd.cpd.CPD;
|
||||
import net.sourceforge.pmd.rules.AccessorClassGenerationRule;
|
||||
import net.sourceforge.pmd.PMD;
|
||||
|
||||
public class AccessorClassGenerationRuleTest extends RuleTst {
|
||||
|
||||
private static final String TEST1 =
|
||||
"public class Foo1 {" + CPD.EOL +
|
||||
" public class InnerClass {" + CPD.EOL +
|
||||
" private InnerClass(){" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" void method(){" + CPD.EOL +
|
||||
" new InnerClass();//Causes generation of accessor" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class Foo1 {" + PMD.EOL +
|
||||
" public class InnerClass {" + PMD.EOL +
|
||||
" private InnerClass(){" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" void method(){" + PMD.EOL +
|
||||
" new InnerClass();//Causes generation of accessor" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST2 =
|
||||
"public class Foo2 {" + CPD.EOL +
|
||||
" public class InnerClass {" + CPD.EOL +
|
||||
" public InnerClass(){" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" void method(){" + CPD.EOL +
|
||||
" new InnerClass(); //OK, due to public constructor" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class Foo2 {" + PMD.EOL +
|
||||
" public class InnerClass {" + PMD.EOL +
|
||||
" public InnerClass(){" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" void method(){" + PMD.EOL +
|
||||
" new InnerClass(); //OK, due to public constructor" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST3 =
|
||||
"public class Foo3 {" + CPD.EOL +
|
||||
" public class InnerClass {" + CPD.EOL +
|
||||
" void method(){" + CPD.EOL +
|
||||
" new Foo3();//Causes generation of accessor" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" private Foo3(){" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class Foo3 {" + PMD.EOL +
|
||||
" public class InnerClass {" + PMD.EOL +
|
||||
" void method(){" + PMD.EOL +
|
||||
" new Foo3();//Causes generation of accessor" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" private Foo3(){" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
public void testInnerClassHasPrivateConstructor() throws Throwable {
|
||||
|
@ -1,47 +1,48 @@
|
||||
package test.net.sourceforge.pmd.rules;
|
||||
|
||||
import net.sourceforge.pmd.Rule;
|
||||
import net.sourceforge.pmd.PMD;
|
||||
import net.sourceforge.pmd.cpd.CPD;
|
||||
import net.sourceforge.pmd.rules.XPathRule;
|
||||
|
||||
public class AssignmentInOperandRuleTest extends RuleTst {
|
||||
|
||||
private static final String TEST1 =
|
||||
"public class AssignmentInOperand1 {" + CPD.EOL +
|
||||
" public void bar() {" + CPD.EOL +
|
||||
" int x = 2;" + CPD.EOL +
|
||||
" if ((x = getX()) == 3) {" + CPD.EOL +
|
||||
" System.out.println(\"3!\");" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" private int getX() {" + CPD.EOL +
|
||||
" return 3;" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class AssignmentInOperand1 {" + PMD.EOL +
|
||||
" public void bar() {" + PMD.EOL +
|
||||
" int x = 2;" + PMD.EOL +
|
||||
" if ((x = getX()) == 3) {" + PMD.EOL +
|
||||
" System.out.println(\"3!\");" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" private int getX() {" + PMD.EOL +
|
||||
" return 3;" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST2 =
|
||||
"public class AssignmentInOperand2 {" + CPD.EOL +
|
||||
" public void bar() {" + CPD.EOL +
|
||||
" if (false) {}" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class AssignmentInOperand2 {" + PMD.EOL +
|
||||
" public void bar() {" + PMD.EOL +
|
||||
" if (false) {}" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST3 =
|
||||
"public class AssignmentInOperand3 {" + CPD.EOL +
|
||||
" public void bar() {" + CPD.EOL +
|
||||
" if (false) {" + CPD.EOL +
|
||||
" int x =2;" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class AssignmentInOperand3 {" + PMD.EOL +
|
||||
" public void bar() {" + PMD.EOL +
|
||||
" if (false) {" + PMD.EOL +
|
||||
" int x =2;" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST4 =
|
||||
"public class AssignmentInOperand4 {" + CPD.EOL +
|
||||
" public void bar() {" + CPD.EOL +
|
||||
" int x = 2;" + CPD.EOL +
|
||||
" while ( (x = getX()) != 0 ) {}" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" private int getX() {return 2;}" + CPD.EOL +
|
||||
"public class AssignmentInOperand4 {" + PMD.EOL +
|
||||
" public void bar() {" + PMD.EOL +
|
||||
" int x = 2;" + PMD.EOL +
|
||||
" while ( (x = getX()) != 0 ) {}" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" private int getX() {return 2;}" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
|
||||
|
@ -2,29 +2,30 @@ package test.net.sourceforge.pmd.rules;
|
||||
|
||||
import net.sourceforge.pmd.cpd.CPD;
|
||||
import net.sourceforge.pmd.rules.AtLeastOneConstructorRule;
|
||||
import net.sourceforge.pmd.PMD;
|
||||
|
||||
public class AtLeastOneConstructorRuleTest extends RuleTst {
|
||||
|
||||
private static final String TEST1 =
|
||||
"public class AtLeastOneConstructorRule1 {" + CPD.EOL +
|
||||
" public AtLeastOneConstructorRule1() {}" + CPD.EOL +
|
||||
"public class AtLeastOneConstructorRule1 {" + PMD.EOL +
|
||||
" public AtLeastOneConstructorRule1() {}" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST2 =
|
||||
"public class AtLeastOneConstructorRule2 {" + CPD.EOL +
|
||||
"public class AtLeastOneConstructorRule2 {" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST3 =
|
||||
"public class AtLeastOneConstructorRule3 {" + CPD.EOL +
|
||||
" public class Foo {}" + CPD.EOL +
|
||||
" public AtLeastOneConstructorRule3() {}" + CPD.EOL +
|
||||
"public class AtLeastOneConstructorRule3 {" + PMD.EOL +
|
||||
" public class Foo {}" + PMD.EOL +
|
||||
" public AtLeastOneConstructorRule3() {}" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST4 =
|
||||
"public class AtLeastOneConstructorRule4 {" + CPD.EOL +
|
||||
" public class Foo { " + CPD.EOL +
|
||||
" public Foo() {}" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class AtLeastOneConstructorRule4 {" + PMD.EOL +
|
||||
" public class Foo { " + PMD.EOL +
|
||||
" public Foo() {}" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
|
||||
|
@ -1,37 +1,38 @@
|
||||
package test.net.sourceforge.pmd.rules;
|
||||
|
||||
import net.sourceforge.pmd.Rule;
|
||||
import net.sourceforge.pmd.PMD;
|
||||
import net.sourceforge.pmd.cpd.CPD;
|
||||
import net.sourceforge.pmd.rules.AvoidDeeplyNestedIfStmtsRule;
|
||||
|
||||
public class AvoidDeeplyNestedIfStmtsRuleTest extends RuleTst {
|
||||
|
||||
public static final String TEST1 =
|
||||
"public class AvoidDeeplyNestedIfStmtsRule1 {" + CPD.EOL +
|
||||
" public void bar() { " + CPD.EOL +
|
||||
" int x=2; " + CPD.EOL +
|
||||
" int y=3; " + CPD.EOL +
|
||||
" int z=4; " + CPD.EOL +
|
||||
" if (x>y) { " + CPD.EOL +
|
||||
" if (y>z) { " + CPD.EOL +
|
||||
" if (z==x) { " + CPD.EOL +
|
||||
" // this is officially out of control now " + CPD.EOL +
|
||||
" } " + CPD.EOL +
|
||||
" } " + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class AvoidDeeplyNestedIfStmtsRule1 {" + PMD.EOL +
|
||||
" public void bar() { " + PMD.EOL +
|
||||
" int x=2; " + PMD.EOL +
|
||||
" int y=3; " + PMD.EOL +
|
||||
" int z=4; " + PMD.EOL +
|
||||
" if (x>y) { " + PMD.EOL +
|
||||
" if (y>z) { " + PMD.EOL +
|
||||
" if (z==x) { " + PMD.EOL +
|
||||
" // this is officially out of control now " + PMD.EOL +
|
||||
" } " + PMD.EOL +
|
||||
" } " + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
public static final String TEST2 =
|
||||
"public class AvoidDeeplyNestedIfStmtsRule2 {" + CPD.EOL +
|
||||
" public void bar() { " + CPD.EOL +
|
||||
" if (true) {" + CPD.EOL +
|
||||
" } else if (true) {" + CPD.EOL +
|
||||
" } else if (true) {" + CPD.EOL +
|
||||
" } else {" + CPD.EOL +
|
||||
" // this ain't good code, but it shouldn't trigger this rule" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class AvoidDeeplyNestedIfStmtsRule2 {" + PMD.EOL +
|
||||
" public void bar() { " + PMD.EOL +
|
||||
" if (true) {" + PMD.EOL +
|
||||
" } else if (true) {" + PMD.EOL +
|
||||
" } else if (true) {" + PMD.EOL +
|
||||
" } else {" + PMD.EOL +
|
||||
" // this ain't good code, but it shouldn't trigger this rule" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private Rule rule;
|
||||
|
@ -2,31 +2,32 @@ package test.net.sourceforge.pmd.rules;
|
||||
|
||||
import net.sourceforge.pmd.cpd.CPD;
|
||||
import net.sourceforge.pmd.rules.AvoidDuplicateLiteralsRule;
|
||||
import net.sourceforge.pmd.PMD;
|
||||
|
||||
public class AvoidDuplicateLiteralsRuleTest extends RuleTst {
|
||||
|
||||
public static final String TEST1 =
|
||||
"public class Foo {" + CPD.EOL +
|
||||
" private void bar() {" + CPD.EOL +
|
||||
" buz(\"Howdy\");" + CPD.EOL +
|
||||
" buz(\"Howdy\");" + CPD.EOL +
|
||||
" buz(\"Howdy\");" + CPD.EOL +
|
||||
" buz(\"Howdy\");" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" private void buz(String x) {}" + CPD.EOL +
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" private void bar() {" + PMD.EOL +
|
||||
" buz(\"Howdy\");" + PMD.EOL +
|
||||
" buz(\"Howdy\");" + PMD.EOL +
|
||||
" buz(\"Howdy\");" + PMD.EOL +
|
||||
" buz(\"Howdy\");" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" private void buz(String x) {}" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
public static final String TEST2 =
|
||||
"public class Foo {" + CPD.EOL +
|
||||
" private void bar() {" + CPD.EOL +
|
||||
" buz(2);" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" private void buz(int x) {}" + CPD.EOL +
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" private void bar() {" + PMD.EOL +
|
||||
" buz(2);" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" private void buz(int x) {}" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
public static final String TEST3 =
|
||||
"public class Foo {" + CPD.EOL +
|
||||
" private static final String FOO = \"foo\";" + CPD.EOL +
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" private static final String FOO = \"foo\";" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private AvoidDuplicateLiteralsRule rule;
|
||||
|
@ -2,57 +2,58 @@ package test.net.sourceforge.pmd.rules;
|
||||
|
||||
import net.sourceforge.pmd.cpd.CPD;
|
||||
import net.sourceforge.pmd.rules.AvoidReassigningParametersRule;
|
||||
import net.sourceforge.pmd.PMD;
|
||||
|
||||
public class AvoidReassigningParametersRuleTest extends RuleTst {
|
||||
|
||||
public static final String TEST1 =
|
||||
"public class AvoidReassigningParameters1 {" + CPD.EOL +
|
||||
" private void foo(String bar) {" + CPD.EOL +
|
||||
" bar = \"something else\";" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class AvoidReassigningParameters1 {" + PMD.EOL +
|
||||
" private void foo(String bar) {" + PMD.EOL +
|
||||
" bar = \"something else\";" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
public static final String TEST2 =
|
||||
"public class AvoidReassigningParameters2 {" + CPD.EOL +
|
||||
" private void foo(String bar) {}" + CPD.EOL +
|
||||
"public class AvoidReassigningParameters2 {" + PMD.EOL +
|
||||
" private void foo(String bar) {}" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
public static final String TEST3 =
|
||||
"public class AvoidReassigningParameters3 {" + CPD.EOL +
|
||||
" private int bar;" + CPD.EOL +
|
||||
" private void foo(String bar) {" + CPD.EOL +
|
||||
" bar = \"hi\";" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class AvoidReassigningParameters3 {" + PMD.EOL +
|
||||
" private int bar;" + PMD.EOL +
|
||||
" private void foo(String bar) {" + PMD.EOL +
|
||||
" bar = \"hi\";" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
public static final String TEST4 =
|
||||
"public class AvoidReassigningParameters4 {" + CPD.EOL +
|
||||
" private int bar;" + CPD.EOL +
|
||||
" private void foo(String bar) {" + CPD.EOL +
|
||||
" this.bar = \"hi\";" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class AvoidReassigningParameters4 {" + PMD.EOL +
|
||||
" private int bar;" + PMD.EOL +
|
||||
" private void foo(String bar) {" + PMD.EOL +
|
||||
" this.bar = \"hi\";" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
public static final String TEST5 =
|
||||
"public class AvoidReassigningParameters5 {" + CPD.EOL +
|
||||
"" + CPD.EOL +
|
||||
" private class Foo {" + CPD.EOL +
|
||||
" public String bar;" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"" + CPD.EOL +
|
||||
" private void foo(String bar) {" + CPD.EOL +
|
||||
" Foo f = new Foo();" + CPD.EOL +
|
||||
" f.bar = bar;" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class AvoidReassigningParameters5 {" + PMD.EOL +
|
||||
"" + PMD.EOL +
|
||||
" private class Foo {" + PMD.EOL +
|
||||
" public String bar;" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"" + PMD.EOL +
|
||||
" private void foo(String bar) {" + PMD.EOL +
|
||||
" Foo f = new Foo();" + PMD.EOL +
|
||||
" f.bar = bar;" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
public static final String TEST6 =
|
||||
"import java.awt.*;" + CPD.EOL +
|
||||
"" + CPD.EOL +
|
||||
"public class AvoidReassigningParameters6 {" + CPD.EOL +
|
||||
" private void foo(GridBagConstraints gbc) {" + CPD.EOL +
|
||||
" gbc.gridx = 2;" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"import java.awt.*;" + PMD.EOL +
|
||||
"" + PMD.EOL +
|
||||
"public class AvoidReassigningParameters6 {" + PMD.EOL +
|
||||
" private void foo(GridBagConstraints gbc) {" + PMD.EOL +
|
||||
" gbc.gridx = 2;" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private AvoidReassigningParametersRule rule;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package test.net.sourceforge.pmd.rules;
|
||||
|
||||
import net.sourceforge.pmd.Rule;
|
||||
import net.sourceforge.pmd.PMD;
|
||||
import net.sourceforge.pmd.cpd.CPD;
|
||||
import net.sourceforge.pmd.rules.BeanMembersShouldSerializeRule;
|
||||
|
||||
@ -25,43 +26,43 @@ public class BeanMembersShouldSerializeRuleTest extends SimpleAggregatorTst {
|
||||
}
|
||||
|
||||
private static final String TEST1 =
|
||||
"public class Foo {" + CPD.EOL +
|
||||
" private String foo;" + CPD.EOL +
|
||||
" private String bar = foo;" + CPD.EOL +
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" private String foo;" + PMD.EOL +
|
||||
" private String bar = foo;" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST2 =
|
||||
"public class Foo {" + CPD.EOL +
|
||||
" private static String foo;" + CPD.EOL +
|
||||
" private String bar = Foo.foo;" + CPD.EOL +
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" private static String foo;" + PMD.EOL +
|
||||
" private String bar = Foo.foo;" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST3 =
|
||||
"public class Foo {" + CPD.EOL +
|
||||
" private transient String foo;" + CPD.EOL +
|
||||
" private String bar = Foo.foo;" + CPD.EOL +
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" private transient String foo;" + PMD.EOL +
|
||||
" private String bar = Foo.foo;" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST4 =
|
||||
"public class Foo {" + CPD.EOL +
|
||||
" private String foo;" + CPD.EOL +
|
||||
" private String bar = Foo.foo;" + CPD.EOL +
|
||||
" public String getFoo() {return foo;}" + CPD.EOL +
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" private String foo;" + PMD.EOL +
|
||||
" private String bar = Foo.foo;" + PMD.EOL +
|
||||
" public String getFoo() {return foo;}" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST5 =
|
||||
"public class Foo {" + CPD.EOL +
|
||||
" private String foo;" + CPD.EOL +
|
||||
" private String bar = Foo.foo;" + CPD.EOL +
|
||||
" public void setFoo(Foo foo) {this.foo = foo;}" + CPD.EOL +
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" private String foo;" + PMD.EOL +
|
||||
" private String bar = Foo.foo;" + PMD.EOL +
|
||||
" public void setFoo(Foo foo) {this.foo = foo;}" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST6 =
|
||||
"public class Foo {" + CPD.EOL +
|
||||
" private String foo;" + CPD.EOL +
|
||||
" private String bar = Foo.foo;" + CPD.EOL +
|
||||
" public void setFoo(Foo foo) {this.foo = foo;}" + CPD.EOL +
|
||||
" public String getFoo() {return foo;}" + CPD.EOL +
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" private String foo;" + PMD.EOL +
|
||||
" private String bar = Foo.foo;" + PMD.EOL +
|
||||
" public void setFoo(Foo foo) {this.foo = foo;}" + PMD.EOL +
|
||||
" public String getFoo() {return foo;}" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
package test.net.sourceforge.pmd.rules;
|
||||
|
||||
import net.sourceforge.pmd.rules.ClassNamingConventionsRule;
|
||||
|
||||
public class ClassNamingConventionsRuleTest extends SimpleAggregatorTst {
|
||||
|
||||
public void testAll() {
|
||||
runTests(new TestDescriptor[] {
|
||||
new TestDescriptor(TEST1, "class names should not start with lowercase character", 1, new ClassNamingConventionsRule()),
|
||||
new TestDescriptor(TEST2, "class names should not contain underscores", 1, new ClassNamingConventionsRule()),
|
||||
new TestDescriptor(TEST3, "all is well", 0, new ClassNamingConventionsRule()),
|
||||
});
|
||||
}
|
||||
|
||||
private static final String TEST1 =
|
||||
"public class foo {};";
|
||||
|
||||
private static final String TEST2 =
|
||||
"public class foo_bar {};";
|
||||
|
||||
private static final String TEST3 =
|
||||
"public class FooBar {};";
|
||||
|
||||
}
|
@ -2,6 +2,7 @@ package test.net.sourceforge.pmd.rules;
|
||||
|
||||
import net.sourceforge.pmd.cpd.CPD;
|
||||
import net.sourceforge.pmd.rules.ConstructorCallsOverridableMethodRule;
|
||||
import net.sourceforge.pmd.PMD;
|
||||
|
||||
public class ConstructorCallsOverridableMethodRuleTest extends SimpleAggregatorTst {
|
||||
|
||||
@ -18,63 +19,63 @@ public class ConstructorCallsOverridableMethodRuleTest extends SimpleAggregatorT
|
||||
}
|
||||
|
||||
private static final String TEST1 =
|
||||
"public class Foo {" + CPD.EOL +
|
||||
" public Foo() {" + CPD.EOL +
|
||||
" bar();" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" public void bar() {}" + CPD.EOL +
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" public Foo() {" + PMD.EOL +
|
||||
" bar();" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" public void bar() {}" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST2 =
|
||||
"public class Foo {" + CPD.EOL +
|
||||
" public Foo() {" + CPD.EOL +
|
||||
" bar();" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" protected void bar() {}" + CPD.EOL +
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" public Foo() {" + PMD.EOL +
|
||||
" bar();" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" protected void bar() {}" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST3 =
|
||||
"public class Foo {" + CPD.EOL +
|
||||
" public Foo() {" + CPD.EOL +
|
||||
" bar();" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" void bar() {}" + CPD.EOL +
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" public Foo() {" + PMD.EOL +
|
||||
" bar();" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" void bar() {}" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST4 =
|
||||
"public class Foo {" + CPD.EOL +
|
||||
" public Foo() {" + CPD.EOL +
|
||||
" bar();" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" private void bar() {}" + CPD.EOL +
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" public Foo() {" + PMD.EOL +
|
||||
" bar();" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" private void bar() {}" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST5 =
|
||||
"public class Foo {" + CPD.EOL +
|
||||
" public Foo() {" + CPD.EOL +
|
||||
" this(\"Bar\");" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" private Foo(String bar) {" + CPD.EOL +
|
||||
" bar();" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" public void bar() {}" + CPD.EOL +
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" public Foo() {" + PMD.EOL +
|
||||
" this(\"Bar\");" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" private Foo(String bar) {" + PMD.EOL +
|
||||
" bar();" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" public void bar() {}" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST6 =
|
||||
"public class Foo {" + CPD.EOL +
|
||||
" public Foo(String s) {" + CPD.EOL +
|
||||
" \"foo\".equals(s);" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" public void equals(String bar) {}" + CPD.EOL +
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" public Foo(String s) {" + PMD.EOL +
|
||||
" \"foo\".equals(s);" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" public void equals(String bar) {}" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST7 =
|
||||
"public class Foo {" + CPD.EOL +
|
||||
" public Foo(String s) {" + CPD.EOL +
|
||||
" addActionListener(new ActionListener() {" + CPD.EOL +
|
||||
" public void actionPerformed(ActionEvent e) {bar();}" + CPD.EOL +
|
||||
" });" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" public void bar() {}" + CPD.EOL +
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" public Foo(String s) {" + PMD.EOL +
|
||||
" addActionListener(new ActionListener() {" + PMD.EOL +
|
||||
" public void actionPerformed(ActionEvent e) {bar();}" + PMD.EOL +
|
||||
" });" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" public void bar() {}" + PMD.EOL +
|
||||
"}";
|
||||
}
|
||||
|
@ -1,22 +1,23 @@
|
||||
package test.net.sourceforge.pmd.rules;
|
||||
|
||||
import net.sourceforge.pmd.Rule;
|
||||
import net.sourceforge.pmd.PMD;
|
||||
import net.sourceforge.pmd.cpd.CPD;
|
||||
import net.sourceforge.pmd.rules.CouplingBetweenObjectsRule;
|
||||
|
||||
public class CouplingBetweenObjectsRuleTest extends RuleTst {
|
||||
|
||||
private static final String TEST1 =
|
||||
"import java.util.*;" + CPD.EOL +
|
||||
"" + CPD.EOL +
|
||||
"public class CouplingBetweenObjects1 {" + CPD.EOL +
|
||||
" public List foo() {return null;}" + CPD.EOL +
|
||||
" public ArrayList foo() {return null;}" + CPD.EOL +
|
||||
" public Vector foo() {return null;}" + CPD.EOL +
|
||||
"import java.util.*;" + PMD.EOL +
|
||||
"" + PMD.EOL +
|
||||
"public class CouplingBetweenObjects1 {" + PMD.EOL +
|
||||
" public List foo() {return null;}" + PMD.EOL +
|
||||
" public ArrayList foo() {return null;}" + PMD.EOL +
|
||||
" public Vector foo() {return null;}" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST2 =
|
||||
"public class CouplingBetweenObjects2 {" + CPD.EOL +
|
||||
"public class CouplingBetweenObjects2 {" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
|
||||
|
@ -2,6 +2,7 @@ package test.net.sourceforge.pmd.rules;
|
||||
|
||||
import net.sourceforge.pmd.Report;
|
||||
import net.sourceforge.pmd.RuleViolation;
|
||||
import net.sourceforge.pmd.PMD;
|
||||
import net.sourceforge.pmd.cpd.CPD;
|
||||
import net.sourceforge.pmd.rules.CyclomaticComplexityRule;
|
||||
|
||||
@ -50,79 +51,79 @@ public class CyclomaticComplexityRuleTest extends RuleTst {
|
||||
}
|
||||
|
||||
private static final String TEST1 =
|
||||
"public class CyclomaticComplexity1 {" + CPD.EOL +
|
||||
" public void foo() {}" + CPD.EOL +
|
||||
"public class CyclomaticComplexity1 {" + PMD.EOL +
|
||||
" public void foo() {}" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST2 =
|
||||
"public class CyclomaticComplexity2 {" + CPD.EOL +
|
||||
" public void example() {" + CPD.EOL +
|
||||
" int x = 0;" + CPD.EOL +
|
||||
" int a = 0;" + CPD.EOL +
|
||||
" int b = 0;" + CPD.EOL +
|
||||
" int c = 0;" + CPD.EOL +
|
||||
" int d = 0;" + CPD.EOL +
|
||||
" int a1 = 0;" + CPD.EOL +
|
||||
" int a2 = 0;" + CPD.EOL +
|
||||
" int b1 = 0;" + CPD.EOL +
|
||||
" int b2 = 0;" + CPD.EOL +
|
||||
" int z = 0;" + CPD.EOL +
|
||||
" int h = 0;" + CPD.EOL +
|
||||
" int e = 0;" + CPD.EOL +
|
||||
" int f = 0;" + CPD.EOL +
|
||||
"" + CPD.EOL +
|
||||
" if (a == b) {" + CPD.EOL +
|
||||
" if (a1 == b1) {" + CPD.EOL +
|
||||
" x=2;" + CPD.EOL +
|
||||
" } else if (a2 == b2) {" + CPD.EOL +
|
||||
" x=2;" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" else" + CPD.EOL +
|
||||
" {" + CPD.EOL +
|
||||
" x=2;" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" else if (c == d)" + CPD.EOL +
|
||||
" {" + CPD.EOL +
|
||||
" while (c == d)" + CPD.EOL +
|
||||
" {" + CPD.EOL +
|
||||
" x=2;" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" else if (e == f)" + CPD.EOL +
|
||||
" {" + CPD.EOL +
|
||||
" for (int n = 0; n < h; n++)" + CPD.EOL +
|
||||
" {" + CPD.EOL +
|
||||
" x=2;" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" else" + CPD.EOL +
|
||||
" {" + CPD.EOL +
|
||||
" switch (z)" + CPD.EOL +
|
||||
" {" + CPD.EOL +
|
||||
" case 1:" + CPD.EOL +
|
||||
" x=2;" + CPD.EOL +
|
||||
" break;" + CPD.EOL +
|
||||
"" + CPD.EOL +
|
||||
" case 2:" + CPD.EOL +
|
||||
" x=2;" + CPD.EOL +
|
||||
" break;" + CPD.EOL +
|
||||
"" + CPD.EOL +
|
||||
" case 3:" + CPD.EOL +
|
||||
" x=2;" + CPD.EOL +
|
||||
" break;" + CPD.EOL +
|
||||
"" + CPD.EOL +
|
||||
" default:" + CPD.EOL +
|
||||
" x=2;" + CPD.EOL +
|
||||
" break;" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class CyclomaticComplexity2 {" + PMD.EOL +
|
||||
" public void example() {" + PMD.EOL +
|
||||
" int x = 0;" + PMD.EOL +
|
||||
" int a = 0;" + PMD.EOL +
|
||||
" int b = 0;" + PMD.EOL +
|
||||
" int c = 0;" + PMD.EOL +
|
||||
" int d = 0;" + PMD.EOL +
|
||||
" int a1 = 0;" + PMD.EOL +
|
||||
" int a2 = 0;" + PMD.EOL +
|
||||
" int b1 = 0;" + PMD.EOL +
|
||||
" int b2 = 0;" + PMD.EOL +
|
||||
" int z = 0;" + PMD.EOL +
|
||||
" int h = 0;" + PMD.EOL +
|
||||
" int e = 0;" + PMD.EOL +
|
||||
" int f = 0;" + PMD.EOL +
|
||||
"" + PMD.EOL +
|
||||
" if (a == b) {" + PMD.EOL +
|
||||
" if (a1 == b1) {" + PMD.EOL +
|
||||
" x=2;" + PMD.EOL +
|
||||
" } else if (a2 == b2) {" + PMD.EOL +
|
||||
" x=2;" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" else" + PMD.EOL +
|
||||
" {" + PMD.EOL +
|
||||
" x=2;" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" else if (c == d)" + PMD.EOL +
|
||||
" {" + PMD.EOL +
|
||||
" while (c == d)" + PMD.EOL +
|
||||
" {" + PMD.EOL +
|
||||
" x=2;" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" else if (e == f)" + PMD.EOL +
|
||||
" {" + PMD.EOL +
|
||||
" for (int n = 0; n < h; n++)" + PMD.EOL +
|
||||
" {" + PMD.EOL +
|
||||
" x=2;" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" else" + PMD.EOL +
|
||||
" {" + PMD.EOL +
|
||||
" switch (z)" + PMD.EOL +
|
||||
" {" + PMD.EOL +
|
||||
" case 1:" + PMD.EOL +
|
||||
" x=2;" + PMD.EOL +
|
||||
" break;" + PMD.EOL +
|
||||
"" + PMD.EOL +
|
||||
" case 2:" + PMD.EOL +
|
||||
" x=2;" + PMD.EOL +
|
||||
" break;" + PMD.EOL +
|
||||
"" + PMD.EOL +
|
||||
" case 3:" + PMD.EOL +
|
||||
" x=2;" + PMD.EOL +
|
||||
" break;" + PMD.EOL +
|
||||
"" + PMD.EOL +
|
||||
" default:" + PMD.EOL +
|
||||
" x=2;" + PMD.EOL +
|
||||
" break;" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST3 =
|
||||
"public class CyclomaticComplexity3 {" + CPD.EOL +
|
||||
" public CyclomaticComplexity3() {}" + CPD.EOL +
|
||||
"public class CyclomaticComplexity3 {" + PMD.EOL +
|
||||
" public CyclomaticComplexity3() {}" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package test.net.sourceforge.pmd.rules;
|
||||
|
||||
import net.sourceforge.pmd.Rule;
|
||||
import net.sourceforge.pmd.PMD;
|
||||
import net.sourceforge.pmd.cpd.CPD;
|
||||
import net.sourceforge.pmd.rules.XPathRule;
|
||||
|
||||
@ -25,19 +26,19 @@ public class DontImportJavaLangRuleTest extends SimpleAggregatorTst {
|
||||
}
|
||||
|
||||
private static final String TEST1 =
|
||||
"import java.lang.String;" + CPD.EOL +
|
||||
"" + CPD.EOL +
|
||||
"import java.lang.String;" + PMD.EOL +
|
||||
"" + PMD.EOL +
|
||||
"public class DontImportJavaLang1 {}";
|
||||
|
||||
private static final String TEST2 =
|
||||
"import java.lang.*;" + CPD.EOL +
|
||||
"" + CPD.EOL +
|
||||
"import java.lang.*;" + PMD.EOL +
|
||||
"" + PMD.EOL +
|
||||
"public class DontImportJavaLang2 {}";
|
||||
|
||||
private static final String TEST3 =
|
||||
"import java.lang.ref.*;" + CPD.EOL +
|
||||
"import java.lang.reflect.*;" + CPD.EOL +
|
||||
"" + CPD.EOL +
|
||||
"import java.lang.ref.*;" + PMD.EOL +
|
||||
"import java.lang.reflect.*;" + PMD.EOL +
|
||||
"" + PMD.EOL +
|
||||
"public class DontImportJavaLang3 {}";
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package test.net.sourceforge.pmd.rules;
|
||||
|
||||
import net.sourceforge.pmd.cpd.CPD;
|
||||
import net.sourceforge.pmd.rules.DoubleCheckedLockingRule;
|
||||
import net.sourceforge.pmd.PMD;
|
||||
|
||||
public class DoubleCheckedLockingRuleTest extends SimpleAggregatorTst {
|
||||
|
||||
@ -14,27 +15,27 @@ public class DoubleCheckedLockingRuleTest extends SimpleAggregatorTst {
|
||||
}
|
||||
|
||||
private static final String TEST1 =
|
||||
"public class DoubleCheckedLockingRule1 {" + CPD.EOL +
|
||||
" public void foo() {}" + CPD.EOL +
|
||||
"public class DoubleCheckedLockingRule1 {" + PMD.EOL +
|
||||
" public void foo() {}" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST2 =
|
||||
"public class DoubleCheckedLockingRule2 {" + CPD.EOL +
|
||||
" Object baz;" + CPD.EOL +
|
||||
" Object bar() {" + CPD.EOL +
|
||||
" if(baz == null) { //baz may be non-null yet not fully created" + CPD.EOL +
|
||||
" synchronized(this){" + CPD.EOL +
|
||||
" if(baz == null){" + CPD.EOL +
|
||||
" baz = new Object();" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" return baz;" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class DoubleCheckedLockingRule2 {" + PMD.EOL +
|
||||
" Object baz;" + PMD.EOL +
|
||||
" Object bar() {" + PMD.EOL +
|
||||
" if(baz == null) { //baz may be non-null yet not fully created" + PMD.EOL +
|
||||
" synchronized(this){" + PMD.EOL +
|
||||
" if(baz == null){" + PMD.EOL +
|
||||
" baz = new Object();" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" return baz;" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST3 =
|
||||
"public interface DoubleCheckedLockingRule3 {" + CPD.EOL +
|
||||
" void foo();" + CPD.EOL +
|
||||
"public interface DoubleCheckedLockingRule3 {" + PMD.EOL +
|
||||
" void foo();" + PMD.EOL +
|
||||
"}";
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package test.net.sourceforge.pmd.rules;
|
||||
|
||||
import net.sourceforge.pmd.cpd.CPD;
|
||||
import net.sourceforge.pmd.rules.DuplicateImportsRule;
|
||||
import net.sourceforge.pmd.PMD;
|
||||
|
||||
public class DuplicateImportsRuleTest extends SimpleAggregatorTst {
|
||||
|
||||
@ -22,26 +23,26 @@ public class DuplicateImportsRuleTest extends SimpleAggregatorTst {
|
||||
}
|
||||
|
||||
private static final String TEST1 =
|
||||
"import java.io.File;" + CPD.EOL +
|
||||
"import java.util.*;" + CPD.EOL +
|
||||
"import java.io.File;" + CPD.EOL +
|
||||
"import java.io.File;" + PMD.EOL +
|
||||
"import java.util.*;" + PMD.EOL +
|
||||
"import java.io.File;" + PMD.EOL +
|
||||
"public class DuplicateImports {}";
|
||||
|
||||
private static final String TEST2 =
|
||||
"import java.io.*;" + CPD.EOL +
|
||||
"import java.io.*;" + CPD.EOL +
|
||||
"import java.io.*;" + PMD.EOL +
|
||||
"import java.io.*;" + PMD.EOL +
|
||||
"public class DuplicateImports2 {}";
|
||||
|
||||
private static final String TEST3 =
|
||||
"import java.util.*;" + CPD.EOL +
|
||||
"import java.net.*;" + CPD.EOL +
|
||||
"import java.io.*;" + CPD.EOL +
|
||||
"import java.io.File;" + CPD.EOL +
|
||||
"import java.util.*;" + PMD.EOL +
|
||||
"import java.net.*;" + PMD.EOL +
|
||||
"import java.io.*;" + PMD.EOL +
|
||||
"import java.io.File;" + PMD.EOL +
|
||||
"public class DuplicateImports3 {}";
|
||||
|
||||
private static final String TEST4 =
|
||||
"import javax.servlet.*;" + CPD.EOL +
|
||||
"import javax.servlet.http.*;" + CPD.EOL +
|
||||
"import javax.servlet.*;" + PMD.EOL +
|
||||
"import javax.servlet.http.*;" + PMD.EOL +
|
||||
"public class DuplicateImports4 {}";
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package test.net.sourceforge.pmd.rules;
|
||||
|
||||
import net.sourceforge.pmd.Rule;
|
||||
import net.sourceforge.pmd.PMD;
|
||||
import net.sourceforge.pmd.cpd.CPD;
|
||||
import net.sourceforge.pmd.rules.XPathRule;
|
||||
|
||||
@ -32,75 +33,75 @@ public class EmptyCatchBlockRuleTest extends SimpleAggregatorTst {
|
||||
}
|
||||
|
||||
public static final String TEST1 =
|
||||
"import java.io.*;" + CPD.EOL +
|
||||
"public class Foo {" + CPD.EOL +
|
||||
" public Foo() {" + CPD.EOL +
|
||||
" try {" + CPD.EOL +
|
||||
" FileReader fr = new FileReader(\"/dev/null\");" + CPD.EOL +
|
||||
" } catch (Exception e) {}" + CPD.EOL +
|
||||
" try {" + CPD.EOL +
|
||||
" FileReader fr = new FileReader(\"/dev/null\");" + CPD.EOL +
|
||||
" } catch (Exception e) {" + CPD.EOL +
|
||||
" e.printStackTrace();" + CPD.EOL +
|
||||
" // this shouldn't show up on the report" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"import java.io.*;" + PMD.EOL +
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" public Foo() {" + PMD.EOL +
|
||||
" try {" + PMD.EOL +
|
||||
" FileReader fr = new FileReader(\"/dev/null\");" + PMD.EOL +
|
||||
" } catch (Exception e) {}" + PMD.EOL +
|
||||
" try {" + PMD.EOL +
|
||||
" FileReader fr = new FileReader(\"/dev/null\");" + PMD.EOL +
|
||||
" } catch (Exception e) {" + PMD.EOL +
|
||||
" e.printStackTrace();" + PMD.EOL +
|
||||
" // this shouldn't show up on the report" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST2 =
|
||||
"public class Foo {" + CPD.EOL +
|
||||
" public Foo() {" + CPD.EOL +
|
||||
" try {" + CPD.EOL +
|
||||
" } catch (RuntimeException e) {e.getMessage();}" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" public Foo() {" + PMD.EOL +
|
||||
" try {" + PMD.EOL +
|
||||
" } catch (RuntimeException e) {e.getMessage();}" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST3 =
|
||||
"public class Foo {" + CPD.EOL +
|
||||
" private void foo() {" + CPD.EOL +
|
||||
" try {" + CPD.EOL +
|
||||
" } finally {" + CPD.EOL +
|
||||
" try {" + CPD.EOL +
|
||||
" int x =2;" + CPD.EOL +
|
||||
" } catch (Exception e) {}" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" private void foo() {" + PMD.EOL +
|
||||
" try {" + PMD.EOL +
|
||||
" } finally {" + PMD.EOL +
|
||||
" try {" + PMD.EOL +
|
||||
" int x =2;" + PMD.EOL +
|
||||
" } catch (Exception e) {}" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST4 =
|
||||
"public class Foo {" + CPD.EOL +
|
||||
" private void foo() {" + CPD.EOL +
|
||||
" try {" + CPD.EOL +
|
||||
" } catch (Exception e) {" + CPD.EOL +
|
||||
" } catch (Throwable t) {" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" private void foo() {" + PMD.EOL +
|
||||
" try {" + PMD.EOL +
|
||||
" } catch (Exception e) {" + PMD.EOL +
|
||||
" } catch (Throwable t) {" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST5 =
|
||||
"public class Foo {" + CPD.EOL +
|
||||
" public void foo() {" + CPD.EOL +
|
||||
" try {" + CPD.EOL +
|
||||
" } catch (Exception e) {" + CPD.EOL +
|
||||
" blah.blah();" + CPD.EOL +
|
||||
" } finally {}" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" public void foo() {" + PMD.EOL +
|
||||
" try {" + PMD.EOL +
|
||||
" } catch (Exception e) {" + PMD.EOL +
|
||||
" blah.blah();" + PMD.EOL +
|
||||
" } finally {}" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST6 =
|
||||
"public class Foo {" + CPD.EOL +
|
||||
" public void foo() {" + CPD.EOL +
|
||||
" try {" + CPD.EOL +
|
||||
" } catch (InterruptedException e) {}" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" public void foo() {" + PMD.EOL +
|
||||
" try {" + PMD.EOL +
|
||||
" } catch (InterruptedException e) {}" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST7 =
|
||||
"public class Foo {" + CPD.EOL +
|
||||
" public void foo() {" + CPD.EOL +
|
||||
" try {" + CPD.EOL +
|
||||
" } catch (CloneNotSupportedException e) {}" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" public void foo() {" + PMD.EOL +
|
||||
" try {" + PMD.EOL +
|
||||
" } catch (CloneNotSupportedException e) {}" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package test.net.sourceforge.pmd.rules;
|
||||
|
||||
import net.sourceforge.pmd.Rule;
|
||||
import net.sourceforge.pmd.PMD;
|
||||
import net.sourceforge.pmd.cpd.CPD;
|
||||
import net.sourceforge.pmd.rules.XPathRule;
|
||||
|
||||
@ -25,39 +26,39 @@ public class EmptyFinallyBlockRuleTest extends SimpleAggregatorTst {
|
||||
}
|
||||
|
||||
private static final String TEST1 =
|
||||
"public class EmptyFinallyBlock1 {" + CPD.EOL +
|
||||
" public void foo() {" + CPD.EOL +
|
||||
" try {" + CPD.EOL +
|
||||
" } catch (Exception e) {} finally {}" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class EmptyFinallyBlock1 {" + PMD.EOL +
|
||||
" public void foo() {" + PMD.EOL +
|
||||
" try {" + PMD.EOL +
|
||||
" } catch (Exception e) {} finally {}" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST2 =
|
||||
"public class EmptyFinallyBlock2 {" + CPD.EOL +
|
||||
" public void foo() {" + CPD.EOL +
|
||||
" try {" + CPD.EOL +
|
||||
" } finally {}" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class EmptyFinallyBlock2 {" + PMD.EOL +
|
||||
" public void foo() {" + PMD.EOL +
|
||||
" try {" + PMD.EOL +
|
||||
" } finally {}" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST3 =
|
||||
"public class EmptyFinallyBlock3 {" + CPD.EOL +
|
||||
" public void foo() {" + CPD.EOL +
|
||||
" try {" + CPD.EOL +
|
||||
" } finally {int x =2;}" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class EmptyFinallyBlock3 {" + PMD.EOL +
|
||||
" public void foo() {" + PMD.EOL +
|
||||
" try {" + PMD.EOL +
|
||||
" } finally {int x =2;}" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST4 =
|
||||
"public class EmptyFinallyBlock4 {" + CPD.EOL +
|
||||
" public void foo() {" + CPD.EOL +
|
||||
" try {" + CPD.EOL +
|
||||
" } catch (IOException e ){" + CPD.EOL +
|
||||
" } catch (Exception e ) {" + CPD.EOL +
|
||||
" } catch (Throwable t ) {" + CPD.EOL +
|
||||
" } finally{" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class EmptyFinallyBlock4 {" + PMD.EOL +
|
||||
" public void foo() {" + PMD.EOL +
|
||||
" try {" + PMD.EOL +
|
||||
" } catch (IOException e ){" + PMD.EOL +
|
||||
" } catch (Exception e ) {" + PMD.EOL +
|
||||
" } catch (Throwable t ) {" + PMD.EOL +
|
||||
" } finally{" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package test.net.sourceforge.pmd.rules;
|
||||
|
||||
import net.sourceforge.pmd.Rule;
|
||||
import net.sourceforge.pmd.PMD;
|
||||
import net.sourceforge.pmd.cpd.CPD;
|
||||
import net.sourceforge.pmd.rules.XPathRule;
|
||||
|
||||
@ -20,14 +21,14 @@ public class EmptyIfStmtRuleTest extends SimpleAggregatorTst {
|
||||
}
|
||||
|
||||
private static final String TEST1 =
|
||||
"public class EmptyIfStmtRule {" + CPD.EOL +
|
||||
" public EmptyIfStmtRule() {" + CPD.EOL +
|
||||
" if (null == null) {" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" if (null != null) {" + CPD.EOL +
|
||||
" this.toString();" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class EmptyIfStmtRule {" + PMD.EOL +
|
||||
" public EmptyIfStmtRule() {" + PMD.EOL +
|
||||
" if (null == null) {" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" if (null != null) {" + PMD.EOL +
|
||||
" this.toString();" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package test.net.sourceforge.pmd.rules;
|
||||
|
||||
import net.sourceforge.pmd.Rule;
|
||||
import net.sourceforge.pmd.PMD;
|
||||
import net.sourceforge.pmd.cpd.CPD;
|
||||
import net.sourceforge.pmd.rules.XPathRule;
|
||||
|
||||
@ -21,21 +22,21 @@ public class EmptySwitchStmtRuleTest extends SimpleAggregatorTst {
|
||||
}
|
||||
|
||||
private static final String TEST1 =
|
||||
"public class EmptySwitchStmt1 {" + CPD.EOL +
|
||||
" public void bar() {" + CPD.EOL +
|
||||
" int x = 2;" + CPD.EOL +
|
||||
" switch (x) {}" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class EmptySwitchStmt1 {" + PMD.EOL +
|
||||
" public void bar() {" + PMD.EOL +
|
||||
" int x = 2;" + PMD.EOL +
|
||||
" switch (x) {}" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST2 =
|
||||
"public class EmptySwitchStmt2 {" + CPD.EOL +
|
||||
" public void bar() {" + CPD.EOL +
|
||||
" int x = 2;" + CPD.EOL +
|
||||
" switch (x) {" + CPD.EOL +
|
||||
" case 2: int y=4;" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class EmptySwitchStmt2 {" + PMD.EOL +
|
||||
" public void bar() {" + PMD.EOL +
|
||||
" int x = 2;" + PMD.EOL +
|
||||
" switch (x) {" + PMD.EOL +
|
||||
" case 2: int y=4;" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package test.net.sourceforge.pmd.rules;
|
||||
|
||||
import net.sourceforge.pmd.Rule;
|
||||
import net.sourceforge.pmd.PMD;
|
||||
import net.sourceforge.pmd.cpd.CPD;
|
||||
import net.sourceforge.pmd.rules.XPathRule;
|
||||
|
||||
@ -22,34 +23,34 @@ public class EmptyTryBlockRuleTest extends SimpleAggregatorTst {
|
||||
}
|
||||
|
||||
private static final String TEST1 =
|
||||
"public class EmptyTryBlock1 {" + CPD.EOL +
|
||||
" public void foo() {" + CPD.EOL +
|
||||
" try {" + CPD.EOL +
|
||||
" } catch (Exception e) {" + CPD.EOL +
|
||||
" e.printStackTrace();" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class EmptyTryBlock1 {" + PMD.EOL +
|
||||
" public void foo() {" + PMD.EOL +
|
||||
" try {" + PMD.EOL +
|
||||
" } catch (Exception e) {" + PMD.EOL +
|
||||
" e.printStackTrace();" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST2 =
|
||||
"public class EmptyTryBlock2 {" + CPD.EOL +
|
||||
" public void foo() {" + CPD.EOL +
|
||||
" try {" + CPD.EOL +
|
||||
" } finally {" + CPD.EOL +
|
||||
" int x = 5;" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class EmptyTryBlock2 {" + PMD.EOL +
|
||||
" public void foo() {" + PMD.EOL +
|
||||
" try {" + PMD.EOL +
|
||||
" } finally {" + PMD.EOL +
|
||||
" int x = 5;" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST3 =
|
||||
"public class EmptyTryBlock3 {" + CPD.EOL +
|
||||
" public void foo() {" + CPD.EOL +
|
||||
" try {" + CPD.EOL +
|
||||
" int f =2;" + CPD.EOL +
|
||||
" } finally {" + CPD.EOL +
|
||||
" int x = 5;" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class EmptyTryBlock3 {" + PMD.EOL +
|
||||
" public void foo() {" + PMD.EOL +
|
||||
" try {" + PMD.EOL +
|
||||
" int f =2;" + PMD.EOL +
|
||||
" } finally {" + PMD.EOL +
|
||||
" int x = 5;" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package test.net.sourceforge.pmd.rules;
|
||||
|
||||
import net.sourceforge.pmd.Rule;
|
||||
import net.sourceforge.pmd.PMD;
|
||||
import net.sourceforge.pmd.cpd.CPD;
|
||||
import net.sourceforge.pmd.rules.XPathRule;
|
||||
|
||||
@ -20,14 +21,14 @@ public class EmptyWhileStmtRuleTest extends SimpleAggregatorTst {
|
||||
}
|
||||
|
||||
private static final String TEST1 =
|
||||
"public class Foo {" + CPD.EOL +
|
||||
" public void bar() {" + CPD.EOL +
|
||||
" while (true == true) {" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" while (true == true) {" + CPD.EOL +
|
||||
" String x = \"\";" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" public void bar() {" + PMD.EOL +
|
||||
" while (true == true) {" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" while (true == true) {" + PMD.EOL +
|
||||
" String x = \"\";" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package test.net.sourceforge.pmd.rules;
|
||||
|
||||
import net.sourceforge.pmd.Rule;
|
||||
import net.sourceforge.pmd.PMD;
|
||||
import net.sourceforge.pmd.cpd.CPD;
|
||||
import net.sourceforge.pmd.rules.ExcessiveImportsRule;
|
||||
|
||||
@ -21,16 +22,16 @@ public class ExcessiveImportsRuleTest extends SimpleAggregatorTst {
|
||||
}
|
||||
|
||||
private static final String TEST1 =
|
||||
"import java.util.Vector;" + CPD.EOL +
|
||||
"import java.util.Vector;" + CPD.EOL +
|
||||
"import java.util.Vector;" + CPD.EOL +
|
||||
"import java.util.Vector;" + CPD.EOL +
|
||||
"import java.util.Vector;" + CPD.EOL +
|
||||
"import java.util.Vector;" + CPD.EOL +
|
||||
"import java.util.Vector;" + PMD.EOL +
|
||||
"import java.util.Vector;" + PMD.EOL +
|
||||
"import java.util.Vector;" + PMD.EOL +
|
||||
"import java.util.Vector;" + PMD.EOL +
|
||||
"import java.util.Vector;" + PMD.EOL +
|
||||
"import java.util.Vector;" + PMD.EOL +
|
||||
"public class Foo{}";
|
||||
|
||||
private static final String TEST2 =
|
||||
"import java.util.Vector;" + CPD.EOL +
|
||||
"import java.util.Vector;" + PMD.EOL +
|
||||
"public class Foo{}";
|
||||
|
||||
|
||||
|
@ -2,6 +2,7 @@ package test.net.sourceforge.pmd.rules;
|
||||
|
||||
import net.sourceforge.pmd.cpd.CPD;
|
||||
import net.sourceforge.pmd.rules.ExcessivePublicCountRule;
|
||||
import net.sourceforge.pmd.PMD;
|
||||
|
||||
public class ExcessivePublicCountRuleTest extends RuleTst {
|
||||
|
||||
@ -22,16 +23,16 @@ public class ExcessivePublicCountRuleTest extends RuleTst {
|
||||
}
|
||||
|
||||
private static final String TEST1 =
|
||||
"public class ExcessivePublicCountRule1 {" + CPD.EOL +
|
||||
" public int foo;" + CPD.EOL +
|
||||
"public class ExcessivePublicCountRule1 {" + PMD.EOL +
|
||||
" public int foo;" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST2 =
|
||||
"public class ExcessivePublicCountRule2 {" + CPD.EOL +
|
||||
" public int foo;" + CPD.EOL +
|
||||
" public int bif;" + CPD.EOL +
|
||||
" public int baz;" + CPD.EOL +
|
||||
" public int bof;" + CPD.EOL +
|
||||
"public class ExcessivePublicCountRule2 {" + PMD.EOL +
|
||||
" public int foo;" + PMD.EOL +
|
||||
" public int bif;" + PMD.EOL +
|
||||
" public int baz;" + PMD.EOL +
|
||||
" public int bof;" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package test.net.sourceforge.pmd.rules;
|
||||
|
||||
import net.sourceforge.pmd.Rule;
|
||||
import net.sourceforge.pmd.PMD;
|
||||
import net.sourceforge.pmd.cpd.CPD;
|
||||
import net.sourceforge.pmd.rules.XPathRule;
|
||||
|
||||
@ -24,28 +25,28 @@ public class FinalFieldCouldBeStaticRuleTest extends SimpleAggregatorTst {
|
||||
}
|
||||
|
||||
private static final String TEST1 =
|
||||
"public class Foo {" + CPD.EOL +
|
||||
" public final int BAR = 42;" + CPD.EOL +
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" public final int BAR = 42;" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST2 =
|
||||
"public class Foo {" + CPD.EOL +
|
||||
" public static final int BAR = 42;" + CPD.EOL +
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" public static final int BAR = 42;" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST3 =
|
||||
"public class Foo {" + CPD.EOL +
|
||||
" public int BAR = 42;" + CPD.EOL +
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" public int BAR = 42;" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST4 =
|
||||
"public class Foo {" + CPD.EOL +
|
||||
" public final String BAR = \"42\";" + CPD.EOL +
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" public final String BAR = \"42\";" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST5 =
|
||||
"public class Foo {" + CPD.EOL +
|
||||
" public final Thread BAR = new Thread();" + CPD.EOL +
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" public final Thread BAR = new Thread();" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package test.net.sourceforge.pmd.rules;
|
||||
|
||||
import net.sourceforge.pmd.Rule;
|
||||
import net.sourceforge.pmd.PMD;
|
||||
import net.sourceforge.pmd.cpd.CPD;
|
||||
import net.sourceforge.pmd.rules.XPathRule;
|
||||
|
||||
@ -22,18 +23,18 @@ public class FinalizeShouldBeProtectedRuleTest extends SimpleAggregatorTst {
|
||||
}
|
||||
|
||||
private static final String TEST1 =
|
||||
"public class Foo {" + CPD.EOL +
|
||||
" public void finalize() {}" + CPD.EOL +
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" public void finalize() {}" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST2 =
|
||||
"public class Foo {" + CPD.EOL +
|
||||
" public void finalize(int x) {}" + CPD.EOL +
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" public void finalize(int x) {}" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST3 =
|
||||
"public class Foo {" + CPD.EOL +
|
||||
" protected void finalize() {}" + CPD.EOL +
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" protected void finalize() {}" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package test.net.sourceforge.pmd.rules;
|
||||
|
||||
import net.sourceforge.pmd.Rule;
|
||||
import net.sourceforge.pmd.PMD;
|
||||
import net.sourceforge.pmd.cpd.CPD;
|
||||
import net.sourceforge.pmd.rules.XPathRule;
|
||||
|
||||
@ -24,29 +25,29 @@ public class ForLoopShouldBeWhileLoopRuleTest extends SimpleAggregatorTst {
|
||||
}
|
||||
|
||||
private static final String TEST1 =
|
||||
"public class ForLoopShouldBeWhileLoop1 {" + CPD.EOL +
|
||||
" public void foo() {" + CPD.EOL +
|
||||
" int x = 2;" + CPD.EOL +
|
||||
" for (;x<5;) { " + CPD.EOL +
|
||||
" x++;" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class ForLoopShouldBeWhileLoop1 {" + PMD.EOL +
|
||||
" public void foo() {" + PMD.EOL +
|
||||
" int x = 2;" + PMD.EOL +
|
||||
" for (;x<5;) { " + PMD.EOL +
|
||||
" x++;" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST2 =
|
||||
"public class ForLoopShouldBeWhileLoop2 {" + CPD.EOL +
|
||||
" public void foo() {" + CPD.EOL +
|
||||
" for (int x=2;x<5;) { " + CPD.EOL +
|
||||
" x++;" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class ForLoopShouldBeWhileLoop2 {" + PMD.EOL +
|
||||
" public void foo() {" + PMD.EOL +
|
||||
" for (int x=2;x<5;) { " + PMD.EOL +
|
||||
" x++;" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST3 =
|
||||
"public class ForLoopShouldBeWhileLoop3 {" + CPD.EOL +
|
||||
" public void foo() {" + CPD.EOL +
|
||||
" for (;;) {}" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class ForLoopShouldBeWhileLoop3 {" + PMD.EOL +
|
||||
" public void foo() {" + PMD.EOL +
|
||||
" for (;;) {}" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package test.net.sourceforge.pmd.rules;
|
||||
|
||||
import net.sourceforge.pmd.Rule;
|
||||
import net.sourceforge.pmd.PMD;
|
||||
import net.sourceforge.pmd.cpd.CPD;
|
||||
import net.sourceforge.pmd.rules.XPathRule;
|
||||
|
||||
@ -24,43 +25,43 @@ public class ForLoopsMustUseBracesRuleTest extends SimpleAggregatorTst {
|
||||
}
|
||||
|
||||
private static final String TEST1 =
|
||||
"public class ForLoopsNeedBraces1 {" + CPD.EOL +
|
||||
" public void foo() {" + CPD.EOL +
|
||||
" for (int i=0; i<42;i++)" + CPD.EOL +
|
||||
" foo();" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class ForLoopsNeedBraces1 {" + PMD.EOL +
|
||||
" public void foo() {" + PMD.EOL +
|
||||
" for (int i=0; i<42;i++)" + PMD.EOL +
|
||||
" foo();" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST2 =
|
||||
"public class ForLoopsNeedBraces2 {" + CPD.EOL +
|
||||
" public void foo() { " + CPD.EOL +
|
||||
" for (int i=0; i<42;i++) {" + CPD.EOL +
|
||||
" foo();" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class ForLoopsNeedBraces2 {" + PMD.EOL +
|
||||
" public void foo() { " + PMD.EOL +
|
||||
" for (int i=0; i<42;i++) {" + PMD.EOL +
|
||||
" foo();" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST3 =
|
||||
"public class ForLoopsNeedBraces3 {" + CPD.EOL +
|
||||
" public void foo() { " + CPD.EOL +
|
||||
" for (int i=0; i<42;) " + CPD.EOL +
|
||||
" foo();" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class ForLoopsNeedBraces3 {" + PMD.EOL +
|
||||
" public void foo() { " + PMD.EOL +
|
||||
" for (int i=0; i<42;) " + PMD.EOL +
|
||||
" foo();" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST4 =
|
||||
"public class ForLoopsNeedBraces4 {" + CPD.EOL +
|
||||
" public void foo() { " + CPD.EOL +
|
||||
" for (int i=0;;) " + CPD.EOL +
|
||||
" foo();" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class ForLoopsNeedBraces4 {" + PMD.EOL +
|
||||
" public void foo() { " + PMD.EOL +
|
||||
" for (int i=0;;) " + PMD.EOL +
|
||||
" foo();" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST5 =
|
||||
"public class ForLoopsNeedBraces5 {" + CPD.EOL +
|
||||
" public void foo() { " + CPD.EOL +
|
||||
" for (;;) " + CPD.EOL +
|
||||
" foo();" + CPD.EOL +
|
||||
" }" + CPD.EOL +
|
||||
"public class ForLoopsNeedBraces5 {" + PMD.EOL +
|
||||
" public void foo() { " + PMD.EOL +
|
||||
" for (;;) " + PMD.EOL +
|
||||
" foo();" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user