git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@113253 13f79535-47bb-0310-9956-ffa450edef68
91 lines
2.1 KiB
XML
91 lines
2.1 KiB
XML
<?xml version="1.0"?>
|
|
|
|
<ruleset name="experimental">
|
|
<description>
|
|
This is the sandbox.
|
|
</description>
|
|
|
|
<!--<rule name="UnnecessaryCast"
|
|
message="Avoid unnecessary casts"
|
|
class="net.sourceforge.pmd.rules.UnnecessaryCastRule">
|
|
<description>
|
|
A variable is cast to itself, one of its supertypes or one of its interfaces. Usually
|
|
indicates that the programmer is not clear on the class structure they
|
|
are working with.
|
|
</description>
|
|
|
|
<example>
|
|
<![CDATA[
|
|
public Collection doSomething() {
|
|
List list = new ArrayList();
|
|
|
|
return (Collection) list; // Unnecessary Cast
|
|
}
|
|
]]>
|
|
</example>
|
|
</rule>
|
|
|
|
<rule name="PositionalIterator"
|
|
message="Avoid positional iterators"
|
|
class="net.sourceforge.pmd.rules.design.PositionalIteratorRule">
|
|
<description>
|
|
Avoid positional iterators. This doesn't work yet,
|
|
it breaks on stuff like this:
|
|
public class Foo {
|
|
private int baz = true;
|
|
public void bar(Iterator i) {
|
|
Object x = null;
|
|
while (i.hasNext()) {
|
|
if (baz) {
|
|
x = i.next();
|
|
} else {
|
|
x = new Runnable() {public void run() {Object bif = i.next();}}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
See javax.security.auth.Subject.java, inner class SecureSet, method removeAll(), around line 1092 for a good example.
|
|
</description>
|
|
|
|
<example>
|
|
<![CDATA[
|
|
public class PositionalIterators {
|
|
public void foo(Iterator i) {
|
|
while(i.hasNext()) {
|
|
Object one = i.next();
|
|
// 2 calls to next() inside the loop == bad!
|
|
Object two = i.next();
|
|
}
|
|
}
|
|
}
|
|
]]>
|
|
</example>
|
|
</rule>
|
|
|
|
<rule name="StringConcatenation"
|
|
message="Consider replacing String concatenation inside loops with a StringBuffer"
|
|
class="net.sourceforge.pmd.rules.StringConcatenationRule">
|
|
<description>
|
|
Consider replacing String concatenation inside loops with a StringBuffer
|
|
</description>
|
|
|
|
<example>
|
|
<![CDATA[
|
|
public class Bar {
|
|
public String foo(Object[] someArray) {
|
|
String list = "" ;
|
|
for( int i = 0; i < someArray.length; i++ ){
|
|
list = list + "," + someArray[i];
|
|
}
|
|
return list;
|
|
}
|
|
}
|
|
]]>
|
|
</example>
|
|
</rule>
|
|
-->
|
|
</ruleset>
|
|
|
|
|
|
|