moved some rules into a new braces ruleset
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@833 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -62,30 +62,6 @@ while (a == b) {
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="IfElseStmtsMustUseBracesRule"
|
||||
message="Avoid using 'if...else' statements without curly braces"
|
||||
class="net.sourceforge.pmd.rules.IfElseStmtsMustUseBracesRule">
|
||||
<description>
|
||||
Avoid using if..else statements without using curly braces
|
||||
</description>
|
||||
|
||||
<example>
|
||||
<![CDATA[
|
||||
|
||||
public void doSomething() {
|
||||
// this is OK
|
||||
if (foo) x++;
|
||||
|
||||
// but this is not
|
||||
if (foo)
|
||||
x=x+1;
|
||||
else
|
||||
x=x-1;
|
||||
}
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="UnnecessaryConversionTemporaryRule"
|
||||
message="Avoid unnecessary temporaries when converting primitives to Strings"
|
||||
class="net.sourceforge.pmd.rules.UnnecessaryConversionTemporaryRule">
|
||||
@ -181,40 +157,6 @@ public void bar() {
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="WhileLoopsMustUseBracesRule"
|
||||
message="Avoid using 'while' statements without curly braces"
|
||||
class="net.sourceforge.pmd.rules.WhileLoopsMustUseBracesRule">
|
||||
<description>
|
||||
Avoid using 'while' statements without using curly braces
|
||||
</description>
|
||||
|
||||
<example>
|
||||
<![CDATA[
|
||||
public void doSomething() {
|
||||
while (true)
|
||||
x++;
|
||||
}
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="ForLoopsMustUseBracesRule"
|
||||
message="Avoid using 'for' statements without curly braces"
|
||||
class="net.sourceforge.pmd.rules.ForLoopsMustUseBracesRule">
|
||||
<description>
|
||||
Avoid using 'for' statements without using curly braces
|
||||
</description>
|
||||
|
||||
<example>
|
||||
<![CDATA[
|
||||
public void foo() {
|
||||
for (int i=0; i<42;i++)
|
||||
foo();
|
||||
}
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
</ruleset>
|
||||
|
||||
|
||||
|
70
pmd/rulesets/braces.xml
Normal file
70
pmd/rulesets/braces.xml
Normal file
@ -0,0 +1,70 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<ruleset name="Braces Rules">
|
||||
<description>
|
||||
The Braces Ruleset contains a collection of braces rules.
|
||||
</description>
|
||||
|
||||
|
||||
<rule name="IfElseStmtsMustUseBracesRule"
|
||||
message="Avoid using 'if...else' statements without curly braces"
|
||||
class="net.sourceforge.pmd.rules.IfElseStmtsMustUseBracesRule">
|
||||
<description>
|
||||
Avoid using if..else statements without using curly braces
|
||||
</description>
|
||||
|
||||
<example>
|
||||
<![CDATA[
|
||||
|
||||
public void doSomething() {
|
||||
// this is OK
|
||||
if (foo) x++;
|
||||
|
||||
// but this is not
|
||||
if (foo)
|
||||
x=x+1;
|
||||
else
|
||||
x=x-1;
|
||||
}
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="WhileLoopsMustUseBracesRule"
|
||||
message="Avoid using 'while' statements without curly braces"
|
||||
class="net.sourceforge.pmd.rules.WhileLoopsMustUseBracesRule">
|
||||
<description>
|
||||
Avoid using 'while' statements without using curly braces
|
||||
</description>
|
||||
|
||||
<example>
|
||||
<![CDATA[
|
||||
public void doSomething() {
|
||||
while (true)
|
||||
x++;
|
||||
}
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="ForLoopsMustUseBracesRule"
|
||||
message="Avoid using 'for' statements without curly braces"
|
||||
class="net.sourceforge.pmd.rules.ForLoopsMustUseBracesRule">
|
||||
<description>
|
||||
Avoid using 'for' statements without using curly braces
|
||||
</description>
|
||||
|
||||
<example>
|
||||
<![CDATA[
|
||||
public void foo() {
|
||||
for (int i=0; i<42;i++)
|
||||
foo();
|
||||
}
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
</ruleset>
|
||||
|
||||
|
||||
|
@ -1 +1 @@
|
||||
rulesets.filenames=rulesets/basic.xml,rulesets/unusedcode.xml,rulesets/design.xml,rulesets/naming.xml,rulesets/imports.xml
|
||||
rulesets.filenames=rulesets/braces.xml,rulesets/basic.xml,rulesets/unusedcode.xml,rulesets/design.xml,rulesets/naming.xml,rulesets/imports.xml
|
Reference in New Issue
Block a user