diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/DontImportJavaLangRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/DontImportJavaLangRuleTest.java index 994eb8bd93..0767bfc1d5 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/DontImportJavaLangRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/DontImportJavaLangRuleTest.java @@ -10,10 +10,6 @@ import net.sourceforge.pmd.rules.DontImportJavaLangRule; public class DontImportJavaLangRuleTest extends RuleTst { - public DontImportJavaLangRuleTest(String name) { - super(name); - } - public void test1() throws Throwable { Report report = process("DontImportJavaLang1.java", new DontImportJavaLangRule()); assertEquals(1, report.size()); diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/DuplicateImportsRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/DuplicateImportsRuleTest.java index 9ab83cae8f..e3be878002 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/DuplicateImportsRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/DuplicateImportsRuleTest.java @@ -11,9 +11,6 @@ import net.sourceforge.pmd.rules.DuplicateImportsRule; import net.sourceforge.pmd.rules.UnusedLocalVariableRule; public class DuplicateImportsRuleTest extends RuleTst { - public DuplicateImportsRuleTest(String name) { - super(name); - } private DuplicateImportsRule rule; diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/EmptyCatchBlockRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/EmptyCatchBlockRuleTest.java index 56d0dce7ae..71ca21f996 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/EmptyCatchBlockRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/EmptyCatchBlockRuleTest.java @@ -13,10 +13,6 @@ import net.sourceforge.pmd.rules.EmptyCatchBlockRule; public class EmptyCatchBlockRuleTest extends RuleTst { - public EmptyCatchBlockRuleTest(String name) { - super(name); - } - public void testEmptyCatchBlock() throws Throwable { Report report = process("EmptyCatchBlock.java", new EmptyCatchBlockRule()); assertEquals(1, report.size()); diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/EmptyFinallyBlockRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/EmptyFinallyBlockRuleTest.java index 62c9da3a4f..f9e42ae5c5 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/EmptyFinallyBlockRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/EmptyFinallyBlockRuleTest.java @@ -11,10 +11,6 @@ import net.sourceforge.pmd.rules.EmptyFinallyBlockRule; public class EmptyFinallyBlockRuleTest extends RuleTst { - public EmptyFinallyBlockRuleTest(String name) { - super(name); - } - public void testEmptyFinallyBlock1() throws Throwable { Report report = process("EmptyFinallyBlock1.java", new EmptyFinallyBlockRule()); assertEquals(1, report.size()); diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/EmptyIfStmtRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/EmptyIfStmtRuleTest.java index 6b227ec85a..5be43b37bf 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/EmptyIfStmtRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/EmptyIfStmtRuleTest.java @@ -11,9 +11,6 @@ import net.sourceforge.pmd.renderers.Renderer; import net.sourceforge.pmd.rules.EmptyIfStmtRule; public class EmptyIfStmtRuleTest extends RuleTst { - public EmptyIfStmtRuleTest(String name) { - super(name); - } public void testEmptyIf() throws Throwable { Report report = process("EmptyIfStmtRule.java", new EmptyIfStmtRule()); diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/EmptySwitchStmtRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/EmptySwitchStmtRuleTest.java index 872f16f195..ec68cbe16c 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/EmptySwitchStmtRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/EmptySwitchStmtRuleTest.java @@ -9,10 +9,6 @@ import net.sourceforge.pmd.rules.EmptySwitchStmtRule; public class EmptySwitchStmtRuleTest extends RuleTst { - public EmptySwitchStmtRuleTest(String name) { - super(name); - } - public void test1() throws Throwable { runTest("EmptySwitchStmt1.java", 1, new EmptySwitchStmtRule()); } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/EmptyTryBlockRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/EmptyTryBlockRuleTest.java index 1829081323..8f3c4d2f53 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/EmptyTryBlockRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/EmptyTryBlockRuleTest.java @@ -11,9 +11,6 @@ import net.sourceforge.pmd.rules.EmptyCatchBlockRule; import net.sourceforge.pmd.rules.EmptyTryBlockRule; public class EmptyTryBlockRuleTest extends RuleTst { - public EmptyTryBlockRuleTest(String name) { - super(name); - } public void testEmptyTryBlock1() throws Throwable { Report report = process("EmptyTryBlock1.java", new EmptyTryBlockRule()); diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/EmptyWhileStmtRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/EmptyWhileStmtRuleTest.java index 9248d54153..7ae6c79789 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/EmptyWhileStmtRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/EmptyWhileStmtRuleTest.java @@ -11,9 +11,6 @@ import net.sourceforge.pmd.renderers.Renderer; import net.sourceforge.pmd.rules.EmptyWhileStmtRule; public class EmptyWhileStmtRuleTest extends RuleTst { - public EmptyWhileStmtRuleTest(String name) { - super(name); - } public void testEmptyWhileStmtRule() throws Throwable { Report report = process("EmptyWhileStmtRule.java", new EmptyWhileStmtRule()); diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/ForLoopsMustUseBracesRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/ForLoopsMustUseBracesRuleTest.java index 1e326945a1..faeae12501 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/ForLoopsMustUseBracesRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/ForLoopsMustUseBracesRuleTest.java @@ -10,9 +10,6 @@ import net.sourceforge.pmd.rules.WhileLoopsMustUseBracesRule; import net.sourceforge.pmd.rules.ForLoopsMustUseBracesRule; public class ForLoopsMustUseBracesRuleTest extends RuleTst { - public ForLoopsMustUseBracesRuleTest(String name) { - super(name); - } public void test1() throws Throwable { Report report = process("ForLoopsNeedBraces1.java", new ForLoopsMustUseBracesRule()); diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/IfElseStmtsMustUseBracesRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/IfElseStmtsMustUseBracesRuleTest.java index 26a49293d2..c0810d167b 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/IfElseStmtsMustUseBracesRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/IfElseStmtsMustUseBracesRuleTest.java @@ -11,10 +11,6 @@ import net.sourceforge.pmd.Report; public class IfElseStmtsMustUseBracesRuleTest extends RuleTst { - public IfElseStmtsMustUseBracesRuleTest(String name) { - super(name); - } - public void testIfElseStmtsMustUseBraces1() throws Throwable { Report report = process("IfElseStmtsNeedBraces1.java", new IfElseStmtsMustUseBracesRule()); assertEquals(1, report.size()); diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/IfStmtsMustUseBracesRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/IfStmtsMustUseBracesRuleTest.java index 74e1b9db5b..67e6d3a9a5 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/IfStmtsMustUseBracesRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/IfStmtsMustUseBracesRuleTest.java @@ -9,9 +9,6 @@ import net.sourceforge.pmd.rules.IfStmtsMustUseBracesRule; public class IfStmtsMustUseBracesRuleTest extends RuleTst { - public IfStmtsMustUseBracesRuleTest(String name) { - super(name); - } public void test1() throws Throwable { runTest("IfStmtsMustUseBraces1.java", 1, new IfStmtsMustUseBracesRule()); diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/JUnitSpellingRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/JUnitSpellingRuleTest.java index 98e5788cfe..fb207e28e6 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/JUnitSpellingRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/JUnitSpellingRuleTest.java @@ -12,9 +12,6 @@ public class JUnitSpellingRuleTest extends RuleTst { private Rule rule; - public JUnitSpellingRuleTest(String name) { - super(name); - } public void setUp() { rule = new JUnitSpellingRule(); diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/JUnitStaticSuiteRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/JUnitStaticSuiteRuleTest.java index 954c00c99b..cdc12d632d 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/JUnitStaticSuiteRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/JUnitStaticSuiteRuleTest.java @@ -9,10 +9,6 @@ import net.sourceforge.pmd.rules.JUnitStaticSuiteRule; public class JUnitStaticSuiteRuleTest extends RuleTst { - public JUnitStaticSuiteRuleTest(String name) { - super(name); - } - public void test1() throws Throwable { runTest("JUnitStaticSuite1.java", 2, new JUnitStaticSuiteRule()); } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/LongVariableRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/LongVariableRuleTest.java index e78066b168..791614dae2 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/LongVariableRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/LongVariableRuleTest.java @@ -14,10 +14,6 @@ public class LongVariableRuleTest private LongVariableRule rule; - public LongVariableRuleTest( String name ) { - super( name ); - } - public void setUp() { rule = new LongVariableRule(); rule.setMessage("Avoid long names like {0}"); diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/OverrideBothEqualsAndHashcodeRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/OverrideBothEqualsAndHashcodeRuleTest.java index 4ad5fa2961..e0218d0ec9 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/OverrideBothEqualsAndHashcodeRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/OverrideBothEqualsAndHashcodeRuleTest.java @@ -11,10 +11,6 @@ import net.sourceforge.pmd.rules.OverrideBothEqualsAndHashcodeRule; import net.sourceforge.pmd.Report; public class OverrideBothEqualsAndHashcodeRuleTest extends RuleTst { - public OverrideBothEqualsAndHashcodeRuleTest( String name ) { - super( name ); - } - public void test1() throws Throwable{ Report report = process("OverrideBothEqualsAndHashcode1.java", new OverrideBothEqualsAndHashcodeRule()); assertEquals(1, report.size()); diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/RuleTst.java b/pmd/regress/test/net/sourceforge/pmd/rules/RuleTst.java index f64ec4b5da..025fadf3ad 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/RuleTst.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/RuleTst.java @@ -23,10 +23,6 @@ import net.sourceforge.pmd.ast.*; public class RuleTst extends TestCase { - public RuleTst( String name ) { - super( name ); - } - public Report process( String fileName, Rule rule ) throws Throwable diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/ShortMethodNameRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/ShortMethodNameRuleTest.java index 3d61bf1a00..d8ad74fb0b 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/ShortMethodNameRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/ShortMethodNameRuleTest.java @@ -14,10 +14,6 @@ public class ShortMethodNameRuleTest private ShortMethodNameRule rule; - public ShortMethodNameRuleTest( String name ) { - super( name ); - } - public void setUp() { rule = new ShortMethodNameRule(); rule.setMessage("Avoid this stuff -> {0}"); diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/ShortVariableRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/ShortVariableRuleTest.java index 45c05810f5..391badc7f2 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/ShortVariableRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/ShortVariableRuleTest.java @@ -14,10 +14,6 @@ public class ShortVariableRuleTest private ShortVariableRule rule; - public ShortVariableRuleTest( String name ) { - super( name ); - } - public void setUp() { rule = new ShortVariableRule(); rule.setMessage("Avoid stuff like -> ''{0}''"); diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/SimplifyBooleanReturnsRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/SimplifyBooleanReturnsRuleTest.java index 605a18afcc..b64737bdec 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/SimplifyBooleanReturnsRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/SimplifyBooleanReturnsRuleTest.java @@ -9,9 +9,6 @@ import net.sourceforge.pmd.Report; import net.sourceforge.pmd.rules.SimplifyBooleanReturnsRule; public class SimplifyBooleanReturnsRuleTest extends RuleTst { - public SimplifyBooleanReturnsRuleTest(String name) { - super(name); - } public void test1() throws Throwable { Report report = process("SimplifyBooleanReturns1.java", new SimplifyBooleanReturnsRule()); diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/StringInstantiationRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/StringInstantiationRuleTest.java index 291310db52..f693385f29 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/StringInstantiationRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/StringInstantiationRuleTest.java @@ -9,10 +9,6 @@ import net.sourceforge.pmd.rules.StringInstantiationRule; public class StringInstantiationRuleTest extends RuleTst { - public StringInstantiationRuleTest(String name) { - super(name); - } - public void test1() throws Throwable { runTest("StringInstantiation1.java", 2, new StringInstantiationRule()); } @@ -20,4 +16,8 @@ public class StringInstantiationRuleTest extends RuleTst { public void test2() throws Throwable { runTest("StringInstantiation2.java", 0, new StringInstantiationRule()); } + + public void test3() throws Throwable { + runTest("StringInstantiation3.java", 0, new StringInstantiationRule()); + } } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/SwitchStmtsShouldHaveDefaultRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/SwitchStmtsShouldHaveDefaultRuleTest.java index 7fa270b84a..c5cee837c0 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/SwitchStmtsShouldHaveDefaultRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/SwitchStmtsShouldHaveDefaultRuleTest.java @@ -9,10 +9,6 @@ import net.sourceforge.pmd.rules.SwitchStmtsShouldHaveDefaultRule; public class SwitchStmtsShouldHaveDefaultRuleTest extends RuleTst { - public SwitchStmtsShouldHaveDefaultRuleTest(String name) { - super(name); - } - public void test1() throws Throwable { runTest("SwitchStmtsShouldHaveDefault1.java", 1, new SwitchStmtsShouldHaveDefaultRule()); } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/UnnecessaryTemporariesRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/UnnecessaryTemporariesRuleTest.java index 63930feb5f..8e1a32236e 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/UnnecessaryTemporariesRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/UnnecessaryTemporariesRuleTest.java @@ -13,10 +13,6 @@ import net.sourceforge.pmd.rules.UnnecessaryConversionTemporaryRule; public class UnnecessaryTemporariesRuleTest extends RuleTst{ - public UnnecessaryTemporariesRuleTest(String name) { - super(name); - } - public void testUnnecessaryTemporaries() throws Throwable { Report report = process("UnnecessaryTemporary.java", new UnnecessaryConversionTemporaryRule()); assertEquals(6, report.size()); diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/UnusedImportsRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/UnusedImportsRuleTest.java index e7c83814bd..b3e098c2e9 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/UnusedImportsRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/UnusedImportsRuleTest.java @@ -9,9 +9,6 @@ import net.sourceforge.pmd.rules.UnusedImportsRule; import net.sourceforge.pmd.Report; public class UnusedImportsRuleTest extends RuleTst { - public UnusedImportsRuleTest(String name) { - super(name); - } private UnusedImportsRule rule; diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/UnusedLocalVariableTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/UnusedLocalVariableTest.java index 0ab043d562..219ab23225 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/UnusedLocalVariableTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/UnusedLocalVariableTest.java @@ -18,10 +18,6 @@ public class UnusedLocalVariableTest extends RuleTst { private UnusedLocalVariableRule rule; - public UnusedLocalVariableTest(String name) { - super(name); - } - public void setUp() { rule = new UnusedLocalVariableRule(); rule.setMessage("Avoid this stuff -> ''{0}''"); diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/UnusedPrivateInstanceVariableRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/UnusedPrivateInstanceVariableRuleTest.java index 620a2663da..f560f2ab5c 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/UnusedPrivateInstanceVariableRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/UnusedPrivateInstanceVariableRuleTest.java @@ -17,10 +17,6 @@ public class UnusedPrivateInstanceVariableRuleTest extends RuleTst { private UnusedPrivateInstanceVariableRule rule; - public UnusedPrivateInstanceVariableRuleTest(String name) { - super(name); - } - public void setUp() { rule = new UnusedPrivateInstanceVariableRule(); rule.setMessage("Avoid this stuff -> ''{0}''"); diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/UnusedPrivateMethodRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/UnusedPrivateMethodRuleTest.java index 4790475aa4..a7bc762e6d 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/UnusedPrivateMethodRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/UnusedPrivateMethodRuleTest.java @@ -11,10 +11,6 @@ import net.sourceforge.pmd.Report; public class UnusedPrivateMethodRuleTest extends RuleTst { private UnusedPrivateMethodRule rule; - public UnusedPrivateMethodRuleTest(String name) { - super(name); - } - public void setUp() { rule = new UnusedPrivateMethodRule(); rule.setMessage("Avoid this stuff -> ''{0}''"); diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/WhileLoopsMustUseBracesRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/WhileLoopsMustUseBracesRuleTest.java index 84fef16ffd..4a114e057f 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/WhileLoopsMustUseBracesRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/WhileLoopsMustUseBracesRuleTest.java @@ -9,9 +9,6 @@ import net.sourceforge.pmd.Report; import net.sourceforge.pmd.rules.WhileLoopsMustUseBracesRule; public class WhileLoopsMustUseBracesRuleTest extends RuleTst { - public WhileLoopsMustUseBracesRuleTest(String name) { - super(name); - } public void test1() throws Throwable { Report report = process("WhileLoopsNeedBraces1.java", new WhileLoopsMustUseBracesRule()); 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 2484d0e842..1393a8b196 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/design/LongClassRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/design/LongClassRuleTest.java @@ -10,9 +10,7 @@ import test.net.sourceforge.pmd.rules.RuleTst; public class LongClassRuleTest extends RuleTst { - public LongClassRuleTest( String name ) { - super( name ); - } + public LongClassRule getIUT() { LongClassRule IUT = new LongClassRule(); 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 94325f22ee..094ae32e41 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/design/LongMethodRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/design/LongMethodRuleTest.java @@ -10,9 +10,6 @@ import test.net.sourceforge.pmd.rules.RuleTst; public class LongMethodRuleTest extends RuleTst { - public LongMethodRuleTest( String name ) { - super( name ); - } public LongMethodRule getIUT() { LongMethodRule IUT = new LongMethodRule(); 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 fc77dec188..34dacf7c12 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/design/LongParameterListRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/design/LongParameterListRuleTest.java @@ -10,10 +10,6 @@ import test.net.sourceforge.pmd.rules.RuleTst; public class LongParameterListRuleTest extends RuleTst { - public LongParameterListRuleTest( String name ) { - super( name ); - } - public LongParameterListRule getIUT() { LongParameterListRule IUT = new LongParameterListRule(); IUT.addProperty("minimum", "9"); 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 7f938709b4..0172a925ad 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/design/LooseCouplingRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/design/LooseCouplingRuleTest.java @@ -14,10 +14,6 @@ import net.sourceforge.pmd.RuleViolation; public class LooseCouplingRuleTest extends RuleTst { private LooseCouplingRule rule; - public LooseCouplingRuleTest(String name) { - super(name); - } - public void setUp() { rule = new LooseCouplingRule(); rule.setMessage("Avoid this stuff -> ''{0}''"); 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 5c33db44af..beacb28aa9 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/design/PositionalIteratorRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/design/PositionalIteratorRuleTest.java @@ -13,10 +13,6 @@ import net.sourceforge.pmd.rules.design.PositionalIteratorRule; public class PositionalIteratorRuleTest extends RuleTst { - public PositionalIteratorRuleTest(String name) { - super(name); - } - public void test1() throws Throwable { runTest("PositionalIterator1.java", 1, new PositionalIteratorRule()); } 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 80e84c1e0b..7bc70363e4 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/design/UseSingletonRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/design/UseSingletonRuleTest.java @@ -18,9 +18,6 @@ import net.sourceforge.pmd.stat.Metric; public class UseSingletonRuleTest extends RuleTst implements ReportListener { - public UseSingletonRuleTest( String name ) { - super( name ); - } public void testUseSingleton1() throws Throwable diff --git a/pmd/src/net/sourceforge/pmd/PMD.java b/pmd/src/net/sourceforge/pmd/PMD.java index 11ccc267ad..8096b68eac 100644 --- a/pmd/src/net/sourceforge/pmd/PMD.java +++ b/pmd/src/net/sourceforge/pmd/PMD.java @@ -33,7 +33,7 @@ public class PMD { try { JavaParser parser = new JavaParser(reader); ASTCompilationUnit c = parser.CompilationUnit(); - ///c.dump(""); + //c.dump(""); List acus = new ArrayList(); acus.add(c); ruleSet.apply(acus, ctx); diff --git a/pmd/src/net/sourceforge/pmd/rules/StringInstantiationRule.java b/pmd/src/net/sourceforge/pmd/rules/StringInstantiationRule.java index 936757e153..6314972eab 100644 --- a/pmd/src/net/sourceforge/pmd/rules/StringInstantiationRule.java +++ b/pmd/src/net/sourceforge/pmd/rules/StringInstantiationRule.java @@ -7,19 +7,26 @@ package net.sourceforge.pmd.rules; import net.sourceforge.pmd.AbstractRule; import net.sourceforge.pmd.RuleContext; -import net.sourceforge.pmd.ast.ASTVariableDeclaratorId; -import net.sourceforge.pmd.ast.ASTAllocationExpression; -import net.sourceforge.pmd.ast.SimpleNode; -import net.sourceforge.pmd.ast.ASTArrayDimsAndInits; +import net.sourceforge.pmd.ast.*; public class StringInstantiationRule extends AbstractRule { public Object visit(ASTAllocationExpression node, Object data) { SimpleNode typeAllocatedNode = (SimpleNode)node.jjtGetChild(0); if (typeAllocatedNode.getImage().equals("String") && !(node.jjtGetChild(1) instanceof ASTArrayDimsAndInits)) { - RuleContext ctx = (RuleContext)data; - ctx.getReport().addRuleViolation(createRuleViolation(ctx, node.getBeginLine())); + + // if it's String(byte[], int, int), skip it + ASTArguments args = (ASTArguments)node.jjtGetChild(1); + if (!skipDueToByteArrayConversion(args)) { + RuleContext ctx = (RuleContext)data; + ctx.getReport().addRuleViolation(createRuleViolation(ctx, node.getBeginLine())); + } + } return data; } + + private boolean skipDueToByteArrayConversion(ASTArguments args) { + return args.jjtGetNumChildren() > 0 && args.jjtGetChild(0).jjtGetNumChildren() == 3; + } } diff --git a/pmd/test-data/StringInstantiation3.java b/pmd/test-data/StringInstantiation3.java new file mode 100644 index 0000000000..70909d2dec --- /dev/null +++ b/pmd/test-data/StringInstantiation3.java @@ -0,0 +1,6 @@ +public class StringInstantiation3 { + public void foo() { + byte[] bytes = new byte[50]; + String bar = new String(bytes, 0, bytes.length); + } +}