diff --git a/pmd/etc/changelog.txt b/pmd/etc/changelog.txt index db79143b88..c4ef9a478e 100644 --- a/pmd/etc/changelog.txt +++ b/pmd/etc/changelog.txt @@ -443,7 +443,7 @@ Fixed character reference in xml report - thanks to Seko New Java rules: - Basic ruleset: ExtendsObject,CheckSkipResult,AvoidBranchingStatementAsLastInLoop + Basic ruleset: ExtendsObject,CheckSkipResult,AvoidBranchingStatementAsLastInLoop,DontCallThreadRun Controversial ruleset: AvoidLiteralsInIfCondition, AvoidPrefixingMethodParameters, OneDeclarationPerLine, UseConcurrentHashMap Coupling ruleset: LoosePackageCoupling,LawofDemeter Design ruleset: LogicInversion,UseVarargs,FieldDeclarationsShouldBeAtStartOfClass,GodClass diff --git a/pmd/regress/test/net/sourceforge/pmd/lang/java/rule/basic/BasicRulesTest.java b/pmd/regress/test/net/sourceforge/pmd/lang/java/rule/basic/BasicRulesTest.java index 55a0db2895..caf6299669 100644 --- a/pmd/regress/test/net/sourceforge/pmd/lang/java/rule/basic/BasicRulesTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/lang/java/rule/basic/BasicRulesTest.java @@ -8,7 +8,7 @@ import org.junit.Before; import test.net.sourceforge.pmd.testframework.SimpleAggregatorTst; public class BasicRulesTest extends SimpleAggregatorTst { - + private static final String RULESET = "java-basic"; @Before @@ -34,6 +34,7 @@ public class BasicRulesTest extends SimpleAggregatorTst { addRule(RULESET, "MisplacedNullCheck"); addRule(RULESET, "OverrideBothEqualsAndHashcode"); addRule(RULESET, "ReturnFromFinallyBlock"); + addRule(RULESET, "DontCallThreadRun"); } public static junit.framework.Test suite() { diff --git a/pmd/regress/test/net/sourceforge/pmd/lang/java/rule/basic/xml/DontCallThreadRun.xml b/pmd/regress/test/net/sourceforge/pmd/lang/java/rule/basic/xml/DontCallThreadRun.xml new file mode 100644 index 0000000000..6ce4ed27c6 --- /dev/null +++ b/pmd/regress/test/net/sourceforge/pmd/lang/java/rule/basic/xml/DontCallThreadRun.xml @@ -0,0 +1,30 @@ + + + + + 1 + + + + + 1 + + + diff --git a/pmd/rulesets/java/basic.xml b/pmd/rulesets/java/basic.xml index c20b6dc407..627d2a4124 100644 --- a/pmd/rulesets/java/basic.xml +++ b/pmd/rulesets/java/basic.xml @@ -736,6 +736,45 @@ for (int i = 0; i < 10; i++) { + + +Explicitly calling Thread.run() method will execute in the caller's thread of control. Instead, call Thread.start() for the intended behavior. + + 4 + + + + + + + + + + + +