Moved BooleanInversion to controversial ruleset until I can look at it a bit more

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@4139 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Tom Copeland
2006-01-13 22:43:15 +00:00
parent 57d7077984
commit 7ed77999e6
4 changed files with 35 additions and 33 deletions

View File

@ -8,7 +8,8 @@ New rules:
JUnit ruleset: UseAssertNullInsteadOfAssertTrue
Strings ruleset: AppendCharacterWithChar, ConsecutiveLiteralAppends, UseIndexOfChar
Design ruleset: AvoidConstantsInterface
Optimizations ruleset: UseArraysAsList, AvoidArrayLoops, BooleanInversion
Optimizations ruleset: UseArraysAsList, AvoidArrayLoops
Controversial ruleset: BooleanInversion
Fixed bug 1277373 - InefficientStringBuffering now catches more cases.
Fixed bug 1371757 - Misleading example in AvoidSynchronizedAtMethodLevel
Fixed bug 1371980 - InefficientStringBuffering no longer flags StringBuffer methods other than append().

View File

@ -11,7 +11,7 @@ public class BooleanInversionTest extends SimpleAggregatorTst {
private Rule rule;
public void setUp() throws RuleSetNotFoundException {
rule = findRule("optimizations", "BooleanInversion");
rule = findRule("controversial", "BooleanInversion");
}
public void testAll() {

View File

@ -355,6 +355,38 @@ Use explicit scoping instead of the default package private level
<priority>3</priority>
</rule>
<rule name="BooleanInversion"
message="Use bitwise inversion to invert boolean values"
class="net.sourceforge.pmd.rules.XPathRule"
externalInfoUrl="http://pmd.sourceforge.net/rules/controversial.html#BooleanInversion">
<description>
Use bitwise inversion to invert boolean values - it's the fastest way to do this.
See http://www.javaspecialists.co.za/archive/newsletter.do?issue=042&amp;locale=en_US for specific details
</description>
<properties>
<property name="xpath">
<value>
<![CDATA[
//AssignmentOperator[@Image="="]/../Expression/UnaryExpressionNotPlusMinus[@Image="!"]
]]>
</value>
</property>
</properties>
<priority>3</priority>
<example>
<![CDATA[
public class Foo {
public void main(bar) {
boolean b = true;
b = !b; // slow
b ^= true; // fast
}
}
]]>
</example>
</rule>
</ruleset>

View File

@ -290,37 +290,6 @@ public class Test {
</rule>
<rule name="BooleanInversion"
message="Use bitwise inversion to invert boolean values"
class="net.sourceforge.pmd.rules.XPathRule"
externalInfoUrl="http://pmd.sourceforge.net/rules/optimizations.html#BooleanInversion">
<description>
Use bitwise inversion to invert boolean values - it's the fastest way to do this.
See http://www.javaspecialists.co.za/archive/newsletter.do?issue=042&amp;locale=en_US for specific details
</description>
<properties>
<property name="xpath">
<value>
<![CDATA[
//AssignmentOperator[@Image="="]/../Expression/UnaryExpressionNotPlusMinus[@Image="!"]
]]>
</value>
</property>
</properties>
<priority>3</priority>
<example>
<![CDATA[
public class Foo {
public void main(bar) {
boolean b = true;
b = !b; // slow
b ^= true; // fast
}
}
]]>
</example>
</rule>
<!--
other optimization should be like avoiding