diff --git a/pmd/regress/test/net/sourceforge/pmd/ast/SimpleNodeTest.java b/pmd/regress/test/net/sourceforge/pmd/ast/SimpleNodeTest.java index 9d5ee70990..814193ea87 100644 --- a/pmd/regress/test/net/sourceforge/pmd/ast/SimpleNodeTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/ast/SimpleNodeTest.java @@ -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 { diff --git a/pmd/regress/test/net/sourceforge/pmd/cpd/MatchAlgorithmTest.java b/pmd/regress/test/net/sourceforge/pmd/cpd/MatchAlgorithmTest.java index 8ba10f4794..da2bd9a806 100644 --- a/pmd/regress/test/net/sourceforge/pmd/cpd/MatchAlgorithmTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/cpd/MatchAlgorithmTest.java @@ -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; } diff --git a/pmd/regress/test/net/sourceforge/pmd/cpd/SourceCodeTest.java b/pmd/regress/test/net/sourceforge/pmd/cpd/SourceCodeTest.java index 553a1af3f2..b2a5fd08ca 100644 --- a/pmd/regress/test/net/sourceforge/pmd/cpd/SourceCodeTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/cpd/SourceCodeTest.java @@ -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)); } } diff --git a/pmd/regress/test/net/sourceforge/pmd/cpd/XMLRendererTest.java b/pmd/regress/test/net/sourceforge/pmd/cpd/XMLRendererTest.java index b609be868a..2c7dc072b2 100644 --- a/pmd/regress/test/net/sourceforge/pmd/cpd/XMLRendererTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/cpd/XMLRendererTest.java @@ -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("", report); + assertEquals("", 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("", report); + assertEquals("", report); } } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/AccessorClassGenerationRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/AccessorClassGenerationRuleTest.java index 5cddbabd20..f28e11a04f 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/AccessorClassGenerationRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/AccessorClassGenerationRuleTest.java @@ -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 { diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/AssignmentInOperandRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/AssignmentInOperandRuleTest.java index 0d3aa3b0b0..d411ba3a33 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/AssignmentInOperandRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/AssignmentInOperandRuleTest.java @@ -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 + "}"; diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/AtLeastOneConstructorRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/AtLeastOneConstructorRuleTest.java index 287cae9b74..4fdab05892 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/AtLeastOneConstructorRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/AtLeastOneConstructorRuleTest.java @@ -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 + "}"; diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/AvoidDeeplyNestedIfStmtsRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/AvoidDeeplyNestedIfStmtsRuleTest.java index d10841b305..588c094cc0 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/AvoidDeeplyNestedIfStmtsRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/AvoidDeeplyNestedIfStmtsRuleTest.java @@ -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; diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/AvoidDuplicateLiteralsRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/AvoidDuplicateLiteralsRuleTest.java index 2cac092a7e..4fe37cf2b0 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/AvoidDuplicateLiteralsRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/AvoidDuplicateLiteralsRuleTest.java @@ -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; diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/AvoidReassigningParametersRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/AvoidReassigningParametersRuleTest.java index 09c672e6a6..34c38fa3bb 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/AvoidReassigningParametersRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/AvoidReassigningParametersRuleTest.java @@ -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; diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/BeanMembersShouldSerializeRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/BeanMembersShouldSerializeRuleTest.java index d2e3bfe566..a0b9b47a06 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/BeanMembersShouldSerializeRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/BeanMembersShouldSerializeRuleTest.java @@ -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 + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/ClassNamingConventionsRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/ClassNamingConventionsRuleTest.java new file mode 100644 index 0000000000..9511bea8cc --- /dev/null +++ b/pmd/regress/test/net/sourceforge/pmd/rules/ClassNamingConventionsRuleTest.java @@ -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 {};"; + +} diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/ConstructorCallsOverridableMethodRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/ConstructorCallsOverridableMethodRuleTest.java index 2b631cb22a..73f7c0f2aa 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/ConstructorCallsOverridableMethodRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/ConstructorCallsOverridableMethodRuleTest.java @@ -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 + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/CouplingBetweenObjectsRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/CouplingBetweenObjectsRuleTest.java index 7b7de2cae5..b34e62bdd4 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/CouplingBetweenObjectsRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/CouplingBetweenObjectsRuleTest.java @@ -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 + "}"; diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/CyclomaticComplexityRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/CyclomaticComplexityRuleTest.java index 957968a476..867a8211bf 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/CyclomaticComplexityRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/CyclomaticComplexityRuleTest.java @@ -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 + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/DontImportJavaLangRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/DontImportJavaLangRuleTest.java index 9279c8aa4d..d8dd2c0296 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/DontImportJavaLangRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/DontImportJavaLangRuleTest.java @@ -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 {}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/DoubleCheckedLockingRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/DoubleCheckedLockingRuleTest.java index 9741c86015..ab31c1fcc3 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/DoubleCheckedLockingRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/DoubleCheckedLockingRuleTest.java @@ -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 + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/DuplicateImportsRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/DuplicateImportsRuleTest.java index a93c8f5426..00b1328227 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/DuplicateImportsRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/DuplicateImportsRuleTest.java @@ -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 {}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/EmptyCatchBlockRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/EmptyCatchBlockRuleTest.java index 7604dd3f7a..59393a980b 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/EmptyCatchBlockRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/EmptyCatchBlockRuleTest.java @@ -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 + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/EmptyFinallyBlockRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/EmptyFinallyBlockRuleTest.java index 228fc38332..d9da4872cb 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/EmptyFinallyBlockRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/EmptyFinallyBlockRuleTest.java @@ -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 + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/EmptyIfStmtRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/EmptyIfStmtRuleTest.java index 23abc152da..f709ca34c1 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/EmptyIfStmtRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/EmptyIfStmtRuleTest.java @@ -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 + "}"; diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/EmptySwitchStmtRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/EmptySwitchStmtRuleTest.java index 6c89feadd1..8463a8e0a6 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/EmptySwitchStmtRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/EmptySwitchStmtRuleTest.java @@ -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 + "}"; diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/EmptyTryBlockRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/EmptyTryBlockRuleTest.java index deae8e9e73..d397425322 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/EmptyTryBlockRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/EmptyTryBlockRuleTest.java @@ -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 + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/EmptyWhileStmtRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/EmptyWhileStmtRuleTest.java index a160dfd454..fe89cfccd9 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/EmptyWhileStmtRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/EmptyWhileStmtRuleTest.java @@ -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 + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/ExcessiveImportsRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/ExcessiveImportsRuleTest.java index 734775e607..d5154d8de4 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/ExcessiveImportsRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/ExcessiveImportsRuleTest.java @@ -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{}"; diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/ExcessivePublicCountRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/ExcessivePublicCountRuleTest.java index ee25332a5f..db361482ca 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/ExcessivePublicCountRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/ExcessivePublicCountRuleTest.java @@ -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 + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/FinalFieldCouldBeStaticRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/FinalFieldCouldBeStaticRuleTest.java index 45ccb1c0d8..54eb3d4a17 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/FinalFieldCouldBeStaticRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/FinalFieldCouldBeStaticRuleTest.java @@ -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 + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/FinalizeShouldBeProtectedRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/FinalizeShouldBeProtectedRuleTest.java index 8417faceb7..f96c602081 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/FinalizeShouldBeProtectedRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/FinalizeShouldBeProtectedRuleTest.java @@ -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 + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/ForLoopShouldBeWhileLoopRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/ForLoopShouldBeWhileLoopRuleTest.java index 67c52de3f7..9ebc74f6d9 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/ForLoopShouldBeWhileLoopRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/ForLoopShouldBeWhileLoopRuleTest.java @@ -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 + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/ForLoopsMustUseBracesRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/ForLoopsMustUseBracesRuleTest.java index e0bd38d3c3..a32303b64f 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/ForLoopsMustUseBracesRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/ForLoopsMustUseBracesRuleTest.java @@ -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 + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/IdempotentOperationsRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/IdempotentOperationsRuleTest.java index c9629cf9cc..134581f716 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/IdempotentOperationsRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/IdempotentOperationsRuleTest.java @@ -2,6 +2,7 @@ package test.net.sourceforge.pmd.rules; import net.sourceforge.pmd.cpd.CPD; import net.sourceforge.pmd.rules.IdempotentOperationsRule; +import net.sourceforge.pmd.PMD; public class IdempotentOperationsRuleTest extends SimpleAggregatorTst { @@ -14,19 +15,19 @@ public class IdempotentOperationsRuleTest extends SimpleAggregatorTst { } private static final String TEST1 = - "public class Foo {" + CPD.EOL + - " private void bar() { " + CPD.EOL + - " int x = 2;" + CPD.EOL + - " x = x;" + CPD.EOL + - " }" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " private void bar() { " + PMD.EOL + + " int x = 2;" + PMD.EOL + + " x = x;" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST2 = - "public class Foo {" + CPD.EOL + - " private void bar() { " + CPD.EOL + - " int[] x = {2,3};" + CPD.EOL + - " x[0] = x[1];" + CPD.EOL + - " }" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " private void bar() { " + PMD.EOL + + " int[] x = {2,3};" + PMD.EOL + + " x[0] = x[1];" + PMD.EOL + + " }" + PMD.EOL + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/IfElseStmtsMustUseBracesRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/IfElseStmtsMustUseBracesRuleTest.java index 8d5731bed0..ca3049650f 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/IfElseStmtsMustUseBracesRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/IfElseStmtsMustUseBracesRuleTest.java @@ -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,27 +22,27 @@ public class IfElseStmtsMustUseBracesRuleTest extends SimpleAggregatorTst { } private static final String TEST1 = - "public class IfElseStmtsNeedBraces1 {" + CPD.EOL + - " public void foo() { " + CPD.EOL + - " int x =0;" + CPD.EOL + - " if (true == true) " + CPD.EOL + - " x=2;" + CPD.EOL + - " else " + CPD.EOL + - " x=4;" + CPD.EOL + - " " + CPD.EOL + - " }" + CPD.EOL + + "public class IfElseStmtsNeedBraces1 {" + PMD.EOL + + " public void foo() { " + PMD.EOL + + " int x =0;" + PMD.EOL + + " if (true == true) " + PMD.EOL + + " x=2;" + PMD.EOL + + " else " + PMD.EOL + + " x=4;" + PMD.EOL + + " " + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST2 = - "public class IfElseStmtsNeedBraces2 {" + CPD.EOL + - " public void foo() { " + CPD.EOL + - " int x =0;" + CPD.EOL + - " if (true == true) {" + CPD.EOL + - " x=2;" + CPD.EOL + - " } else {" + CPD.EOL + - " x=4;" + CPD.EOL + - " }" + CPD.EOL + - " }" + CPD.EOL + + "public class IfElseStmtsNeedBraces2 {" + PMD.EOL + + " public void foo() { " + PMD.EOL + + " int x =0;" + PMD.EOL + + " if (true == true) {" + PMD.EOL + + " x=2;" + PMD.EOL + + " } else {" + PMD.EOL + + " x=4;" + PMD.EOL + + " }" + PMD.EOL + + " }" + PMD.EOL + "}"; diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/IfStmtsMustUseBracesRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/IfStmtsMustUseBracesRuleTest.java index 64d5d5f01b..705231eadc 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/IfStmtsMustUseBracesRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/IfStmtsMustUseBracesRuleTest.java @@ -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,29 +23,29 @@ public class IfStmtsMustUseBracesRuleTest extends SimpleAggregatorTst { } private static final String TEST1 = - "public class IfStmtsMustUseBraces1 {" + CPD.EOL + - " public void foo() {" + CPD.EOL + - " int x = 0; " + CPD.EOL + - " if (true) x=2;" + CPD.EOL + - " }" + CPD.EOL + + "public class IfStmtsMustUseBraces1 {" + PMD.EOL + + " public void foo() {" + PMD.EOL + + " int x = 0; " + PMD.EOL + + " if (true) x=2;" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST2 = - "public class IfStmtsMustUseBraces2 {" + CPD.EOL + - " public void foo() { " + CPD.EOL + - " if (true) {" + CPD.EOL + - " int x=2;" + CPD.EOL + - " }" + CPD.EOL + - " }" + CPD.EOL + + "public class IfStmtsMustUseBraces2 {" + PMD.EOL + + " public void foo() { " + PMD.EOL + + " if (true) {" + PMD.EOL + + " int x=2;" + PMD.EOL + + " }" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST3 = - "public class IfStmtsMustUseBraces3 {" + CPD.EOL + - " public void foo() { " + CPD.EOL + - " if (true) {" + CPD.EOL + - " if (true) bar();" + CPD.EOL + - " }" + CPD.EOL + - " }" + CPD.EOL + + "public class IfStmtsMustUseBraces3 {" + PMD.EOL + + " public void foo() { " + PMD.EOL + + " if (true) {" + PMD.EOL + + " if (true) bar();" + PMD.EOL + + " }" + PMD.EOL + + " }" + PMD.EOL + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/ImportFromSamePackageRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/ImportFromSamePackageRuleTest.java index a73b8f903b..8439dd17be 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/ImportFromSamePackageRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/ImportFromSamePackageRuleTest.java @@ -2,6 +2,7 @@ package test.net.sourceforge.pmd.rules; import net.sourceforge.pmd.cpd.CPD; import net.sourceforge.pmd.rules.ImportFromSamePackageRule; +import net.sourceforge.pmd.PMD; public class ImportFromSamePackageRuleTest extends SimpleAggregatorTst { @@ -17,31 +18,31 @@ public class ImportFromSamePackageRuleTest extends SimpleAggregatorTst { } private static final String TEST1 = - "package foo;" + CPD.EOL + - "import foo.Bar;" + CPD.EOL + + "package foo;" + PMD.EOL + + "import foo.Bar;" + PMD.EOL + "public class ImportFromSamePackage1{}"; private static final String TEST2 = - "package foo;" + CPD.EOL + - "import foo.buz.Bar;" + CPD.EOL + + "package foo;" + PMD.EOL + + "import foo.buz.Bar;" + PMD.EOL + "public class ImportFromSamePackage2{}"; private static final String TEST3 = - "import java.util.*;" + CPD.EOL + + "import java.util.*;" + PMD.EOL + "public class ImportFromSamePackage3{}"; private static final String TEST4 = - "package bar;" + CPD.EOL + - "import Foo;" + CPD.EOL + + "package bar;" + PMD.EOL + + "import Foo;" + PMD.EOL + "public class ImportFromSamePackage4{}"; private static final String TEST5 = - "import Foo;" + CPD.EOL + + "import Foo;" + PMD.EOL + "public class ImportFromSamePackage5{}"; private static final String TEST6 = - "package foo.bar;" + CPD.EOL + - "import foo.bar.baz.*;" + CPD.EOL + + "package foo.bar;" + PMD.EOL + + "import foo.bar.baz.*;" + PMD.EOL + "public class ImportFromSamePackage6{}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/JumbledIncrementerRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/JumbledIncrementerRuleTest.java index 0a1a33cd86..98b7279db7 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/JumbledIncrementerRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/JumbledIncrementerRuleTest.java @@ -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,46 +25,46 @@ public class JumbledIncrementerRuleTest extends SimpleAggregatorTst { } private static final String TEST1 = - "public class JumbledIncrementerRule1 {" + CPD.EOL + - " public void foo() { " + CPD.EOL + - " for (int i = 0; i < 10; i++) { " + CPD.EOL + - " for (int k = 0; k < 20; i++) { " + CPD.EOL + - " System.out.println(\"Hello\"); " + CPD.EOL + - " } " + CPD.EOL + - " } " + CPD.EOL + - " } " + CPD.EOL + + "public class JumbledIncrementerRule1 {" + PMD.EOL + + " public void foo() { " + PMD.EOL + + " for (int i = 0; i < 10; i++) { " + PMD.EOL + + " for (int k = 0; k < 20; i++) { " + PMD.EOL + + " System.out.println(\"Hello\"); " + PMD.EOL + + " } " + PMD.EOL + + " } " + PMD.EOL + + " } " + PMD.EOL + "}"; private static final String TEST2 = - "public class JumbledIncrementerRule2 {" + CPD.EOL + - " public void foo() { " + CPD.EOL + - " for (int i = 0; i < 10; i++) { " + CPD.EOL + - " for (int k = 0; k < 20; k++) { " + CPD.EOL + - " System.out.println(\"Hello\"); " + CPD.EOL + - " } " + CPD.EOL + - " } " + CPD.EOL + - " } " + CPD.EOL + + "public class JumbledIncrementerRule2 {" + PMD.EOL + + " public void foo() { " + PMD.EOL + + " for (int i = 0; i < 10; i++) { " + PMD.EOL + + " for (int k = 0; k < 20; k++) { " + PMD.EOL + + " System.out.println(\"Hello\"); " + PMD.EOL + + " } " + PMD.EOL + + " } " + PMD.EOL + + " } " + PMD.EOL + "}"; private static final String TEST3 = - "public class JumbledIncrementerRule3 {" + CPD.EOL + - " public void foo() { " + CPD.EOL + - " for (int i=0; i<5; ) {" + CPD.EOL + - " i++;" + CPD.EOL + - " }" + CPD.EOL + - " for (int i=0;;) {" + CPD.EOL + - " if (i<5) {" + CPD.EOL + - " break;" + CPD.EOL + - " }" + CPD.EOL + - " i++;" + CPD.EOL + - " }" + CPD.EOL + - " for (;;) {" + CPD.EOL + - " int x =5;" + CPD.EOL + - " }" + CPD.EOL + - " for (int i=0; i<5;i++) ;" + CPD.EOL + - " for (int i=0; i<5;i++) " + CPD.EOL + - " foo();" + CPD.EOL + - " } " + CPD.EOL + + "public class JumbledIncrementerRule3 {" + PMD.EOL + + " public void foo() { " + PMD.EOL + + " for (int i=0; i<5; ) {" + PMD.EOL + + " i++;" + PMD.EOL + + " }" + PMD.EOL + + " for (int i=0;;) {" + PMD.EOL + + " if (i<5) {" + PMD.EOL + + " break;" + PMD.EOL + + " }" + PMD.EOL + + " i++;" + PMD.EOL + + " }" + PMD.EOL + + " for (;;) {" + PMD.EOL + + " int x =5;" + PMD.EOL + + " }" + PMD.EOL + + " for (int i=0; i<5;i++) ;" + PMD.EOL + + " for (int i=0; i<5;i++) " + PMD.EOL + + " foo();" + PMD.EOL + + " } " + PMD.EOL + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/LongVariableRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/LongVariableRuleTest.java index dc647e37d4..e98699f29b 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/LongVariableRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/LongVariableRuleTest.java @@ -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,40 +25,40 @@ public class LongVariableRuleTest extends SimpleAggregatorTst { } private static final String TEST1 = - "public class LongVariableParam {" + CPD.EOL + - " public static void main(String argsWithExtraMustard[]) { " + CPD.EOL + - " // a should trigger it." + CPD.EOL + - " }" + CPD.EOL + + "public class LongVariableParam {" + PMD.EOL + + " public static void main(String argsWithExtraMustard[]) { " + PMD.EOL + + " // a should trigger it." + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST2 = - "public class LongVariableNone {" + CPD.EOL + - " public static void main(String args[]) {" + CPD.EOL + - " int bugleDeWump = -1;" + CPD.EOL + - " }" + CPD.EOL + + "public class LongVariableNone {" + PMD.EOL + + " public static void main(String args[]) {" + PMD.EOL + + " int bugleDeWump = -1;" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST3 = - "public class LongVariableLocal {" + CPD.EOL + - "" + CPD.EOL + - " public static void main(String args[]) {" + CPD.EOL + - " int abcdefghijklmnopqrstuvwxyz = -1; " + CPD.EOL + - " // Should trigger ShortVariable rule." + CPD.EOL + - " }" + CPD.EOL + + "public class LongVariableLocal {" + PMD.EOL + + "" + PMD.EOL + + " public static void main(String args[]) {" + PMD.EOL + + " int abcdefghijklmnopqrstuvwxyz = -1; " + PMD.EOL + + " // Should trigger ShortVariable rule." + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST4 = - "public class LongVariableFor {" + CPD.EOL + - " public static void main(String args[]) {" + CPD.EOL + - " for (int interestingIntIterator = 0; " + CPD.EOL + - " interestingIntIterator < 10; " + CPD.EOL + - " interestingIntIterator++) { } // Should trigger." + CPD.EOL + - " }" + CPD.EOL + + "public class LongVariableFor {" + PMD.EOL + + " public static void main(String args[]) {" + PMD.EOL + + " for (int interestingIntIterator = 0; " + PMD.EOL + + " interestingIntIterator < 10; " + PMD.EOL + + " interestingIntIterator++) { } // Should trigger." + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST5 = - "public class LongVariableField {" + CPD.EOL + - " private int abcdefghijklmnopqrstuvwxyz; // Should cause a problem." + CPD.EOL + + "public class LongVariableField {" + PMD.EOL + + " private int abcdefghijklmnopqrstuvwxyz; // Should cause a problem." + PMD.EOL + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/MethodNamingConventionsRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/MethodNamingConventionsRuleTest.java index 5d213aa214..2db89081ea 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/MethodNamingConventionsRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/MethodNamingConventionsRuleTest.java @@ -2,6 +2,7 @@ package test.net.sourceforge.pmd.rules; import net.sourceforge.pmd.cpd.CPD; import net.sourceforge.pmd.rules.MethodNamingConventionsRule; +import net.sourceforge.pmd.PMD; public class MethodNamingConventionsRuleTest extends SimpleAggregatorTst { @@ -14,17 +15,17 @@ public class MethodNamingConventionsRuleTest extends SimpleAggregatorTst { } private static final String TEST1 = - "public class Foo {" + CPD.EOL + - " void Bar() {}" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " void Bar() {}" + PMD.EOL + "}"; private static final String TEST2 = - "public class Foo {" + CPD.EOL + - " void bar_foo() {}" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " void bar_foo() {}" + PMD.EOL + "}"; private static final String TEST3 = - "public class Foo {" + CPD.EOL + - " void foo() {}" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " void foo() {}" + PMD.EOL + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/OverrideBothEqualsAndHashcodeRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/OverrideBothEqualsAndHashcodeRuleTest.java index eb653a0da1..afa92b3fef 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/OverrideBothEqualsAndHashcodeRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/OverrideBothEqualsAndHashcodeRuleTest.java @@ -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; @@ -35,37 +36,37 @@ public class OverrideBothEqualsAndHashcodeRuleTest extends SimpleAggregatorTst { } private static final String TEST1 = - "public class OverrideBothEqualsAndHashcode1 {" + CPD.EOL + - " public int hashCode() {}" + CPD.EOL + + "public class OverrideBothEqualsAndHashcode1 {" + PMD.EOL + + " public int hashCode() {}" + PMD.EOL + "}"; private static final String TEST2 = - "public class OverrideBothEqualsAndHashcode2 {" + CPD.EOL + - " public boolean equals(Object other) {}" + CPD.EOL + + "public class OverrideBothEqualsAndHashcode2 {" + PMD.EOL + + " public boolean equals(Object other) {}" + PMD.EOL + "}"; private static final String TEST3 = - "public class OverrideBothEqualsAndHashcode3 {" + CPD.EOL + - " public boolean equals(Object other) {}" + CPD.EOL + - " public int hashCode() {}" + CPD.EOL + + "public class OverrideBothEqualsAndHashcode3 {" + PMD.EOL + + " public boolean equals(Object other) {}" + PMD.EOL + + " public int hashCode() {}" + PMD.EOL + "}"; private static final String TEST4 = - "public class OverrideBothEqualsAndHashcode4 {" + CPD.EOL + + "public class OverrideBothEqualsAndHashcode4 {" + PMD.EOL + "}"; private static final String TEST5 = - "public class OverrideBothEqualsAndHashcode5 {" + CPD.EOL + - " public boolean equals(String o) {" + CPD.EOL + - " return true;" + CPD.EOL + - " }" + CPD.EOL + - " public int hashCode() {" + CPD.EOL + - " return 0;" + CPD.EOL + - " }" + CPD.EOL + + "public class OverrideBothEqualsAndHashcode5 {" + PMD.EOL + + " public boolean equals(String o) {" + PMD.EOL + + " return true;" + PMD.EOL + + " }" + PMD.EOL + + " public int hashCode() {" + PMD.EOL + + " return 0;" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST6 = - "public interface OverrideBothEqualsAndHashcode6 {" + CPD.EOL + - " public boolean equals(Object o);" + CPD.EOL + + "public interface OverrideBothEqualsAndHashcode6 {" + PMD.EOL + + " public boolean equals(Object o);" + PMD.EOL + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/ReturnFromFinallyBlockTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/ReturnFromFinallyBlockTest.java index 4750b6b41f..8b99b35e13 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/ReturnFromFinallyBlockTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/ReturnFromFinallyBlockTest.java @@ -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,39 +22,39 @@ public class ReturnFromFinallyBlockTest extends SimpleAggregatorTst { }); } private static final String TEST1 = - "public class ReturnFromFinallyBlock1 {" + CPD.EOL + - " public String bugga() {" + CPD.EOL + - " try {" + CPD.EOL + - " throw new Exception( \"My Exception\" );" + CPD.EOL + - " } catch (Exception e) {" + CPD.EOL + - " throw e;" + CPD.EOL + - " } finally {" + CPD.EOL + - " return \"A. O. K.\"; // Very bad." + CPD.EOL + - " }" + CPD.EOL + - " }" + CPD.EOL + + "public class ReturnFromFinallyBlock1 {" + PMD.EOL + + " public String bugga() {" + PMD.EOL + + " try {" + PMD.EOL + + " throw new Exception( \"My Exception\" );" + PMD.EOL + + " } catch (Exception e) {" + PMD.EOL + + " throw e;" + PMD.EOL + + " } finally {" + PMD.EOL + + " return \"A. O. K.\"; // Very bad." + PMD.EOL + + " }" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST2 = - "public class ReturnFromFinallyBlock2 {" + CPD.EOL + - " public String getBar() {" + CPD.EOL + - " try {" + CPD.EOL + - " return \"buz\";" + CPD.EOL + - " } catch (Exception e) {" + CPD.EOL + - " return \"biz\";" + CPD.EOL + - " } finally {" + CPD.EOL + - " return \"fiddle!\"; // bad!" + CPD.EOL + - " }" + CPD.EOL + - " }" + CPD.EOL + + "public class ReturnFromFinallyBlock2 {" + PMD.EOL + + " public String getBar() {" + PMD.EOL + + " try {" + PMD.EOL + + " return \"buz\";" + PMD.EOL + + " } catch (Exception e) {" + PMD.EOL + + " return \"biz\";" + PMD.EOL + + " } finally {" + PMD.EOL + + " return \"fiddle!\"; // bad!" + PMD.EOL + + " }" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST3 = - "public class ReturnFromFinallyBlock3 {" + CPD.EOL + - " public String getBar() {" + CPD.EOL + - " try {" + CPD.EOL + - " return \"buz\";" + CPD.EOL + - " } finally {" + CPD.EOL + - " }" + CPD.EOL + - " }" + CPD.EOL + + "public class ReturnFromFinallyBlock3 {" + PMD.EOL + + " public String getBar() {" + PMD.EOL + + " try {" + PMD.EOL + + " return \"buz\";" + PMD.EOL + + " } finally {" + PMD.EOL + + " }" + PMD.EOL + + " }" + PMD.EOL + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/ShortMethodNameRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/ShortMethodNameRuleTest.java index cd3d309b27..dc68f39d8c 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/ShortMethodNameRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/ShortMethodNameRuleTest.java @@ -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; @@ -23,39 +24,39 @@ public class ShortMethodNameRuleTest extends SimpleAggregatorTst { } private static final String TEST1 = - "public class ShortMethodName0 {" + CPD.EOL + - " public int abcd( int i ) {" + CPD.EOL + - " // Should not violate." + CPD.EOL + - " }" + CPD.EOL + + "public class ShortMethodName0 {" + PMD.EOL + + " public int abcd( int i ) {" + PMD.EOL + + " // Should not violate." + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST2 = - "public class ShortMethodName1 {" + CPD.EOL + - " public int a( int i ) {" + CPD.EOL + - " // Should violate." + CPD.EOL + - " }" + CPD.EOL + + "public class ShortMethodName1 {" + PMD.EOL + + " public int a( int i ) {" + PMD.EOL + + " // Should violate." + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST3 = - "public class ShortMethodName2 {" + CPD.EOL + - " public int a( int i ) {" + CPD.EOL + - " // Should violate" + CPD.EOL + - " }" + CPD.EOL + - "" + CPD.EOL + - " public int b( int i ) {" + CPD.EOL + - " // Should violate" + CPD.EOL + - " }" + CPD.EOL + + "public class ShortMethodName2 {" + PMD.EOL + + " public int a( int i ) {" + PMD.EOL + + " // Should violate" + PMD.EOL + + " }" + PMD.EOL + + "" + PMD.EOL + + " public int b( int i ) {" + PMD.EOL + + " // Should violate" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST4 = - "public class ShortMethodName3 {" + CPD.EOL + - " public int a( int i ) {" + CPD.EOL + - " // Should violate" + CPD.EOL + - " }" + CPD.EOL + - "" + CPD.EOL + - " public int bcde( int i ) {" + CPD.EOL + - " // Should not violate" + CPD.EOL + - " }" + CPD.EOL + + "public class ShortMethodName3 {" + PMD.EOL + + " public int a( int i ) {" + PMD.EOL + + " // Should violate" + PMD.EOL + + " }" + PMD.EOL + + "" + PMD.EOL + + " public int bcde( int i ) {" + PMD.EOL + + " // Should not violate" + PMD.EOL + + " }" + PMD.EOL + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/ShortVariableRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/ShortVariableRuleTest.java index 3e697055b8..abfddca296 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/ShortVariableRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/ShortVariableRuleTest.java @@ -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,44 +26,44 @@ public class ShortVariableRuleTest extends SimpleAggregatorTst { } private static final String TEST1 = - "public class Foo {" + CPD.EOL + - " public static void main(String a[]) { // a should trigger it." + CPD.EOL + - " }" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " public static void main(String a[]) { // a should trigger it." + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST2 = - "public class Foo {" + CPD.EOL + - " public static void main(String args[]) {" + CPD.EOL + - " int bugleDeWump = -1;" + CPD.EOL + - " }" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " public static void main(String args[]) {" + PMD.EOL + + " int bugleDeWump = -1;" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST3 = - "public class Foo {" + CPD.EOL + - "" + CPD.EOL + - " public static void main(String args[]) {" + CPD.EOL + - " int ab = -1; " + CPD.EOL + - " // Should trigger ShortVariable rule." + CPD.EOL + - " }" + CPD.EOL + + "public class Foo {" + PMD.EOL + + "" + PMD.EOL + + " public static void main(String args[]) {" + PMD.EOL + + " int ab = -1; " + PMD.EOL + + " // Should trigger ShortVariable rule." + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST4 = - "public class Foo {" + CPD.EOL + - " public static void main(String args[]) {" + CPD.EOL + - " for (int i = 0; i < 10; i++) { } // Should NOT!! trigger." + CPD.EOL + - " }" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " public static void main(String args[]) {" + PMD.EOL + + " for (int i = 0; i < 10; i++) { } // Should NOT!! trigger." + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST5 = - "public class Foo {" + CPD.EOL + - " private int qx; // Should cause a problem." + CPD.EOL + + "public class Foo {" + PMD.EOL + + " private int qx; // Should cause a problem." + PMD.EOL + "}"; private static final String TEST6 = - "public class Foo {" + CPD.EOL + - " private void bar() {" + CPD.EOL + - " try {} catch (Exception e) {}" + CPD.EOL + - " }" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " private void bar() {" + PMD.EOL + + " try {} catch (Exception e) {}" + PMD.EOL + + " }" + PMD.EOL + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/SimplifyBooleanExpressionsRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/SimplifyBooleanExpressionsRuleTest.java index 7b754ce37d..ba84ca5ffd 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/SimplifyBooleanExpressionsRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/SimplifyBooleanExpressionsRuleTest.java @@ -1,26 +1,27 @@ 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 SimplifyBooleanExpressionsRuleTest extends RuleTst { private static final String TEST1 = - "public class SimplifyBooleanExpressions1 {" + CPD.EOL + - " private boolean foo = (isFoo() == true);" + CPD.EOL + - " public boolean isFoo() {return foo;}" + CPD.EOL + + "public class SimplifyBooleanExpressions1 {" + PMD.EOL + + " private boolean foo = (isFoo() == true);" + PMD.EOL + + " public boolean isFoo() {return foo;}" + PMD.EOL + "}"; private static final String TEST2 = - "public class SimplifyBooleanExpressions2 {" + CPD.EOL + - " public void foo() {" + CPD.EOL + - " boolean bar = (new String().length() >2) == false;" + CPD.EOL + - " }" + CPD.EOL + + "public class SimplifyBooleanExpressions2 {" + PMD.EOL + + " public void foo() {" + PMD.EOL + + " boolean bar = (new String().length() >2) == false;" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST3 = - "public class SimplifyBooleanExpressions3 {" + CPD.EOL + - " boolean bar = true;" + CPD.EOL + + "public class SimplifyBooleanExpressions3 {" + PMD.EOL + + " boolean bar = true;" + PMD.EOL + "}"; private Rule rule; diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/SimplifyBooleanReturnsRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/SimplifyBooleanReturnsRuleTest.java index 1d1fddf6b8..c3327c22c9 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/SimplifyBooleanReturnsRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/SimplifyBooleanReturnsRuleTest.java @@ -2,38 +2,39 @@ package test.net.sourceforge.pmd.rules; import net.sourceforge.pmd.cpd.CPD; import net.sourceforge.pmd.rules.SimplifyBooleanReturnsRule; +import net.sourceforge.pmd.PMD; public class SimplifyBooleanReturnsRuleTest extends RuleTst { private static final String TEST1 = - "public class SimplifyBooleanReturns1 {" + CPD.EOL + - " public void foo() { " + CPD.EOL + - " if (true) {" + CPD.EOL + - " return true;" + CPD.EOL + - " } else {" + CPD.EOL + - " return false;" + CPD.EOL + - " }" + CPD.EOL + - " }" + CPD.EOL + + "public class SimplifyBooleanReturns1 {" + PMD.EOL + + " public void foo() { " + PMD.EOL + + " if (true) {" + PMD.EOL + + " return true;" + PMD.EOL + + " } else {" + PMD.EOL + + " return false;" + PMD.EOL + + " }" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST2 = - "public class SimplifyBooleanReturns2 {" + CPD.EOL + - " public boolean foo() { " + CPD.EOL + - " if (true) " + CPD.EOL + - " return true;" + CPD.EOL + - " else " + CPD.EOL + - " return false;" + CPD.EOL + - " }" + CPD.EOL + + "public class SimplifyBooleanReturns2 {" + PMD.EOL + + " public boolean foo() { " + PMD.EOL + + " if (true) " + PMD.EOL + + " return true;" + PMD.EOL + + " else " + PMD.EOL + + " return false;" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST3 = - "public class SimplifyBooleanReturns3 {" + CPD.EOL + - " public Object foo() { " + CPD.EOL + - " if (!true) {" + CPD.EOL + - " return null;" + CPD.EOL + - " } else {}" + CPD.EOL + - " return null;" + CPD.EOL + - " }" + CPD.EOL + + "public class SimplifyBooleanReturns3 {" + PMD.EOL + + " public Object foo() { " + PMD.EOL + + " if (!true) {" + PMD.EOL + + " return null;" + PMD.EOL + + " } else {}" + PMD.EOL + + " return null;" + PMD.EOL + + " }" + PMD.EOL + "}"; public void test1() throws Throwable { diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/StringInstantiationRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/StringInstantiationRuleTest.java index 45d0428e93..093c8473f4 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/StringInstantiationRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/StringInstantiationRuleTest.java @@ -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; @@ -23,30 +24,30 @@ public class StringInstantiationRuleTest extends SimpleAggregatorTst { } private static final String TEST1 = - "public class StringInstantiation1 {" + CPD.EOL + - " private String bar = new String(\"bar\");" + CPD.EOL + - " private String baz = new String();" + CPD.EOL + + "public class StringInstantiation1 {" + PMD.EOL + + " private String bar = new String(\"bar\");" + PMD.EOL + + " private String baz = new String();" + PMD.EOL + "}"; private static final String TEST2 = - "public class StringInstantiation2 {" + CPD.EOL + - " private String[] bar = new String[5];" + CPD.EOL + + "public class StringInstantiation2 {" + PMD.EOL + + " private String[] bar = new String[5];" + PMD.EOL + "}"; private static final String TEST3 = - "public class StringInstantiation3 {" + CPD.EOL + - " public void foo() {" + CPD.EOL + - " byte[] bytes = new byte[50];" + CPD.EOL + - " String bar = new String(bytes, 0, bytes.length);" + CPD.EOL + - " }" + CPD.EOL + + "public class StringInstantiation3 {" + PMD.EOL + + " public void foo() {" + PMD.EOL + + " byte[] bytes = new byte[50];" + PMD.EOL + + " String bar = new String(bytes, 0, bytes.length);" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST4 = - "public class StringInstantiation4 {" + CPD.EOL + - " public void foo() {" + CPD.EOL + - " byte[] bytes = new byte[50];" + CPD.EOL + - " String bar = new String(bytes, 0, bytes.length, \"some-encoding\");" + CPD.EOL + - " }" + CPD.EOL + + "public class StringInstantiation4 {" + PMD.EOL + + " public void foo() {" + PMD.EOL + + " byte[] bytes = new byte[50];" + PMD.EOL + + " String bar = new String(bytes, 0, bytes.length, \"some-encoding\");" + PMD.EOL + + " }" + PMD.EOL + "}"; diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/StringToStringRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/StringToStringRuleTest.java index 79ea576a9c..950e024bcc 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/StringToStringRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/StringToStringRuleTest.java @@ -2,6 +2,7 @@ package test.net.sourceforge.pmd.rules; import net.sourceforge.pmd.cpd.CPD; import net.sourceforge.pmd.rules.StringToStringRule; +import net.sourceforge.pmd.PMD; public class StringToStringRuleTest extends SimpleAggregatorTst { @@ -17,49 +18,49 @@ public class StringToStringRuleTest extends SimpleAggregatorTst { } private static final String TEST1 = - "public class StringToString1 {" + CPD.EOL + - " private String baz() {" + CPD.EOL + - " String bar = \"howdy\";" + CPD.EOL + - " return bar.toString();" + CPD.EOL + - " }" + CPD.EOL + + "public class StringToString1 {" + PMD.EOL + + " private String baz() {" + PMD.EOL + + " String bar = \"howdy\";" + PMD.EOL + + " return bar.toString();" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST2 = - "public class StringToString2 {" + CPD.EOL + - " private String baz(String bar) {" + CPD.EOL + - " return bar.toString();" + CPD.EOL + - " }" + CPD.EOL + + "public class StringToString2 {" + PMD.EOL + + " private String baz(String bar) {" + PMD.EOL + + " return bar.toString();" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST3 = - "public class StringToString3 {" + CPD.EOL + - " private String baz;" + CPD.EOL + - " private int getBaz() {" + CPD.EOL + - " return baz.toString();" + CPD.EOL + - " }" + CPD.EOL + + "public class StringToString3 {" + PMD.EOL + + " private String baz;" + PMD.EOL + + " private int getBaz() {" + PMD.EOL + + " return baz.toString();" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST4 = - "public class StringToString4 {" + CPD.EOL + - " private int baz;" + CPD.EOL + - " private int getBaz() {" + CPD.EOL + - " return baz;" + CPD.EOL + - " }" + CPD.EOL + + "public class StringToString4 {" + PMD.EOL + + " private int baz;" + PMD.EOL + + " private int getBaz() {" + PMD.EOL + + " return baz;" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST5 = - "public class StringToString5 {" + CPD.EOL + - " private String getBaz(String foo, StringBuffer buffer) {" + CPD.EOL + - " return buffer.toString();" + CPD.EOL + - " }" + CPD.EOL + + "public class StringToString5 {" + PMD.EOL + + " private String getBaz(String foo, StringBuffer buffer) {" + PMD.EOL + + " return buffer.toString();" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST6 = - "public class StringToString6 {" + CPD.EOL + - " private String getBaz() {" + CPD.EOL + - " String[] foo = {\"hi\"};" + CPD.EOL + - " return foo[0].toString();" + CPD.EOL + - " }" + CPD.EOL + + "public class StringToString6 {" + PMD.EOL + + " private String getBaz() {" + PMD.EOL + + " String[] foo = {\"hi\"};" + PMD.EOL + + " return foo[0].toString();" + PMD.EOL + + " }" + PMD.EOL + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/SwitchStmtsShouldHaveDefaultRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/SwitchStmtsShouldHaveDefaultRuleTest.java index 9bc20cb7c6..0bc8e0e8b8 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/SwitchStmtsShouldHaveDefaultRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/SwitchStmtsShouldHaveDefaultRuleTest.java @@ -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,24 +22,24 @@ public class SwitchStmtsShouldHaveDefaultRuleTest extends SimpleAggregatorTst { } private static final String TEST1 = - "public class SwitchStmtsShouldHaveDefault1 {" + CPD.EOL + - " public void bar() {" + CPD.EOL + - " int x = 2;" + CPD.EOL + - " switch (x) {" + CPD.EOL + - " case 2: int y=8;" + CPD.EOL + - " }" + CPD.EOL + - " }" + CPD.EOL + + "public class SwitchStmtsShouldHaveDefault1 {" + PMD.EOL + + " public void bar() {" + PMD.EOL + + " int x = 2;" + PMD.EOL + + " switch (x) {" + PMD.EOL + + " case 2: int y=8;" + PMD.EOL + + " }" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST2 = - "public class SwitchStmtsShouldHaveDefault2 {" + CPD.EOL + - " public void bar() {" + CPD.EOL + - " int x = 2;" + CPD.EOL + - " switch (x) {" + CPD.EOL + - " case 2: int y=8;" + CPD.EOL + - " default: int j=8;" + CPD.EOL + - " }" + CPD.EOL + - " }" + CPD.EOL + + "public class SwitchStmtsShouldHaveDefault2 {" + PMD.EOL + + " public void bar() {" + PMD.EOL + + " int x = 2;" + PMD.EOL + + " switch (x) {" + PMD.EOL + + " case 2: int y=8;" + PMD.EOL + + " default: int j=8;" + PMD.EOL + + " }" + PMD.EOL + + " }" + PMD.EOL + "}"; diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/UnnecessaryConstructorRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/UnnecessaryConstructorRuleTest.java index cc0c3c0c75..e59587270c 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/UnnecessaryConstructorRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/UnnecessaryConstructorRuleTest.java @@ -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,38 +26,38 @@ public class UnnecessaryConstructorRuleTest extends SimpleAggregatorTst { } private static final String TEST1 = - "public class UnnecessaryConstructor1 {" + CPD.EOL + - " public UnnecessaryConstructor1() {}" + CPD.EOL + + "public class UnnecessaryConstructor1 {" + PMD.EOL + + " public UnnecessaryConstructor1() {}" + PMD.EOL + "}"; private static final String TEST2 = - "public class UnnecessaryConstructor2 {" + CPD.EOL + - " private UnnecessaryConstructor2() {}" + CPD.EOL + + "public class UnnecessaryConstructor2 {" + PMD.EOL + + " private UnnecessaryConstructor2() {}" + PMD.EOL + "}"; private static final String TEST3 = - "public class UnnecessaryConstructor3 {" + CPD.EOL + - " public UnnecessaryConstructor3(int x) {}" + CPD.EOL + + "public class UnnecessaryConstructor3 {" + PMD.EOL + + " public UnnecessaryConstructor3(int x) {}" + PMD.EOL + "}"; private static final String TEST4 = - "public class UnnecessaryConstructor4 {" + CPD.EOL + - " public UnnecessaryConstructor4() { " + CPD.EOL + - " int x = 2;" + CPD.EOL + - " }" + CPD.EOL + + "public class UnnecessaryConstructor4 {" + PMD.EOL + + " public UnnecessaryConstructor4() { " + PMD.EOL + + " int x = 2;" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST5 = - "public class UnnecessaryConstructor5 {" + CPD.EOL + - " public UnnecessaryConstructor5() throws IOException { " + CPD.EOL + - " }" + CPD.EOL + + "public class UnnecessaryConstructor5 {" + PMD.EOL + + " public UnnecessaryConstructor5() throws IOException { " + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST6 = - "public class UnnecessaryConstructor6 {" + CPD.EOL + - " public UnnecessaryConstructor6() {" + CPD.EOL + - " }" + CPD.EOL + - " public UnnecessaryConstructor6(String foo) {}" + CPD.EOL + + "public class UnnecessaryConstructor6 {" + PMD.EOL + + " public UnnecessaryConstructor6() {" + PMD.EOL + + " }" + PMD.EOL + + " public UnnecessaryConstructor6(String foo) {}" + PMD.EOL + "}"; diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/UnnecessaryTemporariesRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/UnnecessaryTemporariesRuleTest.java index ebd30ad076..424af57b06 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/UnnecessaryTemporariesRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/UnnecessaryTemporariesRuleTest.java @@ -2,19 +2,20 @@ package test.net.sourceforge.pmd.rules; import net.sourceforge.pmd.cpd.CPD; import net.sourceforge.pmd.rules.UnnecessaryConversionTemporaryRule; +import net.sourceforge.pmd.PMD; public class UnnecessaryTemporariesRuleTest extends RuleTst { private static final String TEST1 = - " public class UnnecessaryTemporary1 {" + CPD.EOL + - " void method (int x) {" + CPD.EOL + - " new Integer(x).toString(); " + CPD.EOL + - " new Long(x).toString(); " + CPD.EOL + - " new Float(x).toString(); " + CPD.EOL + - " new Byte((byte)x).toString(); " + CPD.EOL + - " new Double(x).toString(); " + CPD.EOL + - " new Short((short)x).toString(); " + CPD.EOL + - " }" + CPD.EOL + + " public class UnnecessaryTemporary1 {" + PMD.EOL + + " void method (int x) {" + PMD.EOL + + " new Integer(x).toString(); " + PMD.EOL + + " new Long(x).toString(); " + PMD.EOL + + " new Float(x).toString(); " + PMD.EOL + + " new Byte((byte)x).toString(); " + PMD.EOL + + " new Double(x).toString(); " + PMD.EOL + + " new Short((short)x).toString(); " + PMD.EOL + + " }" + PMD.EOL + " }"; public void testSimple() throws Throwable { diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/UnusedFormalParameterRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/UnusedFormalParameterRuleTest.java index 9a1c9c568c..0260017744 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/UnusedFormalParameterRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/UnusedFormalParameterRuleTest.java @@ -2,6 +2,7 @@ package test.net.sourceforge.pmd.rules; import net.sourceforge.pmd.cpd.CPD; import net.sourceforge.pmd.rules.UnusedFormalParameterRule; +import net.sourceforge.pmd.PMD; public class UnusedFormalParameterRuleTest extends SimpleAggregatorTst { @@ -22,27 +23,27 @@ public class UnusedFormalParameterRuleTest extends SimpleAggregatorTst { } private static final String TEST1 = - "class UnusedFormalParam1 {" + CPD.EOL + - " private void testMethod(String param1) {" + CPD.EOL + - " //System.out.println(param1);" + CPD.EOL + - " }" + CPD.EOL + + "class UnusedFormalParam1 {" + PMD.EOL + + " private void testMethod(String param1) {" + PMD.EOL + + " //System.out.println(param1);" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST2 = - "class UnusedFormalParam2 {" + CPD.EOL + - " private void foo (String s) " + CPD.EOL + - " {String str = s.toString();}" + CPD.EOL + + "class UnusedFormalParam2 {" + PMD.EOL + + " private void foo (String s) " + PMD.EOL + + " {String str = s.toString();}" + PMD.EOL + "}"; private static final String TEST3 = - "class UnusedFormalParam3 {" + CPD.EOL + - " private void t1(String s) {" + CPD.EOL + - " s.toString();" + CPD.EOL + - " }" + CPD.EOL + + "class UnusedFormalParam3 {" + PMD.EOL + + " private void t1(String s) {" + PMD.EOL + + " s.toString();" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST4 = - "public interface Foo {" + CPD.EOL + - " void foo(String bar);" + CPD.EOL + + "public interface Foo {" + PMD.EOL + + " void foo(String bar);" + PMD.EOL + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/UnusedImportsRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/UnusedImportsRuleTest.java index 683abac0f5..ddbe717d77 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/UnusedImportsRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/UnusedImportsRuleTest.java @@ -2,6 +2,7 @@ package test.net.sourceforge.pmd.rules; import net.sourceforge.pmd.cpd.CPD; import net.sourceforge.pmd.rules.UnusedImportsRule; +import net.sourceforge.pmd.PMD; public class UnusedImportsRuleTest extends SimpleAggregatorTst { @@ -22,27 +23,27 @@ public class UnusedImportsRuleTest extends SimpleAggregatorTst { } private static final String TEST1 = - "import java.io.File;" + CPD.EOL + + "import java.io.File;" + PMD.EOL + "public class UnusedImports1 {}"; private static final String TEST2 = - "import java.io.File;" + CPD.EOL + - "public class UnusedImports2 {" + CPD.EOL + - " private File file;" + CPD.EOL + + "import java.io.File;" + PMD.EOL + + "public class UnusedImports2 {" + PMD.EOL + + " private File file;" + PMD.EOL + "}"; private static final String TEST3 = - "import java.io.File;" + CPD.EOL + - "import java.util.List;" + CPD.EOL + - "public class UnusedImports3 {" + CPD.EOL + + "import java.io.File;" + PMD.EOL + + "import java.util.List;" + PMD.EOL + + "public class UnusedImports3 {" + PMD.EOL + "}"; private static final String TEST4 = - "import java.security.AccessController;" + CPD.EOL + - "public class UnusedImports4 {" + CPD.EOL + - " public void foo() {" + CPD.EOL + - " AccessController.doPrivileged(null);" + CPD.EOL + - " }" + CPD.EOL + + "import java.security.AccessController;" + PMD.EOL + + "public class UnusedImports4 {" + PMD.EOL + + " public void foo() {" + PMD.EOL + + " AccessController.doPrivileged(null);" + PMD.EOL + + " }" + PMD.EOL + "}"; diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/UnusedLocalVariableTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/UnusedLocalVariableTest.java index 0d233c65e8..47b06358c0 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/UnusedLocalVariableTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/UnusedLocalVariableTest.java @@ -2,6 +2,7 @@ package test.net.sourceforge.pmd.rules; import net.sourceforge.pmd.cpd.CPD; import net.sourceforge.pmd.rules.UnusedLocalVariableRule; +import net.sourceforge.pmd.PMD; public class UnusedLocalVariableTest extends SimpleAggregatorTst { @@ -32,131 +33,131 @@ public class UnusedLocalVariableTest extends SimpleAggregatorTst { } private static final String TEST1 = - "public class Foo {" + CPD.EOL + - " public foo() {" + CPD.EOL + - " String fr = new String();" + CPD.EOL + - " }" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " public foo() {" + PMD.EOL + + " String fr = new String();" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST2 = - "public class Foo {" + CPD.EOL + - " public void method() {" + CPD.EOL + - " int x;" + CPD.EOL + - " }" + CPD.EOL + - "}" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " public void method() {" + PMD.EOL + + " int x;" + PMD.EOL + + " }" + PMD.EOL + + "}" + PMD.EOL + ""; private static final String TEST3 = - "import java.util.*;" + CPD.EOL + - "public class Foo {" + CPD.EOL + - " public Foo() {" + CPD.EOL + - " List a = new ArrayList();" + CPD.EOL + - " }" + CPD.EOL + - "}" + CPD.EOL + + "import java.util.*;" + PMD.EOL + + "public class Foo {" + PMD.EOL + + " public Foo() {" + PMD.EOL + + " List a = new ArrayList();" + PMD.EOL + + " }" + PMD.EOL + + "}" + PMD.EOL + ""; private static final String TEST4 = - "import java.util.*;" + CPD.EOL + - "public class Foo {" + CPD.EOL + - " public Foo() {" + CPD.EOL + - " List a = new ArrayList();" + CPD.EOL + - " if (true == true) {" + CPD.EOL + - " a.size();" + CPD.EOL + - " }" + CPD.EOL + - " }" + CPD.EOL + - "}" + CPD.EOL + + "import java.util.*;" + PMD.EOL + + "public class Foo {" + PMD.EOL + + " public Foo() {" + PMD.EOL + + " List a = new ArrayList();" + PMD.EOL + + " if (true == true) {" + PMD.EOL + + " a.size();" + PMD.EOL + + " }" + PMD.EOL + + " }" + PMD.EOL + + "}" + PMD.EOL + ""; private static final String TEST5 = - "import java.util.*;" + CPD.EOL + - "public class Foo {" + CPD.EOL + - "static {" + CPD.EOL + - " String x;" + CPD.EOL + - "}" + CPD.EOL + - "}" + CPD.EOL + + "import java.util.*;" + PMD.EOL + + "public class Foo {" + PMD.EOL + + "static {" + PMD.EOL + + " String x;" + PMD.EOL + + "}" + PMD.EOL + + "}" + PMD.EOL + ""; private static final String TEST6 = - "public class Foo {" + CPD.EOL + - " public int x;" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " public int x;" + PMD.EOL + "}"; private static final String TEST7 = - "public class Foo {" + CPD.EOL + - " public void foo() {" + CPD.EOL + - " for (int i=0;i<10; i++);" + CPD.EOL + - " for (int i=0;i<10; i++);" + CPD.EOL + - " }" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " public void foo() {" + PMD.EOL + + " for (int i=0;i<10; i++);" + PMD.EOL + + " for (int i=0;i<10; i++);" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST8 = - "public class Foo {" + CPD.EOL + - " public void foo() {" + CPD.EOL + - " final String x = \"baf\";" + CPD.EOL + - " new Runnable() {" + CPD.EOL + - " public void run() {" + CPD.EOL + - " System.out.println(x);" + CPD.EOL + - " }" + CPD.EOL + - " }; " + CPD.EOL + - " }" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " public void foo() {" + PMD.EOL + + " final String x = \"baf\";" + PMD.EOL + + " new Runnable() {" + PMD.EOL + + " public void run() {" + PMD.EOL + + " System.out.println(x);" + PMD.EOL + + " }" + PMD.EOL + + " }; " + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST9 = - "public interface Foo {" + CPD.EOL + - " public void foo();" + CPD.EOL + - " public String bar();" + CPD.EOL + + "public interface Foo {" + PMD.EOL + + " public void foo();" + PMD.EOL + + " public String bar();" + PMD.EOL + "}"; private static final String TEST10 = - "public class Foo {" + CPD.EOL + - " public void foo() {" + CPD.EOL + - " String x = \"hi\";" + CPD.EOL + - " class Bar {" + CPD.EOL + - " public void buz() {" + CPD.EOL + - " String x = \"howdy\";" + CPD.EOL + - " }" + CPD.EOL + - " }" + CPD.EOL + - " }" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " public void foo() {" + PMD.EOL + + " String x = \"hi\";" + PMD.EOL + + " class Bar {" + PMD.EOL + + " public void buz() {" + PMD.EOL + + " String x = \"howdy\";" + PMD.EOL + + " }" + PMD.EOL + + " }" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST11 = - "public class Foo {" + CPD.EOL + - " public void foo() {" + CPD.EOL + - " for (int x = 0; ; ) { // USED" + CPD.EOL + - " x++;" + CPD.EOL + - " }" + CPD.EOL + - " }" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " public void foo() {" + PMD.EOL + + " for (int x = 0; ; ) { // USED" + PMD.EOL + + " x++;" + PMD.EOL + + " }" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST12 = - "public class Foo {" + CPD.EOL + - " public void foo() {" + CPD.EOL + - " final String x = \"hi\";" + CPD.EOL + - " new Runnable() {" + CPD.EOL + - " public void run() {" + CPD.EOL + - " x.toString();" + CPD.EOL + - " }" + CPD.EOL + - " };" + CPD.EOL + - " }" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " public void foo() {" + PMD.EOL + + " final String x = \"hi\";" + PMD.EOL + + " new Runnable() {" + PMD.EOL + + " public void run() {" + PMD.EOL + + " x.toString();" + PMD.EOL + + " }" + PMD.EOL + + " };" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST13 = - "public class Foo {" + CPD.EOL + - " public void foo() {" + CPD.EOL + - " int x,y=0;" + CPD.EOL + - " }" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " public void foo() {" + PMD.EOL + + " int x,y=0;" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST14 = - "public class Foo {" + CPD.EOL + - " public void bar() {" + CPD.EOL + - " try {" + CPD.EOL + - " //int x =2;" + CPD.EOL + - " } catch (RuntimeException e) {" + CPD.EOL + - " } catch (Exception e) {" + CPD.EOL + - " }" + CPD.EOL + - " }" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " public void bar() {" + PMD.EOL + + " try {" + PMD.EOL + + " //int x =2;" + PMD.EOL + + " } catch (RuntimeException e) {" + PMD.EOL + + " } catch (Exception e) {" + PMD.EOL + + " }" + PMD.EOL + + " }" + PMD.EOL + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/UnusedModifierRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/UnusedModifierRuleTest.java index 23742dd6a9..90cd80d76a 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/UnusedModifierRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/UnusedModifierRuleTest.java @@ -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; @@ -23,23 +24,23 @@ public class UnusedModifierRuleTest extends SimpleAggregatorTst { } private static final String TEST1 = - "public interface Foo {" + CPD.EOL + - " public void bar();" + CPD.EOL + + "public interface Foo {" + PMD.EOL + + " public void bar();" + PMD.EOL + "}"; private static final String TEST2 = - "public abstract class Foo {" + CPD.EOL + - " public abstract void bar();" + CPD.EOL + + "public abstract class Foo {" + PMD.EOL + + " public abstract void bar();" + PMD.EOL + "}"; private static final String TEST3 = - "public interface Foo {" + CPD.EOL + - " abstract void bar();" + CPD.EOL + + "public interface Foo {" + PMD.EOL + + " abstract void bar();" + PMD.EOL + "}"; private static final String TEST4 = - "public interface Foo {" + CPD.EOL + - " void bar();" + CPD.EOL + + "public interface Foo {" + PMD.EOL + + " void bar();" + PMD.EOL + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/UnusedPrivateFieldRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/UnusedPrivateFieldRuleTest.java index 9a48fcfb64..40a7863511 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/UnusedPrivateFieldRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/UnusedPrivateFieldRuleTest.java @@ -2,6 +2,7 @@ package test.net.sourceforge.pmd.rules; import net.sourceforge.pmd.cpd.CPD; import net.sourceforge.pmd.rules.UnusedPrivateFieldRule; +import net.sourceforge.pmd.PMD; public class UnusedPrivateFieldRuleTest extends SimpleAggregatorTst { @@ -35,145 +36,145 @@ public class UnusedPrivateFieldRuleTest extends SimpleAggregatorTst { }); } private static final String TEST1 = - "public class UnusedPrivateField1 {" + CPD.EOL + - "private String foo;" + CPD.EOL + + "public class UnusedPrivateField1 {" + PMD.EOL + + "private String foo;" + PMD.EOL + "}"; private static final String TEST2 = - "public class UnusedPrivateField2 {" + CPD.EOL + - " " + CPD.EOL + - " private String foo;" + CPD.EOL + - " private String bar = foo;" + CPD.EOL + - " " + CPD.EOL + - " public void buz() {" + CPD.EOL + - " bar = null;" + CPD.EOL + - " }" + CPD.EOL + + "public class UnusedPrivateField2 {" + PMD.EOL + + " " + PMD.EOL + + " private String foo;" + PMD.EOL + + " private String bar = foo;" + PMD.EOL + + " " + PMD.EOL + + " public void buz() {" + PMD.EOL + + " bar = null;" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST3 = - "public class UnusedPrivateField3 {" + CPD.EOL + - "" + CPD.EOL + - " private String foo;" + CPD.EOL + - "" + CPD.EOL + - " public void baz() {" + CPD.EOL + - " Runnable r = new Runnable() {" + CPD.EOL + - " public void run() {" + CPD.EOL + - " String foo = \"buz\";" + CPD.EOL + - " }" + CPD.EOL + - " }; " + CPD.EOL + - " }" + CPD.EOL + + "public class UnusedPrivateField3 {" + PMD.EOL + + "" + PMD.EOL + + " private String foo;" + PMD.EOL + + "" + PMD.EOL + + " public void baz() {" + PMD.EOL + + " Runnable r = new Runnable() {" + PMD.EOL + + " public void run() {" + PMD.EOL + + " String foo = \"buz\";" + PMD.EOL + + " }" + PMD.EOL + + " }; " + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST4 = - "public class UnusedPrivateField4 {" + CPD.EOL + - " public void bar() {" + CPD.EOL + - " foo[0] = 0;" + CPD.EOL + - " }" + CPD.EOL + - " private int[] foo;" + CPD.EOL + + "public class UnusedPrivateField4 {" + PMD.EOL + + " public void bar() {" + PMD.EOL + + " foo[0] = 0;" + PMD.EOL + + " }" + PMD.EOL + + " private int[] foo;" + PMD.EOL + "}"; private static final String TEST5 = - "public class UnusedPrivateField5 {" + CPD.EOL + - " private String foo;" + CPD.EOL + - " public void bar() { " + CPD.EOL + - " this.foo = null;" + CPD.EOL + - " }" + CPD.EOL + + "public class UnusedPrivateField5 {" + PMD.EOL + + " private String foo;" + PMD.EOL + + " public void bar() { " + PMD.EOL + + " this.foo = null;" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST6 = - "public class UnusedPrivateField6 {" + CPD.EOL + - " private static final String FOO = \"foo\";" + CPD.EOL + - " public Runnable bar() { " + CPD.EOL + - " return new Runnable() {" + CPD.EOL + - " public void run() {" + CPD.EOL + - " FOO.toString();" + CPD.EOL + - " }" + CPD.EOL + - " };" + CPD.EOL + - " }" + CPD.EOL + + "public class UnusedPrivateField6 {" + PMD.EOL + + " private static final String FOO = \"foo\";" + PMD.EOL + + " public Runnable bar() { " + PMD.EOL + + " return new Runnable() {" + PMD.EOL + + " public void run() {" + PMD.EOL + + " FOO.toString();" + PMD.EOL + + " }" + PMD.EOL + + " };" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST7 = - "public interface UnusedPrivateField7 {" + CPD.EOL + - " public static final String FOO = \"FOO\"; " + CPD.EOL + - " public boolean equals(Object another);" + CPD.EOL + - " public int hashCode();" + CPD.EOL + - " public String toString();" + CPD.EOL + + "public interface UnusedPrivateField7 {" + PMD.EOL + + " public static final String FOO = \"FOO\"; " + PMD.EOL + + " public boolean equals(Object another);" + PMD.EOL + + " public int hashCode();" + PMD.EOL + + " public String toString();" + PMD.EOL + "}"; private static final String TEST8 = - "public class UnusedPrivateField8 {" + CPD.EOL + - " public static class Services {" + CPD.EOL + - " private String x; " + CPD.EOL + - " }" + CPD.EOL + - "}" + CPD.EOL + + "public class UnusedPrivateField8 {" + PMD.EOL + + " public static class Services {" + PMD.EOL + + " private String x; " + PMD.EOL + + " }" + PMD.EOL + + "}" + PMD.EOL + ""; private static final String TEST9 = - "public class UnusedPrivateField9 {" + CPD.EOL + - " private int x;" + CPD.EOL + - " private class Bar {" + CPD.EOL + - " public void baz() {" + CPD.EOL + - " x = 2;" + CPD.EOL + - " }" + CPD.EOL + - " }" + CPD.EOL + + "public class UnusedPrivateField9 {" + PMD.EOL + + " private int x;" + PMD.EOL + + " private class Bar {" + PMD.EOL + + " public void baz() {" + PMD.EOL + + " x = 2;" + PMD.EOL + + " }" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST10 = - "public class UnusedPrivateField10 {" + CPD.EOL + - " private static String foo;" + CPD.EOL + + "public class UnusedPrivateField10 {" + PMD.EOL + + " private static String foo;" + PMD.EOL + "}"; private static final String TEST11 = - "public class Foo {" + CPD.EOL + - " private static final int BAR = 2;" + CPD.EOL + - " int x = Foo.BAR;" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " private static final int BAR = 2;" + PMD.EOL + + " int x = Foo.BAR;" + PMD.EOL + "}"; private static final String TEST12 = - "public class Foo {" + CPD.EOL + - " public class Foo {}" + CPD.EOL + - " private int x;" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " public class Foo {}" + PMD.EOL + + " private int x;" + PMD.EOL + "}"; private static final String TEST13 = - "public class Foo {" + CPD.EOL + - " public class Foo {private int x;}" + CPD.EOL + - " public class Bar {private int x;}" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " public class Foo {private int x;}" + PMD.EOL + + " public class Bar {private int x;}" + PMD.EOL + "}"; private static final String TEST14 = - "public class Foo {" + CPD.EOL + - " private int value;" + CPD.EOL + - " public int doSomething(int value) { " + CPD.EOL + - " return value + 1; " + CPD.EOL + - " }" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " private int value;" + PMD.EOL + + " public int doSomething(int value) { " + PMD.EOL + + " return value + 1; " + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST15 = - "public class Foo {" + CPD.EOL + - " private int x; " + CPD.EOL + - " public UnusedPrivateField17(int x) {" + CPD.EOL + - " this.x=x;" + CPD.EOL + - " }" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " private int x; " + PMD.EOL + + " public UnusedPrivateField17(int x) {" + PMD.EOL + + " this.x=x;" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST16 = - "public class Foo {" + CPD.EOL + - " public static final String FOO = \"foo\";" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " public static final String FOO = \"foo\";" + PMD.EOL + "}"; private static final String TEST17 = - "public class Foo {" + CPD.EOL + - " private int x;" + CPD.EOL + - " public void foo() {" + CPD.EOL + - " Foo foo = new Foo(); " + CPD.EOL + - " foo.x = 2;" + CPD.EOL + - " }" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " private int x;" + PMD.EOL + + " public void foo() {" + PMD.EOL + + " Foo foo = new Foo(); " + PMD.EOL + + " foo.x = 2;" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST18 = - "public class Foo {" + CPD.EOL + - " private static final ObjectStreamField[] serialPersistentFields = {new ObjectStreamField(\"foo\", String.class)};" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " private static final ObjectStreamField[] serialPersistentFields = {new ObjectStreamField(\"foo\", String.class)};" + PMD.EOL + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/UnusedPrivateMethodRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/UnusedPrivateMethodRuleTest.java index d2943a646e..4267f2ea33 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/UnusedPrivateMethodRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/UnusedPrivateMethodRuleTest.java @@ -2,6 +2,7 @@ package test.net.sourceforge.pmd.rules; import net.sourceforge.pmd.cpd.CPD; import net.sourceforge.pmd.rules.UnusedPrivateMethodRule; +import net.sourceforge.pmd.PMD; public class UnusedPrivateMethodRuleTest extends SimpleAggregatorTst { @@ -24,60 +25,60 @@ public class UnusedPrivateMethodRuleTest extends SimpleAggregatorTst { }); } private static final String TEST1 = - "public class Foo {" + CPD.EOL + - " public void bar() {" + CPD.EOL + - " foo();" + CPD.EOL + - " }" + CPD.EOL + - " private void foo() {}" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " public void bar() {" + PMD.EOL + + " foo();" + PMD.EOL + + " }" + PMD.EOL + + " private void foo() {}" + PMD.EOL + "}"; private static final String TEST2 = - "public class Foo {" + CPD.EOL + - " private void foo() {}" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " private void foo() {}" + PMD.EOL + "}"; private static final String TEST3 = - "public class Foo {" + CPD.EOL + - " public void bar() {" + CPD.EOL + - " new Runnable() {" + CPD.EOL + - " public void run() {" + CPD.EOL + - " foo();" + CPD.EOL + - " }" + CPD.EOL + - " };" + CPD.EOL + - " }" + CPD.EOL + - "" + CPD.EOL + - " private void foo() {}" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " public void bar() {" + PMD.EOL + + " new Runnable() {" + PMD.EOL + + " public void run() {" + PMD.EOL + + " foo();" + PMD.EOL + + " }" + PMD.EOL + + " };" + PMD.EOL + + " }" + PMD.EOL + + "" + PMD.EOL + + " private void foo() {}" + PMD.EOL + "}"; private static final String TEST4 = - "public class Foo {" + CPD.EOL + - " private void foo() {}" + CPD.EOL + - " private void foo(String baz) {}" + CPD.EOL + - " public void bar() {" + CPD.EOL + - " foo();" + CPD.EOL + - " }" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " private void foo() {}" + PMD.EOL + + " private void foo(String baz) {}" + PMD.EOL + + " public void bar() {" + PMD.EOL + + " foo();" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST5 = - "public class Foo {" + CPD.EOL + - " private void foo(String[] args) {}" + CPD.EOL + - " public static void main(String[] args) {" + CPD.EOL + - " Foo u = new Foo();" + CPD.EOL + - " u.foo(args); " + CPD.EOL + - " }" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " private void foo(String[] args) {}" + PMD.EOL + + " public static void main(String[] args) {" + PMD.EOL + + " Foo u = new Foo();" + PMD.EOL + + " u.foo(args); " + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST6 = - "public class Foo {" + CPD.EOL + - " public void bar() {" + CPD.EOL + - " this.foo();" + CPD.EOL + - " }" + CPD.EOL + - " private void foo() {}" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " public void bar() {" + PMD.EOL + + " this.foo();" + PMD.EOL + + " }" + PMD.EOL + + " private void foo() {}" + PMD.EOL + "}"; private static final String TEST7 = - "public class Foo {" + CPD.EOL + - " private static void foo() {}" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " private static void foo() {}" + PMD.EOL + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/VariableNamingConventionsRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/VariableNamingConventionsRuleTest.java index b0091ea883..18f9dfdf50 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/VariableNamingConventionsRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/VariableNamingConventionsRuleTest.java @@ -2,6 +2,7 @@ package test.net.sourceforge.pmd.rules; import net.sourceforge.pmd.cpd.CPD; import net.sourceforge.pmd.rules.VariableNamingConventionsRule; +import net.sourceforge.pmd.PMD; public class VariableNamingConventionsRuleTest extends SimpleAggregatorTst { @@ -15,23 +16,23 @@ public class VariableNamingConventionsRuleTest extends SimpleAggregatorTst { } private static final String TEST1 = - "public class Foo {" + CPD.EOL + - " private static final int foo = 2;" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " private static final int foo = 2;" + PMD.EOL + "}"; private static final String TEST2 = - "public class Foo {" + CPD.EOL + - " private int foo_bar = 2;" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " private int foo_bar = 2;" + PMD.EOL + "}"; private static final String TEST3 = - "public class Foo {" + CPD.EOL + - " private int Ubar = 2;" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " private int Ubar = 2;" + PMD.EOL + "}"; private static final String TEST4 = - "public class Foo {" + CPD.EOL + - " private int bar = 2;" + CPD.EOL + - " private static final int FOO_BAR = 2;" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " private int bar = 2;" + PMD.EOL + + " private static final int FOO_BAR = 2;" + PMD.EOL + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/WhileLoopsMustUseBracesRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/WhileLoopsMustUseBracesRuleTest.java index 404778686a..6c82ed22f4 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/WhileLoopsMustUseBracesRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/WhileLoopsMustUseBracesRuleTest.java @@ -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,22 +22,22 @@ public class WhileLoopsMustUseBracesRuleTest extends SimpleAggregatorTst { } private static final String TEST1 = - "public class WhileLoopsNeedBraces1 {" + CPD.EOL + - " public void foo() { " + CPD.EOL + - " int x =0;" + CPD.EOL + - " while (true)" + CPD.EOL + - " x++;" + CPD.EOL + - " }" + CPD.EOL + + "public class WhileLoopsNeedBraces1 {" + PMD.EOL + + " public void foo() { " + PMD.EOL + + " int x =0;" + PMD.EOL + + " while (true)" + PMD.EOL + + " x++;" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST2 = - "public class WhileLoopsNeedBraces2 {" + CPD.EOL + - " public void foo() { " + CPD.EOL + - " int x =0;" + CPD.EOL + - " while (true) {" + CPD.EOL + - " x++;" + CPD.EOL + - " }" + CPD.EOL + - " }" + CPD.EOL + + "public class WhileLoopsNeedBraces2 {" + PMD.EOL + + " public void foo() { " + PMD.EOL + + " int x =0;" + PMD.EOL + + " while (true) {" + PMD.EOL + + " x++;" + PMD.EOL + + " }" + PMD.EOL + + " }" + PMD.EOL + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/design/LongClassRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/design/LongClassRuleTest.java index 5720acfb36..fbdb712486 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/design/LongClassRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/design/LongClassRuleTest.java @@ -2,6 +2,7 @@ package test.net.sourceforge.pmd.rules.design; import net.sourceforge.pmd.cpd.CPD; import net.sourceforge.pmd.rules.design.LongClassRule; +import net.sourceforge.pmd.PMD; import test.net.sourceforge.pmd.rules.RuleTst; public class LongClassRuleTest extends RuleTst { @@ -27,30 +28,30 @@ public class LongClassRuleTest extends RuleTst { } private static final String TEST0 = - "public class LongMethod1 {" + CPD.EOL + - " public static void main(String args[]) {" + CPD.EOL + - " System.err.println(\"This is short.\");" + CPD.EOL + - " }" + CPD.EOL + + "public class LongMethod1 {" + PMD.EOL + + " public static void main(String args[]) {" + PMD.EOL + + " System.err.println(\"This is short.\");" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST1 = - "public class LongClass1" + CPD.EOL + - "{" + CPD.EOL + - " public void method0() {" + CPD.EOL + - " System.err.println(\"This is a long class.\");" + CPD.EOL + - " System.err.println(\"This is a long class.\");" + CPD.EOL + - " System.err.println(\"This is a long class.\");" + CPD.EOL + - " System.err.println(\"This is a long class.\");" + CPD.EOL + - " System.err.println(\"This is a long class.\");" + CPD.EOL + - " System.err.println(\"This is a long class.\");" + CPD.EOL + - " System.err.println(\"This is a long class.\");" + CPD.EOL + - " System.err.println(\"This is a long class.\");" + CPD.EOL + - " System.err.println(\"This is a long class.\");" + CPD.EOL + - " System.err.println(\"This is a long class.\");" + CPD.EOL + - " System.err.println(\"This is a long class.\");" + CPD.EOL + - " System.err.println(\"This is a long class.\");" + CPD.EOL + - " System.err.println(\"This is a long class.\");" + CPD.EOL + - " }" + CPD.EOL + + "public class LongClass1" + PMD.EOL + + "{" + PMD.EOL + + " public void method0() {" + PMD.EOL + + " System.err.println(\"This is a long class.\");" + PMD.EOL + + " System.err.println(\"This is a long class.\");" + PMD.EOL + + " System.err.println(\"This is a long class.\");" + PMD.EOL + + " System.err.println(\"This is a long class.\");" + PMD.EOL + + " System.err.println(\"This is a long class.\");" + PMD.EOL + + " System.err.println(\"This is a long class.\");" + PMD.EOL + + " System.err.println(\"This is a long class.\");" + PMD.EOL + + " System.err.println(\"This is a long class.\");" + PMD.EOL + + " System.err.println(\"This is a long class.\");" + PMD.EOL + + " System.err.println(\"This is a long class.\");" + PMD.EOL + + " System.err.println(\"This is a long class.\");" + PMD.EOL + + " System.err.println(\"This is a long class.\");" + PMD.EOL + + " System.err.println(\"This is a long class.\");" + PMD.EOL + + " }" + PMD.EOL + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/design/LongMethodRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/design/LongMethodRuleTest.java index e27691b821..1c52b84a6e 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/design/LongMethodRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/design/LongMethodRuleTest.java @@ -4,6 +4,7 @@ package test.net.sourceforge.pmd.rules.design; import net.sourceforge.pmd.cpd.CPD; import net.sourceforge.pmd.rules.design.LongMethodRule; +import net.sourceforge.pmd.PMD; import test.net.sourceforge.pmd.rules.RuleTst; public class LongMethodRuleTest extends RuleTst { @@ -33,64 +34,64 @@ public class LongMethodRuleTest extends RuleTst { } private static final String TEST1 = - "public class LongMethod1 {" + CPD.EOL + - " public static void main(String args[]) {" + CPD.EOL + - " System.err.println(\"This is short.\");" + CPD.EOL + - " }" + CPD.EOL + + "public class LongMethod1 {" + PMD.EOL + + " public static void main(String args[]) {" + PMD.EOL + + " System.err.println(\"This is short.\");" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST2 = - "public class LongMethod2 {" + CPD.EOL + - " public static void main(String args[]) {" + CPD.EOL + - " System.err.println(\"This is long.\");" + CPD.EOL + - " System.err.println(\"This is long.\");" + CPD.EOL + - " System.err.println(\"This is long.\");" + CPD.EOL + - " System.err.println(\"This is long.\");" + CPD.EOL + - " System.err.println(\"This is long.\");" + CPD.EOL + - " System.err.println(\"This is long.\");" + CPD.EOL + - " System.err.println(\"This is long.\");" + CPD.EOL + - " System.err.println(\"This is long.\");" + CPD.EOL + - " System.err.println(\"This is long.\");" + CPD.EOL + - " System.err.println(\"This is long.\");" + CPD.EOL + - " System.err.println(\"This is long.\");" + CPD.EOL + - " System.err.println(\"This is long.\");" + CPD.EOL + - " } // 11 lines - violation" + CPD.EOL + + "public class LongMethod2 {" + PMD.EOL + + " public static void main(String args[]) {" + PMD.EOL + + " System.err.println(\"This is long.\");" + PMD.EOL + + " System.err.println(\"This is long.\");" + PMD.EOL + + " System.err.println(\"This is long.\");" + PMD.EOL + + " System.err.println(\"This is long.\");" + PMD.EOL + + " System.err.println(\"This is long.\");" + PMD.EOL + + " System.err.println(\"This is long.\");" + PMD.EOL + + " System.err.println(\"This is long.\");" + PMD.EOL + + " System.err.println(\"This is long.\");" + PMD.EOL + + " System.err.println(\"This is long.\");" + PMD.EOL + + " System.err.println(\"This is long.\");" + PMD.EOL + + " System.err.println(\"This is long.\");" + PMD.EOL + + " System.err.println(\"This is long.\");" + PMD.EOL + + " } // 11 lines - violation" + PMD.EOL + "}"; private static final String TEST3 = - "public class LongMethod2 {" + CPD.EOL + - " public static void main(String args[]) {" + CPD.EOL + - " System.err.println(\"This is long, but not a violation\");" + CPD.EOL + - " System.err.println(\"This is long, but not a violation\");" + CPD.EOL + - " System.err.println(\"This is long, but not a violation\");" + CPD.EOL + - " System.err.println(\"This is long, but not a violation\");" + CPD.EOL + - " System.err.println(\"This is long, but not a violation\");" + CPD.EOL + - " System.err.println(\"This is long, but not a violation\");" + CPD.EOL + - " System.err.println(\"This is long, but not a violation\");" + CPD.EOL + - " System.err.println(\"This is long, but not a violation\");" + CPD.EOL + - " } // 9 lines - Not a violation" + CPD.EOL + + "public class LongMethod2 {" + PMD.EOL + + " public static void main(String args[]) {" + PMD.EOL + + " System.err.println(\"This is long, but not a violation\");" + PMD.EOL + + " System.err.println(\"This is long, but not a violation\");" + PMD.EOL + + " System.err.println(\"This is long, but not a violation\");" + PMD.EOL + + " System.err.println(\"This is long, but not a violation\");" + PMD.EOL + + " System.err.println(\"This is long, but not a violation\");" + PMD.EOL + + " System.err.println(\"This is long, but not a violation\");" + PMD.EOL + + " System.err.println(\"This is long, but not a violation\");" + PMD.EOL + + " System.err.println(\"This is long, but not a violation\");" + PMD.EOL + + " } // 9 lines - Not a violation" + PMD.EOL + "}"; private static final String TEST4 = - "public class LongMethod2 {" + CPD.EOL + - " public static void main(String args[]) {" + CPD.EOL + - " System.err.println(\"This is long, and is a violation\");" + CPD.EOL + - " System.err.println(\"This is long, and is a violation\");" + CPD.EOL + - " System.err.println(\"This is long, and is a violation\");" + CPD.EOL + - " System.err.println(\"This is long, and is a violation\");" + CPD.EOL + - " System.err.println(\"This is long, and is a violation\");" + CPD.EOL + - " System.err.println(\"This is long, and is a violation\");" + CPD.EOL + - " System.err.println(\"This is long, and is a violation\");" + CPD.EOL + - " System.err.println(\"This is long, and is a violation\");" + CPD.EOL + - " System.err.println(\"This is long, and is a violation\");" + CPD.EOL + - " System.err.println(\"This is long, and is a violation\");" + CPD.EOL + - " System.err.println(\"This is long, and is a violation\");" + CPD.EOL + - " System.err.println(\"This is long, and is a violation\");" + CPD.EOL + - " System.err.println(\"This is long, and is a violation\");" + CPD.EOL + - " System.err.println(\"This is long, and is a violation\");" + CPD.EOL + - " System.err.println(\"This is long, and is a violation\");" + CPD.EOL + - " System.err.println(\"This is long, and is a violation\");" + CPD.EOL + - " } // > 10 lines - Not a violation" + CPD.EOL + + "public class LongMethod2 {" + PMD.EOL + + " public static void main(String args[]) {" + PMD.EOL + + " System.err.println(\"This is long, and is a violation\");" + PMD.EOL + + " System.err.println(\"This is long, and is a violation\");" + PMD.EOL + + " System.err.println(\"This is long, and is a violation\");" + PMD.EOL + + " System.err.println(\"This is long, and is a violation\");" + PMD.EOL + + " System.err.println(\"This is long, and is a violation\");" + PMD.EOL + + " System.err.println(\"This is long, and is a violation\");" + PMD.EOL + + " System.err.println(\"This is long, and is a violation\");" + PMD.EOL + + " System.err.println(\"This is long, and is a violation\");" + PMD.EOL + + " System.err.println(\"This is long, and is a violation\");" + PMD.EOL + + " System.err.println(\"This is long, and is a violation\");" + PMD.EOL + + " System.err.println(\"This is long, and is a violation\");" + PMD.EOL + + " System.err.println(\"This is long, and is a violation\");" + PMD.EOL + + " System.err.println(\"This is long, and is a violation\");" + PMD.EOL + + " System.err.println(\"This is long, and is a violation\");" + PMD.EOL + + " System.err.println(\"This is long, and is a violation\");" + PMD.EOL + + " System.err.println(\"This is long, and is a violation\");" + PMD.EOL + + " } // > 10 lines - Not a violation" + PMD.EOL + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/design/LongParameterListRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/design/LongParameterListRuleTest.java index 88979185e5..fe4e64129a 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/design/LongParameterListRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/design/LongParameterListRuleTest.java @@ -4,20 +4,21 @@ package test.net.sourceforge.pmd.rules.design; import net.sourceforge.pmd.cpd.CPD; import net.sourceforge.pmd.rules.design.LongParameterListRule; +import net.sourceforge.pmd.PMD; import test.net.sourceforge.pmd.rules.RuleTst; public class LongParameterListRuleTest extends RuleTst { private static final String TEST1 = - "public class LongParameterList0 {" + CPD.EOL + - " public void foo() {}" + CPD.EOL + + "public class LongParameterList0 {" + PMD.EOL + + " public void foo() {}" + PMD.EOL + "}"; private static final String TEST2 = - "public class LongParameterList1 {" + CPD.EOL + - " public void foo(int p01, int p02, int p03, int p04, int p05," + CPD.EOL + - " int p06, int p07, int p08, int p09, int p10 ) { }" + CPD.EOL + - " public void bar(int p01, int p02, int p03, int p04, int p05 ) { }" + CPD.EOL + + "public class LongParameterList1 {" + PMD.EOL + + " public void foo(int p01, int p02, int p03, int p04, int p05," + PMD.EOL + + " int p06, int p07, int p08, int p09, int p10 ) { }" + PMD.EOL + + " public void bar(int p01, int p02, int p03, int p04, int p05 ) { }" + PMD.EOL + "}"; public LongParameterListRule getIUT() { diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/design/LooseCouplingRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/design/LooseCouplingRuleTest.java index 983255dbc2..4568ea809c 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/design/LooseCouplingRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/design/LooseCouplingRuleTest.java @@ -2,6 +2,7 @@ package test.net.sourceforge.pmd.rules.design; import net.sourceforge.pmd.cpd.CPD; import net.sourceforge.pmd.rules.design.LooseCouplingRule; +import net.sourceforge.pmd.PMD; import test.net.sourceforge.pmd.rules.SimpleAggregatorTst; import test.net.sourceforge.pmd.rules.TestDescriptor; @@ -29,70 +30,70 @@ public class LooseCouplingRuleTest extends SimpleAggregatorTst { } private static final String TEST1 = - "import java.util.*;" + CPD.EOL + - "public class LooseCoupling1 {" + CPD.EOL + - " public HashSet getFoo() {" + CPD.EOL + - " return new HashSet();" + CPD.EOL + - " }" + CPD.EOL + + "import java.util.*;" + PMD.EOL + + "public class LooseCoupling1 {" + PMD.EOL + + " public HashSet getFoo() {" + PMD.EOL + + " return new HashSet();" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST2 = - "import java.util.*;" + CPD.EOL + - "public class LooseCoupling2 {" + CPD.EOL + - " public Map getFoo() {" + CPD.EOL + - " return new HashMap();" + CPD.EOL + - " }" + CPD.EOL + + "import java.util.*;" + PMD.EOL + + "public class LooseCoupling2 {" + PMD.EOL + + " public Map getFoo() {" + PMD.EOL + + " return new HashMap();" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST3 = - "public class LooseCoupling3 {" + CPD.EOL + - " public void foo() {}" + CPD.EOL + + "public class LooseCoupling3 {" + PMD.EOL + + " public void foo() {}" + PMD.EOL + "}"; private static final String TEST4 = - "import java.util.*;" + CPD.EOL + - "public class LooseCoupling1 {" + CPD.EOL + - " private Set fooSet = new HashSet(); // OK" + CPD.EOL + - " public Set getFoo() {" + CPD.EOL + - " return fooSet;" + CPD.EOL + - " }" + CPD.EOL + + "import java.util.*;" + PMD.EOL + + "public class LooseCoupling1 {" + PMD.EOL + + " private Set fooSet = new HashSet(); // OK" + PMD.EOL + + " public Set getFoo() {" + PMD.EOL + + " return fooSet;" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST5 = - "import java.util.*;" + CPD.EOL + - "public class LooseCoupling5 {" + CPD.EOL + - " private HashSet fooSet = new HashSet(); // NOT OK" + CPD.EOL + - " public Set getFoo() {" + CPD.EOL + - " return fooSet;" + CPD.EOL + - " }" + CPD.EOL + + "import java.util.*;" + PMD.EOL + + "public class LooseCoupling5 {" + PMD.EOL + + " private HashSet fooSet = new HashSet(); // NOT OK" + PMD.EOL + + " public Set getFoo() {" + PMD.EOL + + " return fooSet;" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST6 = - "import java.util.*;" + CPD.EOL + - "public class LooseCoupling1 {" + CPD.EOL + - " private HashSet fooSet = new HashSet(); // NOT OK" + CPD.EOL + - " public HashSet getFoo() { // NOT OK" + CPD.EOL + - " return fooSet;" + CPD.EOL + - " }" + CPD.EOL + + "import java.util.*;" + PMD.EOL + + "public class LooseCoupling1 {" + PMD.EOL + + " private HashSet fooSet = new HashSet(); // NOT OK" + PMD.EOL + + " public HashSet getFoo() { // NOT OK" + PMD.EOL + + " return fooSet;" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST7 = - "import java.util.*;" + CPD.EOL + - "public class LooseCoupling7 {" + CPD.EOL + - " private HashSet fooSet = new HashSet();" + CPD.EOL + - " private HashMap fooMap = new HashMap();" + CPD.EOL + + "import java.util.*;" + PMD.EOL + + "public class LooseCoupling7 {" + PMD.EOL + + " private HashSet fooSet = new HashSet();" + PMD.EOL + + " private HashMap fooMap = new HashMap();" + PMD.EOL + "}"; private static final String TEST8 = - "import java.util.*;" + CPD.EOL + - "public class LooseCoupling8 {" + CPD.EOL + - " public void foo(HashMap bar) {}" + CPD.EOL + + "import java.util.*;" + PMD.EOL + + "public class LooseCoupling8 {" + PMD.EOL + + " public void foo(HashMap bar) {}" + PMD.EOL + "}"; private static final String TEST9 = - "import java.util.*;" + CPD.EOL + - "public class LooseCoupling9 {" + CPD.EOL + - " public void foo(Vector bar) {}" + CPD.EOL + + "import java.util.*;" + PMD.EOL + + "public class LooseCoupling9 {" + PMD.EOL + + " public void foo(Vector bar) {}" + PMD.EOL + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/design/NullAssignmentRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/design/NullAssignmentRuleTest.java index 4ed9144ce6..394eb4dacd 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/design/NullAssignmentRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/design/NullAssignmentRuleTest.java @@ -2,46 +2,47 @@ package test.net.sourceforge.pmd.rules.design; import net.sourceforge.pmd.cpd.CPD; import net.sourceforge.pmd.rules.design.NullAssignmentRule; +import net.sourceforge.pmd.PMD; import test.net.sourceforge.pmd.rules.RuleTst; public class NullAssignmentRuleTest extends RuleTst { private static final String TEST1 = - "public class NullAssignment1 {" + CPD.EOL + - " public Object foo() {" + CPD.EOL + - " Object x = null; // OK" + CPD.EOL + - " return x;" + CPD.EOL + - " } " + CPD.EOL + + "public class NullAssignment1 {" + PMD.EOL + + " public Object foo() {" + PMD.EOL + + " Object x = null; // OK" + PMD.EOL + + " return x;" + PMD.EOL + + " } " + PMD.EOL + "}"; private static final String TEST2 = - "public class NullAssignment2 {" + CPD.EOL + - " public void foo() {" + CPD.EOL + - " Object x;" + CPD.EOL + - " x = new Object();" + CPD.EOL + - " for (int y = 0; y < 10; y++) {" + CPD.EOL + - " System.err.println(y); " + CPD.EOL + - " }" + CPD.EOL + - " x = null; // This is bad" + CPD.EOL + - " }" + CPD.EOL + + "public class NullAssignment2 {" + PMD.EOL + + " public void foo() {" + PMD.EOL + + " Object x;" + PMD.EOL + + " x = new Object();" + PMD.EOL + + " for (int y = 0; y < 10; y++) {" + PMD.EOL + + " System.err.println(y); " + PMD.EOL + + " }" + PMD.EOL + + " x = null; // This is bad" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST3 = - "public class NullAssignment3 {" + CPD.EOL + - " public void foo() {" + CPD.EOL + - " Object x;" + CPD.EOL + - " if (x == null) { // This is OK" + CPD.EOL + - " return;" + CPD.EOL + - " }" + CPD.EOL + - " }" + CPD.EOL + + "public class NullAssignment3 {" + PMD.EOL + + " public void foo() {" + PMD.EOL + + " Object x;" + PMD.EOL + + " if (x == null) { // This is OK" + PMD.EOL + + " return;" + PMD.EOL + + " }" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST4 = - "public class NullAssignment4 {" + CPD.EOL + - " public void foo() {" + CPD.EOL + - " String x = null;" + CPD.EOL + - " x = new String(null);" + CPD.EOL + - " }" + CPD.EOL + + "public class NullAssignment4 {" + PMD.EOL + + " public void foo() {" + PMD.EOL + + " String x = null;" + PMD.EOL + + " x = new String(null);" + PMD.EOL + + " }" + PMD.EOL + "}"; public void testInitAssignment() throws Throwable { diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/design/OnlyOneReturnRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/design/OnlyOneReturnRuleTest.java index b89e038449..8d9e44bea4 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/design/OnlyOneReturnRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/design/OnlyOneReturnRuleTest.java @@ -2,67 +2,68 @@ package test.net.sourceforge.pmd.rules.design; import net.sourceforge.pmd.cpd.CPD; import net.sourceforge.pmd.rules.design.OnlyOneReturnRule; +import net.sourceforge.pmd.PMD; import test.net.sourceforge.pmd.rules.RuleTst; public class OnlyOneReturnRuleTest extends RuleTst { private static final String TEST1 = - "public class OnlyOneReturn1 {" + CPD.EOL + - " public String foo(int x) { " + CPD.EOL + - " if (x > 0) {" + CPD.EOL + - " return \"hey\";" + CPD.EOL + - " }" + CPD.EOL + - " return \"hi\";" + CPD.EOL + - " }" + CPD.EOL + + "public class OnlyOneReturn1 {" + PMD.EOL + + " public String foo(int x) { " + PMD.EOL + + " if (x > 0) {" + PMD.EOL + + " return \"hey\";" + PMD.EOL + + " }" + PMD.EOL + + " return \"hi\";" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST2 = - "public class OnlyOneReturn2 {" + CPD.EOL + - " public String foo(int x) { " + CPD.EOL + - " return \"hi\";" + CPD.EOL + - " }" + CPD.EOL + + "public class OnlyOneReturn2 {" + PMD.EOL + + " public String foo(int x) { " + PMD.EOL + + " return \"hi\";" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST3 = - "public class OnlyOneReturn3 {" + CPD.EOL + - " public void foo(int x) { " + CPD.EOL + - " int y =2;" + CPD.EOL + - " }" + CPD.EOL + + "public class OnlyOneReturn3 {" + PMD.EOL + + " public void foo(int x) { " + PMD.EOL + + " int y =2;" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST4 = - "public class OnlyOneReturn4 {" + CPD.EOL + - " public void foo(int x) { " + CPD.EOL + - " if (x>2) {" + CPD.EOL + - " return;" + CPD.EOL + - " }" + CPD.EOL + - " int y =2;" + CPD.EOL + - " }" + CPD.EOL + + "public class OnlyOneReturn4 {" + PMD.EOL + + " public void foo(int x) { " + PMD.EOL + + " if (x>2) {" + PMD.EOL + + " return;" + PMD.EOL + + " }" + PMD.EOL + + " int y =2;" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST5 = - "public class OnlyOneReturn5 {" + CPD.EOL + - " public int foo(int x) {" + CPD.EOL + - " try {" + CPD.EOL + - " x += 2;" + CPD.EOL + - " return x;" + CPD.EOL + - " } finally {" + CPD.EOL + - " System.err.println(\"WunderBuggy!\");" + CPD.EOL + - " }" + CPD.EOL + - " }" + CPD.EOL + + "public class OnlyOneReturn5 {" + PMD.EOL + + " public int foo(int x) {" + PMD.EOL + + " try {" + PMD.EOL + + " x += 2;" + PMD.EOL + + " return x;" + PMD.EOL + + " } finally {" + PMD.EOL + + " System.err.println(\"WunderBuggy!\");" + PMD.EOL + + " }" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST6 = - "public class OnlyOneReturn6 {" + CPD.EOL + - " public int foo() {" + CPD.EOL + - " FileFilter f = new FileFilter() {" + CPD.EOL + - " public boolean accept(File file) {" + CPD.EOL + - " return false;" + CPD.EOL + - " }" + CPD.EOL + - " };" + CPD.EOL + - " return 2;" + CPD.EOL + - " }" + CPD.EOL + + "public class OnlyOneReturn6 {" + PMD.EOL + + " public int foo() {" + PMD.EOL + + " FileFilter f = new FileFilter() {" + PMD.EOL + + " public boolean accept(File file) {" + PMD.EOL + + " return false;" + PMD.EOL + + " }" + PMD.EOL + + " };" + PMD.EOL + + " return 2;" + PMD.EOL + + " }" + PMD.EOL + "}"; diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/design/PositionalIteratorRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/design/PositionalIteratorRuleTest.java index d1bec3639e..168a9ecbfd 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/design/PositionalIteratorRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/design/PositionalIteratorRuleTest.java @@ -2,43 +2,44 @@ package test.net.sourceforge.pmd.rules.design; import net.sourceforge.pmd.cpd.CPD; import net.sourceforge.pmd.rules.design.PositionalIteratorRule; +import net.sourceforge.pmd.PMD; import test.net.sourceforge.pmd.rules.RuleTst; public class PositionalIteratorRuleTest extends RuleTst { private static final String TEST1 = - "public class PositionalIterator1 {" + CPD.EOL + - " public void foo(Iterator i) {" + CPD.EOL + - " while(i.hasNext()) {" + CPD.EOL + - " Object one = i.next();" + CPD.EOL + - " " + CPD.EOL + - " // 2 calls to next() inside the loop == bad!" + CPD.EOL + - " Object two = i.next(); " + CPD.EOL + - " }" + CPD.EOL + - " }" + CPD.EOL + + "public class PositionalIterator1 {" + PMD.EOL + + " public void foo(Iterator i) {" + PMD.EOL + + " while(i.hasNext()) {" + PMD.EOL + + " Object one = i.next();" + PMD.EOL + + " " + PMD.EOL + + " // 2 calls to next() inside the loop == bad!" + PMD.EOL + + " Object two = i.next(); " + PMD.EOL + + " }" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST2 = - "public class PositionalIterator2 {" + CPD.EOL + - " public void foo(Iterator i) {" + CPD.EOL + - " while(i.hasNext()) {" + CPD.EOL + - " Object one = i.next();" + CPD.EOL + - " }" + CPD.EOL + - " }" + CPD.EOL + + "public class PositionalIterator2 {" + PMD.EOL + + " public void foo(Iterator i) {" + PMD.EOL + + " while(i.hasNext()) {" + PMD.EOL + + " Object one = i.next();" + PMD.EOL + + " }" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST3 = - "public class PositionalIterator3 {" + CPD.EOL + - " public void foo() {" + CPD.EOL + - " Iterator i = (new List()).iterator();" + CPD.EOL + - " while(i.hasNext()) {" + CPD.EOL + - " Object one = i.next();" + CPD.EOL + - " Iterator j = (new List()).iterator();" + CPD.EOL + - " while (j.hasNext()) {" + CPD.EOL + - " j.next();" + CPD.EOL + - " }" + CPD.EOL + - " }" + CPD.EOL + - " }" + CPD.EOL + + "public class PositionalIterator3 {" + PMD.EOL + + " public void foo() {" + PMD.EOL + + " Iterator i = (new List()).iterator();" + PMD.EOL + + " while(i.hasNext()) {" + PMD.EOL + + " Object one = i.next();" + PMD.EOL + + " Iterator j = (new List()).iterator();" + PMD.EOL + + " while (j.hasNext()) {" + PMD.EOL + + " j.next();" + PMD.EOL + + " }" + PMD.EOL + + " }" + PMD.EOL + + " }" + PMD.EOL + "}"; public void test1() throws Throwable { diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/design/SwitchDensityTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/design/SwitchDensityTest.java index 11f8196b4a..6ca1c59a31 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/design/SwitchDensityTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/design/SwitchDensityTest.java @@ -5,6 +5,7 @@ package test.net.sourceforge.pmd.rules.design; import net.sourceforge.pmd.cpd.CPD; import net.sourceforge.pmd.rules.design.SwitchDensityRule; +import net.sourceforge.pmd.PMD; import test.net.sourceforge.pmd.rules.RuleTst; /** @@ -16,54 +17,54 @@ import test.net.sourceforge.pmd.rules.RuleTst; public class SwitchDensityTest extends RuleTst { private static final String TEST1 = - "// Switch Density = 5.0" + CPD.EOL + - "public class SwitchDensity1 {" + CPD.EOL + - " public void foo(int i) {" + CPD.EOL + - " switch (i) {" + CPD.EOL + - " case 0:" + CPD.EOL + - " {" + CPD.EOL + - " System.err.println(\"I am a fish.\");" + CPD.EOL + - " System.err.println(\"I am a fish.\");" + CPD.EOL + - " System.err.println(\"I am a fish.\");" + CPD.EOL + - " System.err.println(\"I am a fish.\");" + CPD.EOL + - " System.err.println(\"I am a fish.\");" + CPD.EOL + - " }" + CPD.EOL + - " } " + CPD.EOL + - " }" + CPD.EOL + + "// Switch Density = 5.0" + PMD.EOL + + "public class SwitchDensity1 {" + PMD.EOL + + " public void foo(int i) {" + PMD.EOL + + " switch (i) {" + PMD.EOL + + " case 0:" + PMD.EOL + + " {" + PMD.EOL + + " System.err.println(\"I am a fish.\");" + PMD.EOL + + " System.err.println(\"I am a fish.\");" + PMD.EOL + + " System.err.println(\"I am a fish.\");" + PMD.EOL + + " System.err.println(\"I am a fish.\");" + PMD.EOL + + " System.err.println(\"I am a fish.\");" + PMD.EOL + + " }" + PMD.EOL + + " } " + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST2 = - "// Switch Density = 1.0" + CPD.EOL + - "public class SwitchDensity2 {" + CPD.EOL + - " public void foo(int i) {" + CPD.EOL + - " switch (i) {" + CPD.EOL + - " case 0:" + CPD.EOL + - " {" + CPD.EOL + - " System.err.println(\"I am a fish.\");" + CPD.EOL + - " }" + CPD.EOL + - " } " + CPD.EOL + - " }" + CPD.EOL + + "// Switch Density = 1.0" + PMD.EOL + + "public class SwitchDensity2 {" + PMD.EOL + + " public void foo(int i) {" + PMD.EOL + + " switch (i) {" + PMD.EOL + + " case 0:" + PMD.EOL + + " {" + PMD.EOL + + " System.err.println(\"I am a fish.\");" + PMD.EOL + + " }" + PMD.EOL + + " } " + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST3 = - "// Switch Density = 1.0" + CPD.EOL + - "public class SwitchDensity3 {" + CPD.EOL + - " public void foo(int i) {" + CPD.EOL + - " switch (i) {" + CPD.EOL + - " case 0:" + CPD.EOL + - " case 1:" + CPD.EOL + - " case 2:" + CPD.EOL + - " case 3:" + CPD.EOL + - " case 4:" + CPD.EOL + - " {" + CPD.EOL + - " System.err.println(\"I am a fish.\");" + CPD.EOL + - " System.err.println(\"I am a fish.\");" + CPD.EOL + - " System.err.println(\"I am a fish.\");" + CPD.EOL + - " System.err.println(\"I am a fish.\");" + CPD.EOL + - " System.err.println(\"I am a fish.\");" + CPD.EOL + - " }" + CPD.EOL + - " } " + CPD.EOL + - " }" + CPD.EOL + + "// Switch Density = 1.0" + PMD.EOL + + "public class SwitchDensity3 {" + PMD.EOL + + " public void foo(int i) {" + PMD.EOL + + " switch (i) {" + PMD.EOL + + " case 0:" + PMD.EOL + + " case 1:" + PMD.EOL + + " case 2:" + PMD.EOL + + " case 3:" + PMD.EOL + + " case 4:" + PMD.EOL + + " {" + PMD.EOL + + " System.err.println(\"I am a fish.\");" + PMD.EOL + + " System.err.println(\"I am a fish.\");" + PMD.EOL + + " System.err.println(\"I am a fish.\");" + PMD.EOL + + " System.err.println(\"I am a fish.\");" + PMD.EOL + + " System.err.println(\"I am a fish.\");" + PMD.EOL + + " }" + PMD.EOL + + " } " + PMD.EOL + + " }" + PMD.EOL + "}"; public SwitchDensityTest() { diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/design/UseSingletonRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/design/UseSingletonRuleTest.java index ca6e397eb8..d75fc574b9 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/design/UseSingletonRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/design/UseSingletonRuleTest.java @@ -4,6 +4,7 @@ import net.sourceforge.pmd.Report; import net.sourceforge.pmd.ReportListener; import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleViolation; +import net.sourceforge.pmd.PMD; import net.sourceforge.pmd.cpd.CPD; import net.sourceforge.pmd.rules.design.UseSingletonRule; import net.sourceforge.pmd.stat.Metric; @@ -56,52 +57,52 @@ public class UseSingletonRuleTest extends RuleTst implements ReportListener { } private static final String TEST1 = - "public class Foo {" + CPD.EOL + - " // Should trigger UseSingleton rule?" + CPD.EOL + - " public Foo() { }" + CPD.EOL + - " public static void doSomething() {}" + CPD.EOL + - " public static void main(String args[]) {" + CPD.EOL + - " doSomething();" + CPD.EOL + - " }" + CPD.EOL + + "public class Foo {" + PMD.EOL + + " // Should trigger UseSingleton rule?" + PMD.EOL + + " public Foo() { }" + PMD.EOL + + " public static void doSomething() {}" + PMD.EOL + + " public static void main(String args[]) {" + PMD.EOL + + " doSomething();" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST2 = - "public class UseSingleton2" + CPD.EOL + - "{" + CPD.EOL + - " // Should not trigger UseSingleton rule." + CPD.EOL + - " public UseSingleton2() { }" + CPD.EOL + - " public void doSomething() { }" + CPD.EOL + - " public static void main(String args[]) { }" + CPD.EOL + + "public class UseSingleton2" + PMD.EOL + + "{" + PMD.EOL + + " // Should not trigger UseSingleton rule." + PMD.EOL + + " public UseSingleton2() { }" + PMD.EOL + + " public void doSomething() { }" + PMD.EOL + + " public static void main(String args[]) { }" + PMD.EOL + "}"; private static final String TEST3 = - "public class UseSingleton3" + CPD.EOL + - "{" + CPD.EOL + - " // Should trigger it." + CPD.EOL + - " public static void doSomething1() { }" + CPD.EOL + - " public static void doSomething2() { }" + CPD.EOL + - " public static void doSomething3() { }" + CPD.EOL + + "public class UseSingleton3" + PMD.EOL + + "{" + PMD.EOL + + " // Should trigger it." + PMD.EOL + + " public static void doSomething1() { }" + PMD.EOL + + " public static void doSomething2() { }" + PMD.EOL + + " public static void doSomething3() { }" + PMD.EOL + "}"; private static final String TEST4 = - "public class UseSingleton4" + CPD.EOL + - "{" + CPD.EOL + - " public UseSingleton4() { }" + CPD.EOL + + "public class UseSingleton4" + PMD.EOL + + "{" + PMD.EOL + + " public UseSingleton4() { }" + PMD.EOL + "}"; private static final String TEST5 = - "public class UseSingleton5 {" + CPD.EOL + - " private UseSingleton5() {}" + CPD.EOL + - " public static UseSingleton5 get() {" + CPD.EOL + - " return null;" + CPD.EOL + - " } " + CPD.EOL + + "public class UseSingleton5 {" + PMD.EOL + + " private UseSingleton5() {}" + PMD.EOL + + " public static UseSingleton5 get() {" + PMD.EOL + + " return null;" + PMD.EOL + + " } " + PMD.EOL + "}"; private static final String TEST6 = - "public abstract class Foo {" + CPD.EOL + - " public static void doSomething1() { }" + CPD.EOL + - " public static void doSomething2() { }" + CPD.EOL + - " public static void doSomething3() { }" + CPD.EOL + + "public abstract class Foo {" + PMD.EOL + + " public static void doSomething1() { }" + PMD.EOL + + " public static void doSomething2() { }" + PMD.EOL + + " public static void doSomething3() { }" + PMD.EOL + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/junit/JUnitAssertionsShouldIncludeMessageRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/junit/JUnitAssertionsShouldIncludeMessageRuleTest.java index c08a2e07ca..dafa478481 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/junit/JUnitAssertionsShouldIncludeMessageRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/junit/JUnitAssertionsShouldIncludeMessageRuleTest.java @@ -2,6 +2,7 @@ package test.net.sourceforge.pmd.rules.junit; import net.sourceforge.pmd.cpd.CPD; import net.sourceforge.pmd.rules.junit.JUnitAssertionsShouldIncludeMessageRule; +import net.sourceforge.pmd.PMD; import test.net.sourceforge.pmd.rules.RuleTst; public class JUnitAssertionsShouldIncludeMessageRuleTest extends RuleTst { @@ -41,80 +42,80 @@ public class JUnitAssertionsShouldIncludeMessageRuleTest extends RuleTst { } private static final String TEST1 = - "public class JUnitAssertionsShouldIncludeMessageRule1 {" + CPD.EOL + - " public void test1() {" + CPD.EOL + - " assertEquals(\"1 == 1\", 1, 1);" + CPD.EOL + - " }" + CPD.EOL + + "public class JUnitAssertionsShouldIncludeMessageRule1 {" + PMD.EOL + + " public void test1() {" + PMD.EOL + + " assertEquals(\"1 == 1\", 1, 1);" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST2 = - "public class JUnitAssertionsShouldIncludeMessageRule2 {" + CPD.EOL + - " public void test1() {" + CPD.EOL + - " assertEquals(1, 1);" + CPD.EOL + - " }" + CPD.EOL + + "public class JUnitAssertionsShouldIncludeMessageRule2 {" + PMD.EOL + + " public void test1() {" + PMD.EOL + + " assertEquals(1, 1);" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST3 = - "public class JUnitAssertionsShouldIncludeMessageRule3 {" + CPD.EOL + - " public void test1() {" + CPD.EOL + - " assertTrue(\"foo\", \"foo\".equals(\"foo\"));" + CPD.EOL + - " }" + CPD.EOL + + "public class JUnitAssertionsShouldIncludeMessageRule3 {" + PMD.EOL + + " public void test1() {" + PMD.EOL + + " assertTrue(\"foo\", \"foo\".equals(\"foo\"));" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST4 = - "public class JUnitAssertionsShouldIncludeMessageRule4 {" + CPD.EOL + - " public void test1() {" + CPD.EOL + - " assertTrue(\"foo\".equals(\"foo\"));" + CPD.EOL + - " }" + CPD.EOL + + "public class JUnitAssertionsShouldIncludeMessageRule4 {" + PMD.EOL + + " public void test1() {" + PMD.EOL + + " assertTrue(\"foo\".equals(\"foo\"));" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST5 = - "public class JUnitAssertionsShouldIncludeMessageRule5 {" + CPD.EOL + - " public void test1() {" + CPD.EOL + - " assertNull(\"it's not null\", null);" + CPD.EOL + - " }" + CPD.EOL + + "public class JUnitAssertionsShouldIncludeMessageRule5 {" + PMD.EOL + + " public void test1() {" + PMD.EOL + + " assertNull(\"it's not null\", null);" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST6 = - "public class JUnitAssertionsShouldIncludeMessageRule6 {" + CPD.EOL + - " public void test1() {" + CPD.EOL + - " assertNull(null);" + CPD.EOL + - " }" + CPD.EOL + + "public class JUnitAssertionsShouldIncludeMessageRule6 {" + PMD.EOL + + " public void test1() {" + PMD.EOL + + " assertNull(null);" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST7 = - "public class JUnitAssertionsShouldIncludeMessageRule7 {" + CPD.EOL + - " public void test1() {" + CPD.EOL + - " assertSame(\"not same!\", null, null);" + CPD.EOL + - " }" + CPD.EOL + + "public class JUnitAssertionsShouldIncludeMessageRule7 {" + PMD.EOL + + " public void test1() {" + PMD.EOL + + " assertSame(\"not same!\", null, null);" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST8 = - "public class JUnitAssertionsShouldIncludeMessageRule8 {" + CPD.EOL + - " public void test1() {" + CPD.EOL + - " assertSame(null, null);" + CPD.EOL + - " }" + CPD.EOL + + "public class JUnitAssertionsShouldIncludeMessageRule8 {" + PMD.EOL + + " public void test1() {" + PMD.EOL + + " assertSame(null, null);" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST9 = - "public class JUnitAssertionsShouldIncludeMessageRule9 {" + CPD.EOL + - " public void test1() {" + CPD.EOL + - " assertNotNull(\"foo\", null);" + CPD.EOL + - " }" + CPD.EOL + + "public class JUnitAssertionsShouldIncludeMessageRule9 {" + PMD.EOL + + " public void test1() {" + PMD.EOL + + " assertNotNull(\"foo\", null);" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST10 = - "public class JUnitAssertionsShouldIncludeMessageRule10 {" + CPD.EOL + - " public void test1() {" + CPD.EOL + - " assertNotNull(null);" + CPD.EOL + - " }" + CPD.EOL + + "public class JUnitAssertionsShouldIncludeMessageRule10 {" + PMD.EOL + + " public void test1() {" + PMD.EOL + + " assertNotNull(null);" + PMD.EOL + + " }" + PMD.EOL + "}"; private static final String TEST11 = - "public class JUnitAssertionsShouldIncludeMessageRule11 {" + CPD.EOL + - " public void test1() {" + CPD.EOL + - " this.test1(\"foo\");" + CPD.EOL + - " }" + CPD.EOL + + "public class JUnitAssertionsShouldIncludeMessageRule11 {" + PMD.EOL + + " public void test1() {" + PMD.EOL + + " this.test1(\"foo\");" + PMD.EOL + + " }" + PMD.EOL + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/junit/JUnitSpellingRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/junit/JUnitSpellingRuleTest.java index 732cdd8b81..06edf7041c 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/junit/JUnitSpellingRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/junit/JUnitSpellingRuleTest.java @@ -1,6 +1,7 @@ package test.net.sourceforge.pmd.rules.junit; import net.sourceforge.pmd.Rule; +import net.sourceforge.pmd.PMD; import net.sourceforge.pmd.cpd.CPD; import net.sourceforge.pmd.rules.XPathRule; import test.net.sourceforge.pmd.rules.RuleTst; @@ -8,36 +9,36 @@ import test.net.sourceforge.pmd.rules.RuleTst; public class JUnitSpellingRuleTest extends RuleTst { private static final String TEST1 = - "public class JUnitSpelling1 {" + CPD.EOL + - " // these should be 'setUp'" + CPD.EOL + - " public void setup() {}" + CPD.EOL + - " public void SetUp() {}" + CPD.EOL + + "public class JUnitSpelling1 {" + PMD.EOL + + " // these should be 'setUp'" + PMD.EOL + + " public void setup() {}" + PMD.EOL + + " public void SetUp() {}" + PMD.EOL + "}"; private static final String TEST2 = - "public class JUnitSpelling2 {" + CPD.EOL + - " // these should be 'tearDown'" + CPD.EOL + - " public void TearDown() {}" + CPD.EOL + - " public void teardown() {}" + CPD.EOL + + "public class JUnitSpelling2 {" + PMD.EOL + + " // these should be 'tearDown'" + PMD.EOL + + " public void TearDown() {}" + PMD.EOL + + " public void teardown() {}" + PMD.EOL + "}"; private static final String TEST3 = - "public class JUnitSpelling3 {" + CPD.EOL + - " // these are OK" + CPD.EOL + - " public void setUp() {}" + CPD.EOL + - " public void tearDown() {}" + CPD.EOL + + "public class JUnitSpelling3 {" + PMD.EOL + + " // these are OK" + PMD.EOL + + " public void setUp() {}" + PMD.EOL + + " public void tearDown() {}" + PMD.EOL + "}"; private static final String TEST4 = - "public class JUnitSpelling4 {" + CPD.EOL + - " // these are OK" + CPD.EOL + - " public void utility() {}" + CPD.EOL + - " public void foobr() {}" + CPD.EOL + + "public class JUnitSpelling4 {" + PMD.EOL + + " // these are OK" + PMD.EOL + + " public void utility() {}" + PMD.EOL + + " public void foobr() {}" + PMD.EOL + "}"; private static final String TEST5 = - "public class JUnitSpelling5 {" + CPD.EOL + - " public void setup(String x) {}" + CPD.EOL + + "public class JUnitSpelling5 {" + PMD.EOL + + " public void setup(String x) {}" + PMD.EOL + "}"; private Rule rule; diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/junit/JUnitStaticSuiteRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/junit/JUnitStaticSuiteRuleTest.java index efab3d432c..0370c76a10 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/junit/JUnitStaticSuiteRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/junit/JUnitStaticSuiteRuleTest.java @@ -1,6 +1,7 @@ package test.net.sourceforge.pmd.rules.junit; import net.sourceforge.pmd.Rule; +import net.sourceforge.pmd.PMD; import net.sourceforge.pmd.cpd.CPD; import net.sourceforge.pmd.rules.XPathRule; import test.net.sourceforge.pmd.rules.RuleTst; @@ -8,18 +9,18 @@ import test.net.sourceforge.pmd.rules.RuleTst; public class JUnitStaticSuiteRuleTest extends RuleTst { private static final String TEST1 = - "public class JUnitStaticSuite1 {" + CPD.EOL + - " public TestSuite suite() {}" + CPD.EOL + + "public class JUnitStaticSuite1 {" + PMD.EOL + + " public TestSuite suite() {}" + PMD.EOL + "}"; private static final String TEST2 = - "public class JUnitStaticSuite2 {" + CPD.EOL + - " public static TestSuite suite() {}" + CPD.EOL + + "public class JUnitStaticSuite2 {" + PMD.EOL + + " public static TestSuite suite() {}" + PMD.EOL + "}"; private static final String TEST3 = - "public class JUnitStaticSuite3 {" + CPD.EOL + - " private static TestSuite suite() {}" + CPD.EOL + + "public class JUnitStaticSuite3 {" + PMD.EOL + + " private static TestSuite suite() {}" + PMD.EOL + "}"; private Rule rule; diff --git a/pmd/src/net/sourceforge/pmd/PMD.java b/pmd/src/net/sourceforge/pmd/PMD.java index 2ddab8a332..7ddb56f0c5 100644 --- a/pmd/src/net/sourceforge/pmd/PMD.java +++ b/pmd/src/net/sourceforge/pmd/PMD.java @@ -24,6 +24,7 @@ import java.util.Iterator; import java.util.List; public class PMD { + public static final String EOL = System.getProperty("line.separator", "\n"); /** * @param reader - a Reader to the Java code to analyse diff --git a/pmd/src/net/sourceforge/pmd/cpd/CPD.java b/pmd/src/net/sourceforge/pmd/cpd/CPD.java index a1a5fa5f1b..682b4ea186 100644 --- a/pmd/src/net/sourceforge/pmd/cpd/CPD.java +++ b/pmd/src/net/sourceforge/pmd/cpd/CPD.java @@ -10,8 +10,6 @@ import java.util.Map; public class CPD { - public static final String EOL = System.getProperty("line.separator", "\n"); - private Map source = new HashMap(); private CPDListener listener = new CPDNullListener(); private Tokens tokens = new Tokens(); diff --git a/pmd/src/net/sourceforge/pmd/cpd/JavaTokenizer.java b/pmd/src/net/sourceforge/pmd/cpd/JavaTokenizer.java index a7ee71bd7d..f2840d6b07 100644 --- a/pmd/src/net/sourceforge/pmd/cpd/JavaTokenizer.java +++ b/pmd/src/net/sourceforge/pmd/cpd/JavaTokenizer.java @@ -3,6 +3,7 @@ package net.sourceforge.pmd.cpd; import net.sourceforge.pmd.ast.JavaCharStream; import net.sourceforge.pmd.ast.JavaParserTokenManager; import net.sourceforge.pmd.ast.Token; +import net.sourceforge.pmd.PMD; import java.io.IOException; import java.io.LineNumberReader; @@ -22,7 +23,7 @@ public class JavaTokenizer implements Tokenizer { while ((currentLine = r.readLine()) != null) { lines.add(currentLine); sb.append(currentLine); - sb.append(CPD.EOL); + sb.append(PMD.EOL); } tokens.setCode(lines); diff --git a/pmd/src/net/sourceforge/pmd/cpd/PHPTokenizer.java b/pmd/src/net/sourceforge/pmd/cpd/PHPTokenizer.java index f6343d50da..aa570397ab 100644 --- a/pmd/src/net/sourceforge/pmd/cpd/PHPTokenizer.java +++ b/pmd/src/net/sourceforge/pmd/cpd/PHPTokenizer.java @@ -1,5 +1,7 @@ package net.sourceforge.pmd.cpd; +import net.sourceforge.pmd.PMD; + import java.io.IOException; import java.io.LineNumberReader; import java.io.Reader; @@ -18,7 +20,7 @@ public class PHPTokenizer implements Tokenizer { while ((currentLine = r.readLine()) != null) { lines.add(currentLine); sb.append(currentLine); - sb.append(CPD.EOL); + sb.append(PMD.EOL); for (int i=0;i"); + buffer.append(""); } buffer.append(""); } diff --git a/pmd/src/net/sourceforge/pmd/renderers/VBHTMLRenderer.java b/pmd/src/net/sourceforge/pmd/renderers/VBHTMLRenderer.java index 0427a30fee..08b5146ed2 100644 --- a/pmd/src/net/sourceforge/pmd/renderers/VBHTMLRenderer.java +++ b/pmd/src/net/sourceforge/pmd/renderers/VBHTMLRenderer.java @@ -2,6 +2,7 @@ package net.sourceforge.pmd.renderers; import net.sourceforge.pmd.Report; import net.sourceforge.pmd.RuleViolation; +import net.sourceforge.pmd.PMD; import net.sourceforge.pmd.cpd.CPD; import java.util.Iterator; @@ -19,7 +20,7 @@ public class VBHTMLRenderer implements Renderer { StringBuffer sb = new StringBuffer(header()); String filename = null; - String lineSep = CPD.EOL; + String lineSep = PMD.EOL; boolean colorize = false; @@ -80,13 +81,13 @@ public class VBHTMLRenderer implements Renderer { StringBuffer sb = new StringBuffer(); sb.append("PMD"); sb.append(""); sb.append("
"); diff --git a/pmd/src/net/sourceforge/pmd/rules/ClassNamingConventionsRule.java b/pmd/src/net/sourceforge/pmd/rules/ClassNamingConventionsRule.java new file mode 100644 index 0000000000..23b05b53cb --- /dev/null +++ b/pmd/src/net/sourceforge/pmd/rules/ClassNamingConventionsRule.java @@ -0,0 +1,24 @@ +package net.sourceforge.pmd.rules; + +import net.sourceforge.pmd.AbstractRule; +import net.sourceforge.pmd.RuleContext; +import net.sourceforge.pmd.ast.ASTUnmodifiedClassDeclaration; + +public class ClassNamingConventionsRule extends AbstractRule { + + public Object visit(ASTUnmodifiedClassDeclaration node, Object data) { + + if (Character.isLowerCase(node.getImage().charAt(0))) { + RuleContext ctx = (RuleContext)data; + ctx.getReport().addRuleViolation(createRuleViolation(ctx, node.getBeginLine(), getMessage())); + } + + if (node.getImage().indexOf("_") >= 0) { + RuleContext ctx = (RuleContext)data; + ctx.getReport().addRuleViolation(createRuleViolation(ctx, node.getBeginLine(), "Class names should not contain underscores")); + + } + + return data; + } +}