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:
Tom Copeland
2002-09-04 14:59:34 +00:00
parent a982288189
commit bb36eace93
3 changed files with 71 additions and 59 deletions

View File

@ -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
View 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>

View File

@ -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