You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by vm...@apache.org on 2003/04/04 13:06:45 UTC

cvs commit: maven/src/plugins-build/pmd/xdocs changes.xml

vmassol     2003/04/04 03:06:45

  Modified:    src/plugins-build/pmd project.xml plugin.jelly
                        plugin.properties .cvsignore
               src/plugins-build/pmd/xdocs changes.xml
  Added:       src/plugins-build/pmd/src/plugin-resources/rulesets
                        imports.xml codesize.xml naming.xml
                        experimental.xml basic.xml braces.xml strings.xml
                        newrules.xml coupling.xml junit.xml unusedcode.xml
                        design.xml controversial.xml favorites.xml
               src/plugins-build/pmd/src/plugin-resources pmd.jsl
  Removed:     src/plugins-build/pmd/rulesets favorites.xml design.xml
                        imports.xml rulesets.properties codesize.xml
                        junit.xml unusedcode.xml basic.xml strings.xml
                        naming.xml newrules.xml experimental.xml braces.xml
               src/plugins-build/pmd pmd.jsl
  Log:
  Made the plugin work with Maven b9
  
  Revision  Changes    Path
  1.1                  maven/src/plugins-build/pmd/src/plugin-resources/rulesets/imports.xml
  
  Index: imports.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <ruleset name="Import Rules">
    <description>
  These rules deal with different problems that can occur with a class' import statements.
    </description>
  
    <rule name="DuplicateImports"
          message="Avoid duplicate imports such as ''{0}''"
          class="net.sourceforge.pmd.rules.DuplicateImportsRule">
      <description>
      Avoid duplicate import statements.
      </description>
        <priority>4</priority>
  
      <example>
  <![CDATA[
  // this is bad
  import java.io.File;
  import java.io.File;
  public class Foo {}
  
  // --- in another source code file...
  
  // this is bad
  import java.io.*;
  import java.io.File;
  
  public class Foo {}
  ]]>
      </example>
      </rule>
  
    <rule name="DontImportJavaLang"
          message="Avoid importing anything from the package 'java.lang'"
          class="net.sourceforge.pmd.rules.XPathRule">
      <description>
      Avoid importing anything from the package 'java.lang'.  These classes are automatically imported (JLS 7.5.3).
      </description>
        <properties>
            <property name="xpath">
                <value>
                    <![CDATA[
  //ImportDeclaration
   [starts-with(Name/@Image, 'java.lang')]
   [not(starts-with(Name/@Image, 'java.lang.ref'))]
   [not(starts-with(Name/@Image, 'java.lang.reflect'))]
                  ]]>
                </value>
            </property>
         </properties>
        <priority>4</priority>
  
      <example>
  <![CDATA[
  // this is bad
  import java.lang.String;
  public class Foo {}
  
  // --- in another source code file...
  
  // this is bad
  import java.lang.*;
  
  public class Foo {}
  ]]>
      </example>
      </rule>
  
    <rule name="UnusedImports"
          message="Avoid unused imports such as ''{0}''"
          class="net.sourceforge.pmd.rules.UnusedImportsRule">
      <description>
      Avoid unused import statements.
      </description>
        <priority>4</priority>
  
      <example>
  <![CDATA[
  // this is bad
  import java.io.File;
  public class Foo {}
  ]]>
      </example>
      </rule>
  
      <rule name="ImportFromSamePackage"
           message="No need to import a type that's in the same package"
           class="net.sourceforge.pmd.rules.ImportFromSamePackageRule">
       <description>
       No need to import a type that's in the same package.
       </description>
          <priority>3</priority>
       <example>
   <![CDATA[
   package foo;
   import foo.Buz; // no need for this
   public class Bar{}
   ]]>
       </example>
       </rule>
  
  </ruleset>
  
  
  
  
  
  
  1.1                  maven/src/plugins-build/pmd/src/plugin-resources/rulesets/codesize.xml
  
  Index: codesize.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <ruleset name="Code Size Rules">
    <description>
  The Code Size Ruleset contains a collection of rules that find code size related problems.
    </description>
  
  
   <rule name="ExcessiveMethodLength"
         message="Avoid really long methods."
         class="net.sourceforge.pmd.rules.design.LongMethodRule">
     <description>
  Excessive Method Length usually means that the method is doing
  too much.  There is usually quite a bit of Cut and Paste there
  as well.  Try to reduce the method size by creating helper methods,
  and removing cut and paste.
  
  Default value is 2.5 sigma greater than the mean.
  
  NOTE:  In version 0.9 and higher, their are three parameters available:
  minimum - Minimum Length before reporting.
  sigma - Std Deviations away from the mean before reporting.
  topscore - The Maximum Number of reports to generate.
  
  At this time, only one can be used at a time.
  
     </description>
       <priority>3</priority>
     <properties>
      <property name="minimum" value="100"/>
     </properties>
     <example>
  <![CDATA[
  public void doSomething() {
    System.out.println("I am a fish.");
    System.out.println("I am a fish.");
    System.out.println("I am a fish.");
    System.out.println("I am a fish.");
    System.out.println("I am a fish.");
    // 495 copies omitted for brevity.
  }
  ]]>
     </example>
  
   </rule>
  
  
   <rule name="ExcessiveParameterList"
         message="Avoid really long parameter lists."
         class="net.sourceforge.pmd.rules.design.LongParameterListRule">
     <description>
  This checks to make sure that the Parameter Lists in the project aren't
  getting too long.  If there are long parameter lists, then that is
  generally indicative that another object is hiding around there.
  
  Basically, try to group the parameters together.
  
  Default value is 2.5 sigma greater than the mean.
  
  NOTE:  In version 0.9 and higher, their are three parameters available:
  minimum - Minimum Length before reporting.
  sigma - Std Deviations away from the mean before reporting.
  topscore - The Maximum Number of reports to generate.
  
  At this time, only one can be used at a time.
  
     </description>
       <priority>3</priority>
     <properties>
      <property name="minimum" value="10"/>
     </properties>
     <example>
  <![CDATA[
  public void addData(
    int p00, int p01, int p02, int p03, int p04, int p05,
    int p05, int p06, int p07, int p08, int p09, int p10) {
  
    }
  }
  ]]>
     </example>
  
   </rule>
  
  
   <rule name="ExcessiveClassLength"
         message="Avoid really long Classes."
         class="net.sourceforge.pmd.rules.design.LongClassRule">
     <description>
  Long Class files are indications that the class may be trying to
  do too much.  Try to break it down, and reduce the size to something
  managable.
  
  Default value is 2.5 sigma greater than the mean.
  
  NOTE:  In version 0.9 and higher, their are three parameters available:
  minimum - Minimum Length before reporting.
  sigma - Std Deviations away from the mean before reporting.
  topscore - The Maximum Number of reports to generate.
  
  At this time, only one can be used at a time.
  
     </description>
       <priority>3</priority>
     <properties>
      <property name="minimum" value="1000"/>
     </properties>
     <example>
  <![CDATA[
  public class Foo {
    public void bar() {
      // 500 lines of code
    }
  
    public void baz() {
      // 500 more lines of code
    }
  }
  ]]>
     </example>
   </rule>
  
  
      <rule name="CyclomaticComplexityRule"
        message = "The {0} ''{1}'' has a Cyclomatic Complexity of {2}."
        class="net.sourceforge.pmd.rules.CyclomaticComplexityRule">
     <description>
  Complexity is determined by the number of decision points in a method plus one for the
  method entry.  The decision points are 'if', 'while', 'for', and 'case labels'.  Scale:
  1-4 (low complexity)   5-7 (moderate complexity)   8-10 (high complexity)   10+ (very high complexity)
     </description>
     <priority>3</priority>
     <properties>
        <property name="reportLevel" value="10"/>
     </properties>
     <example>
  <![CDATA[
  Cyclomatic Complexity = 12
  
  public class Foo
  {
  1   public void example()
      {
  2       if (a == b)
          {
  3           if (a1 == b1)
              {
                  do something;
              }
  4           else if a2 == b2)
              {
                  do something;
              }
              else
              {
                  do something;
              }
          }
  5       else if (c == d)
          {
  6           while (c == d)
              {
                  do something;
              }
          }
  7       else if (e == f)
          {
  8           for (int n = 0; n < h; n++)
              {
                  do something;
              }
          }
          else
          {
              switch (z)
              {
  9               case 1:
                      do something;
                      break;
  
  10              case 2:
                      do something;
                      break;
  
  11              case 3:
                      do something;
                      break;
  
  12              default:
                      do something;
                      break;
              }
          }
      }
  }
  ]]>
     </example>
  </rule>
  
      <rule name="ExcessivePublicCountRule"
      message="A high number of public methods and attributes in an object can indicate the class may need to be broken up for exhaustive testing may prove difficult."
      class="net.sourceforge.pmd.rules.ExcessivePublicCountRule">
      <description>
      A large amount of public methods and attributes declared in an object can indicate the class may need
      to be broken up as increased effort will be required to thoroughly test such a class.
      </description>
      <priority>3</priority>
      <properties>
      <property name="minimum" value="45"/>
      </properties>
      <example>
      <![CDATA[
  
      public class Foo {
      public String value;
      public Bar something;
      public Variable var;
      //more public attributes
      public void doWork() {}
      public void doMoreWork() {}
      public void doWorkAgain() {}
      public void doWorking() {}
      public void doWorkIt() {}
      public void doWorkingAgain() {}
      public void doWorkAgainAgain() {}
      public void doWorked() {}
  
      }
      ]]>
      </example>
      </rule>
  
  
  </ruleset>
  
  
  
  
  
  
  1.1                  maven/src/plugins-build/pmd/src/plugin-resources/rulesets/naming.xml
  
  Index: naming.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <ruleset name="Naming Rules">
    <description>
  The Naming Ruleset contains a collection of rules about names - too long, too short, and so forth.
    </description>
  
  
    <rule name="ShortVariable"
          message="Avoid variables with short names"
          class="net.sourceforge.pmd.rules.XPathRule">
      <description>
  Detects when a field, local or parameter has a short name.
      </description>
        <properties>
            <property name="xpath">
                <value>
                    <![CDATA[
      //VariableDeclaratorId[string-length(@Image) < 3][not(ancestor::ForInit)]
                    ]]>
                </value>
            </property>
        </properties>
        <priority>3</priority>
      <example>
  <![CDATA[
  public class Something {
    private int q = 15; // VIOLATION - Field
  
    public static void main( String as[] ) {  // VIOLATION - Formal
      int r = 20 + q; // VIOLATION - Local
  
      for (int i = 0; i < 10; i++) { // Not a Violation (inside FOR)
        r += q;
      }
    }
  }
  ]]>
      </example>
    </rule>
  
    <rule name="LongVariable"
          message="Avoid excessively long variable names"
          class="net.sourceforge.pmd.rules.XPathRule">
      <description>
  Detects when a field, formal or local variable is declared with a big name.
      </description>
        <priority>3</priority>
        <properties>
            <property name="xpath">
                <value>
                    <![CDATA[
      //VariableDeclaratorId[string-length(@Image) > 12]
                    ]]>
                </value>
            </property>
        </properties>
      <example>
  <![CDATA[
  public class Something {
    int reallyLongIntName = -3;  // VIOLATION - Field
  
    public static void main( String argumentsList[] ) { // VIOLATION - Formal
      int otherReallyLongName = -5; // VIOLATION - Local
  
      for (int interestingIntIndex = 0;  // VIOLATION - For
               interestingIntIndex < 10;
               interestingIntIndex ++ ) {
  
      }
  }
  
  ]]>
      </example>
    </rule>
  
    <rule name="ShortMethodNameRule"
          message="Avoid using short method names"
          class="net.sourceforge.pmd.rules.XPathRule">
       <description>
  Detects when very short method names are used.
       </description>
        <priority>3</priority>
        <properties>
            <property name="xpath">
                <value>
                    <![CDATA[
      //MethodDeclarator[string-length(@Image) < 3]
                    ]]>
                </value>
            </property>
        </properties>
       <example>
  <![CDATA[
  public class ShortMethod {
    public void a( int i ) { // Violation
    }
  }
  ]]>
       </example>
    </rule>
  
  </ruleset>
  
  
  
  
  
  
  1.1                  maven/src/plugins-build/pmd/src/plugin-resources/rulesets/experimental.xml
  
  Index: experimental.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>
  
  
  
  
  
  
  1.1                  maven/src/plugins-build/pmd/src/plugin-resources/rulesets/basic.xml
  
  Index: basic.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <ruleset name="Basic Rules">
    <description>
  The Basic Ruleset contains a collection of good practices which everyone should follow.
    </description>
  
  
      <rule name="EmptyCatchBlock"
            message="Avoid empty catch blocks"
            class="net.sourceforge.pmd.rules.XPathRule">
        <description>
    Empty Catch Block finds instances where an exception is caught,
    but nothing is done.  In most circumstances, this swallows an exception
    which should either be acted on or reported.
        </description>
        <properties>
            <property name="xpath">
                <value>
                    <![CDATA[
      //TryStatement[@Catch='true']/Block[position() > 1]
      [count(*) = 0]
      [../@Finally='false' or following-sibling::Block]
                    ]]>
                </value>
            </property>
        </properties>
          <priority>3</priority>
  
        <example>
    <![CDATA[
      public void doSomething() {
        try {
          FileInputStream fis = new FileInputStream("/tmp/bugger");
        } catch (IOException ioe) {
            // not good
        }
      }
    ]]>
        </example>
      </rule>
  
      <rule name="EmptyIfStmt"
            message="Avoid empty 'if' statements"
            class="net.sourceforge.pmd.rules.XPathRule">
        <description>
    Empty If Statement finds instances where a condition is checked but nothing is done about it.
      </description>
          <priority>3</priority>
        <properties>
            <property name="xpath">
                <value>
                    <![CDATA[
                      //IfStatement/Statement/Block[count(*) = 0]
                    ]]>
                </value>
            </property>
        </properties>
        <example>
    <![CDATA[
      if (absValue < 1) {
         // not good
      }
    ]]>
         </example>
      </rule>
  
  
      <rule name="EmptyWhileStmt"
            message="Avoid empty 'while' statements"
            class="net.sourceforge.pmd.rules.XPathRule">
         <description>
    Empty While Statement finds all instances where a while statement
    does nothing.  If it is a timing loop, then you should use Thread.sleep() for it; if
    it's a while loop that does a lot in the exit expression, rewrite it to make it clearer.
         </description>
        <properties>
            <property name="xpath">
                <value>
                    <![CDATA[
      //WhileStatement/Statement/Block[count(*) = 0]
                    ]]>
                </value>
            </property>
        </properties>
          <priority>3</priority>
  
         <example>
    <![CDATA[
    while (a == b) {
      // not good
    }
    ]]>
         </example>
      </rule>
  
  
      <rule name="EmptyTryBlock"
            message="Avoid empty try blocks"
            class="net.sourceforge.pmd.rules.XPathRule">
        <description>
    Avoid empty try blocks - what's the point?
        </description>
        <properties>
            <property name="xpath">
                <value>
                    <![CDATA[
      //TryStatement/Block[1][count(*) = 0]
                    ]]>
                </value>
            </property>
        </properties>
          <priority>3</priority>
  
        <example>
    <![CDATA[
    // this is bad
    public void bar() {
        try {
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    ]]>
        </example>
      </rule>
  
      <rule name="EmptyFinallyBlock"
            message="Avoid empty finally blocks"
            class="net.sourceforge.pmd.rules.XPathRule">
        <description>
    Avoid empty finally blocks - these can be deleted.
        </description>
        <properties>
            <property name="xpath">
                <value>
                    <![CDATA[
      //TryStatement[@Finally='true']/Block[position() = last()][count(*) = 0]
                    ]]>
                </value>
            </property>
        </properties>
          <priority>3</priority>
  
        <example>
    <![CDATA[
    // this is bad
    public void bar() {
        try {
            int x=2;
        } finally {
        }
    }
    ]]>
        </example>
      </rule>
  
  
      <rule name="EmptySwitchStatements"
            message="Avoid empty switch statements"
            class="net.sourceforge.pmd.rules.XPathRule">
        <description>
        Avoid empty switch statements.
        </description>
        <properties>
            <property name="xpath">
                <value>
                    <![CDATA[
      //SwitchStatement[count(*) = 1]
                    ]]>
                </value>
            </property>
        </properties>
          <priority>3</priority>
  
        <example>
    <![CDATA[
    public class Foo {
     public void bar() {
      int x = 2;
      switch (x) {
       // once there was code here
       // but it's been commented out or something
      }
     }
    }
    ]]>
        </example>
        </rule>
  
  
      <rule name="JumbledIncrementer"
           message="Avoid using an outer loop incrementer in an inner loop for update expression"
           class="net.sourceforge.pmd.rules.XPathRule">
       <description>
       Avoid jumbled loop incrementers - it's usually a mistake, and it's confusing even if it's what's intended.
       </description>
       <properties>
           <property name="xpath">
               <value>
                   <![CDATA[
      //ForStatement[ForUpdate//Name/@Image = ancestor::ForStatement/ForInit//VariableDeclaratorId/@Image]
                   ]]>
               </value>
           </property>
       </properties>
          <priority>3</priority>
  
       <example>
   <![CDATA[
   public class JumbledIncrementerRule1 {
    public void foo() {
     for (int i = 0; i < 10; i++) {
      for (int k = 0; k < 20; i++) {
       System.out.println("Hello");
      }
     }
    }
   }}]]>
       </example>
       </rule>
  
  
      <rule name="ForLoopShouldBeWhileLoop"
            message="This for loop could be simplified to a while loop"
            class="net.sourceforge.pmd.rules.XPathRule">
        <description>
        Some for loops can be simplified to while loops - this makes them more concise.
        </description>
      <properties>
          <property name="xpath">
              <value>
                  <![CDATA[
      //ForStatement[count(*) > 1][not(ForInit)][not(ForUpdate)]
                  ]]>
              </value>
          </property>
      </properties>
          <priority>3</priority>
        <example>
    <![CDATA[
    public class Foo {
        void bar() {
            for (;true;) true; // No Init or Update part, may as well be: while (true)
        }
    }
    ]]>
        </example>
      </rule>
  
  
      <rule name="UnnecessaryConversionTemporaryRule"
            message="Avoid unnecessary temporaries when converting primitives to Strings"
            class="net.sourceforge.pmd.rules.UnnecessaryConversionTemporaryRule">
        <description>
        Avoid unnecessary temporaries when converting primitives to Strings
        </description>
          <priority>3</priority>
        <example>
    <![CDATA[
      public String convert(int x) {
        // this wastes an object
        String foo = new Integer(x).toString();
        // this is better
        return Integer.toString(x);
      }
    ]]>
        </example>
      </rule>
  
      <rule name="OverrideBothEqualsAndHashcodeRule"
            message="Ensure you override both equals() and hashCode()"
            class="net.sourceforge.pmd.rules.XPathRule">
        <description>
    Override both public boolean Object.equals(Object other), and public int Object.hashCode(), or override neither.  Even if you are inheriting a hashCode() from a parent class, consider implementing hashCode and explicitly delegating to your superclass.
        </description>
        <properties>
            <property name="xpath">
                <value>
                    <![CDATA[
        //ClassDeclaration//MethodDeclarator
        [
        (@Image = 'equals'
            and count(FormalParameters/*) = 1
            and not(//MethodDeclarator[count(FormalParameters/*) = 0][@Image = 'hashCode'])
         or
        (@Image='hashCode'
            and count(FormalParameters/*) = 0
            and not(//MethodDeclarator[count(FormalParameters//Type/Name[@Image = 'Object']) = 1][@Image = 'equals']))
        )]
                    ]]>
                </value>
            </property>
        </properties>
          <priority>3</priority>
  
        <example>
    <![CDATA[
    // this is bad
    public class Bar {
        public boolean equals(Object o) {
            // do some comparison
        }
    }
  
    // and so is this
    public class Baz {
        public int hashCode() {
            // return some hash value
        }
    }
  
    // this is OK
    public class Foo {
        public boolean equals(Object other) {
            // do some comparison
        }
        public int hashCode() {
            // return some hash value
        }
    }
    ]]>
        </example>
      </rule>
  
      <rule name="DoubleCheckedLockingRule"
            message="Double checked locking is not thread safe in Java."
            class="net.sourceforge.pmd.rules.DoubleCheckedLockingRule">
        <description>
        Partially created objects can be returned by the Double Checked Locking pattern when used in Java.
        An optimizing JRE may assign a reference to the baz variable before it creates the object the
            reference is intended to point to.  For more details see http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-double.html.
        </description>
          <priority>1</priority>
        <example>
    <![CDATA[
    public class Foo {
        Object baz;
        Object bar() {
          if(baz == null) { //baz may be non-null yet not fully created
            synchronized(this){
              if(baz == null){
                baz = new Object();
              }
            }
          }
          return baz;
        }
    }
    ]]>
        </example>
      </rule>
  
  </ruleset>
  
  
  
  
  
  
  1.1                  maven/src/plugins-build/pmd/src/plugin-resources/rulesets/braces.xml
  
  Index: braces.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <ruleset name="Braces Rules">
    <description>
  The Braces Ruleset contains a collection of braces rules.
    </description>
  
     <rule name="IfStmtsMustUseBraces"
           message="Avoid using if statements without curly braces"
           class="net.sourceforge.pmd.rules.XPathRule">
       <description>
       Avoid using if statements without using curly braces
       </description>
         <properties>
             <property name="xpath">
                 <value>
                     <![CDATA[
      //IfStatement[count(*) < 3][not(Statement/Block)]
                     ]]>
                 </value>
             </property>
         </properties>
         <priority>3</priority>
  
       <example>
   <![CDATA[
   public class Foo {
     public void bar() {
       int x = 0;
       if (foo) x++;
     }
   }
   ]]>
       </example>
       </rule>
  
      <rule name="WhileLoopsMustUseBracesRule"
            message="Avoid using 'while' statements without curly braces"
            class="net.sourceforge.pmd.rules.XPathRule">
        <description>
        Avoid using 'while' statements without using curly braces
        </description>
          <properties>
              <property name="xpath">
                  <value>
                      <![CDATA[
      //WhileStatement[not(Statement/Block)]
                      ]]>
                  </value>
              </property>
          </properties>
          <priority>3</priority>
  
        <example>
    <![CDATA[
      public void doSomething() {
        while (true)
            x++;
      }
    ]]>
        </example>
      </rule>
  
        <rule name="IfElseStmtsMustUseBracesRule"
             message="Avoid using 'if...else' statements without curly braces"
             class="net.sourceforge.pmd.rules.XPathRule">
         <description>
         Avoid using if..else statements without using curly braces
         </description>
           <properties>
               <property name="xpath">
                   <value>
                       <![CDATA[
      //IfStatement[count(*) > 2][not(Statement/Block)]
                       ]]>
                   </value>
               </property>
           </properties>
           <priority>3</priority>
  
         <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="ForLoopsMustUseBracesRule"
             message="Avoid using 'for' statements without curly braces"
             class="net.sourceforge.pmd.rules.XPathRule">
         <description>
         Avoid using 'for' statements without using curly braces
         </description>
           <properties>
               <property name="xpath">
                   <value>
                       <![CDATA[
      //ForStatement[not(Statement/Block)]
                       ]]>
                   </value>
               </property>
           </properties>
           <priority>3</priority>
  
         <example>
     <![CDATA[
       public void foo() {
         for (int i=0; i<42;i++)
             foo();
       }
     ]]>
         </example>
       </rule>
  
  </ruleset>
  
  
  
  
  
  
  1.1                  maven/src/plugins-build/pmd/src/plugin-resources/rulesets/strings.xml
  
  Index: strings.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <ruleset name="Strings Rules">
    <description>
  These rules deal with different problems that can occur with String manipulation.
    </description>
  
  
     <rule name="StringInstantiation"
          message="Avoid instantiating String objects; this is usually unnecessary."
          class="net.sourceforge.pmd.rules.XPathRule">
      <description>
      Avoid instantiating String objects; this is usually unnecessary.
      </description>
         <properties>
             <property name="xpath">
                 <value>
                     <![CDATA[
      //AllocationExpression[Name/@Image='String'][count(.//Expression) < 2][not(ArrayDimsAndInits)]
                      ]]>
                 </value>
             </property>
         </properties>
         <priority>2</priority>
  
      <example>
  <![CDATA[
  public class Foo {
   private String bar = new String("bar"); // just do a String bar = "bar";
  }
  ]]>
      </example>
      </rule>
  
      <rule name="AvoidDuplicateLiterals"
          message="The same String literal appears {0} times in this file; the first occurrence is on line {1}"
          class="net.sourceforge.pmd.rules.AvoidDuplicateLiteralsRule">
      <description>
  Code containing duplicate String literals can usually be improved by declaring the String as a constant field.
      </description>
          <priority>3</priority>
     <properties>
      <property name="threshold" value="4"/>
     </properties>
      <example>
  <![CDATA[
  public class Foo {
   private void bar() {
      buz("Howdy");
      buz("Howdy");
      buz("Howdy");
      buz("Howdy");
   }
   private void buz(String x) {}
  }
  ]]>
      </example>
    </rule>
  
     <rule name="StringToString"
          message="Avoid calling toString() on String objects; this is unnecessary"
          class="net.sourceforge.pmd.rules.StringToStringRule">
      <description>
      Avoid calling toString() on String objects; this is unnecessary
      </description>
         <priority>3</priority>
  
      <example>
  <![CDATA[
  public class Foo {
   private String baz() {
    String bar = "howdy";
    return bar.toString();
   }
  }
  ]]>
      </example>
      </rule>
  
  </ruleset>
  
  
  
  
  
  
  1.1                  maven/src/plugins-build/pmd/src/plugin-resources/rulesets/newrules.xml
  
  Index: newrules.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <ruleset name="newrules">
    <description>
  These are new rules for the next release
    </description>
  
  
  
      <rule name="SymbolTableTestRule"
            message="test"
            class="net.sourceforge.pmd.rules.SymbolTableTestRule">
        <description>
        asdsad
        </description>
          <priority>3</priority>
  
        <example>
    <![CDATA[
    // asdadas
    ]]>
        </example>
      </rule>
  
  
  
  
  
    </ruleset>
  
  
  
  
  
  1.1                  maven/src/plugins-build/pmd/src/plugin-resources/rulesets/coupling.xml
  
  Index: coupling.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <ruleset name="coupling">
    <description>
  	These are new rules for coupling
    </description>
  
      <rule name="CouplingBetweenObjectsRule"
          message="High amount of different objects as memebers donotes a high coupling"
          class="net.sourceforge.pmd.rules.CouplingBetweenObjectsRule">
      <description>
          Rule counts unique attributes, local variables and return types within an object. An amount
          higher than specified threshold can indicate a high degree of couping with in an object
      </description>
      <priority>3</priority>
      <properties>
        <property name="threshold" value="20"/>
      </properties>
      <example>
      <![CDATA[
        import com.Blah;
        import org.Bar;
        import org.Bardo;
        //
        public class Foo {
          private Blah var1;
          private Bar var2;
          //followed by many imports of unique objects
  
          void ObjectC doWork() {
             Bardo var55;
             ObjectA var44;
             ObjectZ var93;
             return something;
          }
  
          }
          ]]>
      </example>
    </rule>
  
    <rule name="ExcessiveImportsRule"
       message="A high number of imports can indicate a high degree of coupling within an object."
       class="net.sourceforge.pmd.rules.ExcessiveImportsRule">
       <description>
        A high number of imports can indicate a high degree of coupling within
        an object. Rule counts the number of unique imports and reports a violation
        if the count is above the user defined threshold.
    </description>
    <priority>3</priority>
    <properties>
        <property name="minimum" value="30"/>
    </properties>
    <example>
        <![CDATA[
        import blah.blah.Bardo;
        import blah.blah.Hardo;
        import blah.blah.Bar;
        import blah.net.ObjectA;
        //imports over some threshold
        public class Foo {
          public void doWork() {}
        }
        ]]>
    </example>
  
     </rule>
  
    </ruleset>
  
  
  
  
  
  1.1                  maven/src/plugins-build/pmd/src/plugin-resources/rulesets/junit.xml
  
  Index: junit.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <ruleset name="JUnit Rules">
    <description>
  These rules deal with different problems that can occur with JUnit tests.
    </description>
  
      <rule name="JUnitStaticSuite"
            message="You have a suite() method that is not both public and static, so JUnit won't call it to get your TestSuite.  Is that what you wanted to do?"
            class="net.sourceforge.pmd.rules.XPathRule">
        <description>
        The suite() method in a JUnit test needs to be both public and static.
        </description>
          <properties>
          <property name="xpath">
              <value>
                  <![CDATA[
    //MethodDeclaration[not(@Static='true') or not(@Public='true')][MethodDeclarator/@Image='suite']
                  ]]>
              </value>
          </property>
          </properties>
          <priority>3</priority>
  
        <example>
    <![CDATA[
    import junit.framework.*;
    public class Foo extends TestCase {
     public void suite() {} // oops, should be static
     private static void suite() {} // oops, should be public
    }
    ]]>
        </example>
        </rule>
  
  
    <rule name="JUnitSpelling"
          message="You may have misspelled a JUnit framework method (setUp or tearDown)"
          class="net.sourceforge.pmd.rules.XPathRule">
      <description>
      Some JUnit framework methods are easy to misspell.
      </description>
        <properties>
        <property name="xpath">
            <value>
                <![CDATA[
  //MethodDeclarator[(not(@Image = 'setUp') and translate(@Image, 'SETuP', 'setUp') = 'setUp') or (not(@Image = 'tearDown') and translate(@Image, 'TEARdOWN', 'tearDown') = 'tearDown')][FormalParameters[count(*) = 0]]
                ]]>
            </value>
        </property>
        </properties>
        <priority>3</priority>
  
      <example>
  <![CDATA[
  import junit.framework.*;
  public class Foo extends TestCase {
   public void setup() {} // oops, should be setUp
   public void TearDown() {} // oops, should be tearDown
  }
  ]]>
      </example>
      </rule>
  
      <rule name="JUnitAssertionsShouldIncludeMessageRule"
            message="JUnit assertions should include a message"
            class="net.sourceforge.pmd.rules.junit.JUnitAssertionsShouldIncludeMessageRule">
        <description>
        JUnit assertions should include a message - i.e., use the three argument version of
            assertEquals(), not the two argument version.
        </description>
          <priority>3</priority>
  
        <example>
    <![CDATA[
    public class Foo extends TestCase {
      public void testSomething() {
          assertEquals("foo", "bar");
          // not good!  use the form:
          // assertEquals("Foo does not equals bar", "foo", "bar");
          // instead
      }
    }
    ]]>
        </example>
      </rule>
  
  
  </ruleset>
  
  
  
  
  
  
  1.1                  maven/src/plugins-build/pmd/src/plugin-resources/rulesets/unusedcode.xml
  
  Index: unusedcode.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <ruleset name="Unused Code Rules">
    <description>
  The Unused Code Ruleset contains a collection of rules that find unused code.
    </description>
  
    <rule name="UnusedPrivateField"
          message="Avoid unused private fields such as ''{0}''"
          class="net.sourceforge.pmd.rules.UnusedPrivateFieldRule">
      <description>
  Unused Private Field detects when a private field is declared
  that is not used by the class.
      </description>
        <priority>3</priority>
      <example>
  <![CDATA[
  public class Something {
    private static int FOO = 2; // Unused
    private int i = 5; // Unused
    private int j = 6;
  
    public int addOne() {
      return j++;
    }
  }
  ]]>
      </example>
    </rule>
  
  <rule name="UnusedLocalVariable"
          message="Avoid unused local variables such as ''{0}''"
          class="net.sourceforge.pmd.rules.UnusedLocalVariableRule">
      <description>
  Unused Local Variables detects when a variable is declared, but not
  used (except for possibly initial assignment)
      </description>
      <priority>3</priority>
  
      <example>
  <![CDATA[
  public int doSomething() {
    int i = 5; // Unused
    int j = 6;
    j += 3;
    return j;
  }
  ]]>
      </example>
    </rule>
  
  
  
      <rule name="UnusedPrivateMethod"
          message="Avoid unused private methods such as ''{0}''"
          class="net.sourceforge.pmd.rules.UnusedPrivateMethodRule">
      <description>
  Unused Private Method detects when a private method is declared but is unused.
      </description>
          <priority>3</priority>
      <example>
  <![CDATA[
  public class Something {
   private void foo() {} // unused
  }
  ]]>
      </example>
    </rule>
  
  
    <rule name="UnusedFormalParameter"
          message="Avoid unused formal parameters such as ''{0}''"
          class="net.sourceforge.pmd.rules.UnusedFormalParameterRule">
      <description>
  Avoid passing parameters to methods and then not using those parameters.
      </description>
        <priority>3</priority>
  
      <example>
  <![CDATA[
  public class Foo {
   private void bar(String howdy) {
    // howdy is not used
   }
  ]]>
      </example>
    </rule>
  
  
  </ruleset>
  
  
  
  
  
  
  1.1                  maven/src/plugins-build/pmd/src/plugin-resources/rulesets/design.xml
  
  Index: design.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <ruleset name="Design Rules">
    <description>
  The Design Ruleset contains a collection of rules that find questionable designs.
    </description>
  
  
    <rule name="UseSingletonRule"
          message="All methods are static.  Consider using Singleton instead."
          class="net.sourceforge.pmd.rules.design.UseSingletonRule">
      <description>
      If you have a class that has nothing but static methods, consider making it a Singleton
      </description>
        <priority>3</priority>
  
      <example>
  <![CDATA[
  public class MaybeASingleton {
      public static void foo() {
       // etc
      }
      public static void bar() {
       // etc
      }
  }
  ]]>
      </example>
    </rule>
  
  
    <rule name="LooseCouplingRule"
          message="Avoid using implementation types like ''{0}''; use the interface instead"
          class="net.sourceforge.pmd.rules.design.LooseCouplingRule">
      <description>
      Avoid using implementation types (i.e., HashSet); use the interface (i.e, Set) instead
      </description>
        <priority>3</priority>
  
      <example>
  <![CDATA[
  import java.util.*;
  public class Bar {
  
   // should be "private List list"
   private ArrayList list = new ArrayList();
  
   // should be "public Set getFoo()"
   public HashSet getFoo() {
    return new HashSet();
   }
  }
  
  ]]>
      </example>
    </rule>
  
  
    <rule name="SimplifyBooleanReturnsRule"
          message="Avoid unnecessary if..then..else statements when returning a boolean"
          class="net.sourceforge.pmd.rules.SimplifyBooleanReturnsRule">
      <description>
  Avoid unnecessary if..then..else statements when returning a boolean
      </description>
        <priority>3</priority>
      <example>
  <![CDATA[
  public class Foo {
    private int bar =2;
    public boolean isBarEqualsTo(int x) {
      // this bit of code
      if (bar == x) {
       return true;
      } else {
       return false;
      }
      // can be replaced with a simple
      // return bar == x;
    }
  }
  ]]>
      </example>
    </rule>
  
  
    <rule name="SwitchStmtsShouldHaveDefault"
          message="Switch statements should have a default label"
          class="net.sourceforge.pmd.rules.XPathRule">
      <description>
      Switch statements should have a default label.
      </description>
        <properties>
            <property name="xpath">
                <value>
                    <![CDATA[
      //SwitchStatement[not(SwitchLabel[count(*) = 0])]
                    ]]>
                </value>
            </property>
        </properties>
        <priority>3</priority>
  
      <example>
  <![CDATA[
  public class Foo {
   public void bar() {
    int x = 2;
    switch (x) {
     case 2: int j = 8;
    }
   }
  }
  ]]>
      </example>
      </rule>
  
  
  
    <rule name="AvoidDeeplyNestedIfStmts"
          message="Deeply nested if..then statements are hard to read"
          class="net.sourceforge.pmd.rules.AvoidDeeplyNestedIfStmtsRule">
      <description>
      Deeply nested if..then statements are hard to read.
      </description>
        <priority>3</priority>
     <properties>
      <property name="problemDepth" value="3"/>
     </properties>
      <example>
  <![CDATA[
  public class Foo {
   public void bar() {
    int x=2;
    int y=3;
    int z=4;
    if (x>y) {
     if (y>z) {
      if (z==x) {
       // this is officially out of control now
      }
     }
    }
   }
  }
  ]]>
      </example>
      </rule>
  
  
      <rule name="AvoidReassigningParametersRule"
          message="Avoid reassigning parameters such as ''{0}''"
          class="net.sourceforge.pmd.rules.AvoidReassigningParametersRule">
      <description>
  Reassigning values to parameters is a questionable practice.  Use a temporary local variable instead.
      </description>
          <priority>2</priority>
      <example>
  <![CDATA[
  public class Foo {
   private void foo(String bar) {
    bar = "something else";
   }
  }
  ]]>
      </example>
    </rule>
  
      <rule name="SwitchDensity"
            message="A high ratio of statements to labels in a switch statement.  Consider refactoring."
            class="net.sourceforge.pmd.rules.design.SwitchDensityRule">
        <description>
   A high ratio of statements to labels in a switch statement implies that the switch
   statement is doing too much work.  Consider moving the statements either into new
   methods, or creating subclasses based on the switch variable.
        </description>
          <priority>3</priority>
          <properties>
           <property name="minimum" value="10"/>
          </properties>
        <example>
   <![CDATA[
     public class Foo {
       private int x;
       public void bar() {
         switch (x) {
           case 1: {
             System.out.println("I am a fish.");
             System.out.println("I am a fish.");
             System.out.println("I am a fish.");
             System.out.println("I am a fish.");
             break;
           }
  
           case 2: {
             System.out.println("I am a cow.");
             System.out.println("I am a cow.");
             System.out.println("I am a cow.");
             System.out.println("I am a cow.");
             break;
           }
         }
       }
     }
   ]]>
        </example>
      </rule>
  
      <rule name="ConstructorCallsOverridableMethodRule"
            message="Avoid calls to overridable methods during construction"
            class="net.sourceforge.pmd.rules.ConstructorCallsOverridableMethodRule">
        <description>
        Calling overridable methods during construction poses a risk of invoking methods on an
            incompletely constructed object.  This situation can be difficult to discern.
        It may leave the sub-class unable to construct its superclass or forced to
            replicate the construction process completely within itself, losing the ability to call
        super().  If the default constructor contains a call to an overridable method,
            the subclass may be completely uninstantiable.
        </description>
          <priority>1</priority>
        <example>
    <![CDATA[
      public class SeniorClass {
        public SeniorClass(){
            toString(); //may throw NullPointerException if overridden
        }
        public String toString(){
          return "IAmSeniorClass";
        }
      }
      public class JuniorClass extends SeniorClass {
        private String name;
        public JuniorClass(){
          super(); //Automatic call leads to NullPointerException
          name = "JuniorClass";
        }
        public String toString(){
          return name;
        }
      }
    ]]>
        </example>
      </rule>
  
      <rule name="AccessorClassGenerationRule"
            message="Avoid instantiation through private constructors from outside of the constructor's class."
            class="net.sourceforge.pmd.rules.AccessorClassGenerationRule">
        <description>
        Instantiation by way of private constructors from outside of the constructor's class often causes the generation of an accessor.
        A factory method, or non-privitization of the constructor can eliminate this situation.
        The generated class file is actually an interface.  It gives the accessing class the ability to invoke a new hidden package
        scope constructor that takes the interface as a supplementary parameter.  This turns a private constructor effectively into
        one with package scope, though not visible to the naked eye.
        </description>
        <priority>3</priority>
        <example>
    <![CDATA[
    public class OuterClass {
      void method(){
        InnerClass ic = new InnerClass();//Causes generation of accessor
      }
      public class InnerClass {
        private InnerClass(){
        }
      }
    }
  
    public class OuterClass {
      void method(){
        InnerClass ic = new InnerClass();//OK, due to public constructor
      }
      public class InnerClass {
        public InnerClass(){
        }
      }
    }
  
    public class OuterClass {
      void method(){
        InnerClass ic = InnerClass.getInnerClass();//OK
      }
      public static class InnerClass {
        private InnerClass(){
        }
        private static InnerClass getInnerClass(){
          return new InnerClass();
        }
      }
    }
  
    public class OuterClass {
      private OuterClass(){
      }
      public class InnerClass {
        void method(){
          OuterClass oc = new OuterClass();//Causes generation of accessor
        }
      }
    }
    ]]>
        </example>
      </rule>
  
    </ruleset>
  
  
  
  1.1                  maven/src/plugins-build/pmd/src/plugin-resources/rulesets/controversial.xml
  
  Index: controversial.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <ruleset name="Controversial Rules">
    <description>
  The Controversial Ruleset contains rules that, for whatever reason, are considered controversial.  They
  are separated out here to allow people to include as they see fit via custom rulesets.  This ruleset was
  initially created in response to discussions over UnnecessaryConstructorRule which Tom likes but
  most people really dislike :-)
    </description>
  
      <rule name="UnnecessaryConstructorRule"
            message="Avoid unnecessary constructors - the compiler will generate these for you"
            class="net.sourceforge.pmd.rules.XPathRule">
        <description>
    Unnecessary constructor detects when a constructor is not necessary; i.e., when there's only one constructor,
    it's public, has an empty body, and takes no arguments.
        </description>
          <properties>
              <property name="xpath">
                  <value>
                      <![CDATA[
      //ConstructorDeclaration[1][position() = last()][@Public='true'][not(FormalParameters/*)][not(BlockStatement)]
                      ]]>
                  </value>
              </property>
          </properties>
          <priority>3</priority>
        <example>
    <![CDATA[
    public class Foo {
     public Foo() {}
    }
    ]]>
        </example>
      </rule>
  
  
  
      <rule name="NullAssignment"
            message="Assigning an Object to null is a code smell.  Consider refactoring."
            class="net.sourceforge.pmd.rules.design.NullAssignmentRule">
        <description>
   Assigning a "null" to a variable (outside of its declaration) is usually in
   bad form.  Some times, the assignment is an indication that the programmer doesn't
   completely understand what is going on in the code.  NOTE: This sort of assignment
   may in rare cases be useful to encourage garbage collection.  If that's what you're using
   it for, by all means, disregard this rule :-)
        </description>
          <priority>3</priority>
        <example>
   <![CDATA[
   public class Foo {
     public void bar() {
       Object x = null; // This is OK.
       x = new Object();
       // Big, complex piece of code here.
       x = null; // This is BAD.
       // Big, complex piece of code here.
     }
   }
  
   ]]>
        </example>
  
      </rule>
      <rule name="OnlyOneReturn"
           message="A method should have only one exit point, and that should be the last statement in the method"
           class="net.sourceforge.pmd.rules.design.OnlyOneReturnRule">
       <description>
       A method should have only one exit point, and that should be the last statement in the method.
       </description>
          <priority>3</priority>
  
       <example>
   <![CDATA[
   public class OneReturnOnly1 {
    public void foo(int x) {
     if (x > 0) {
      return "hey";   // oops, multiple exit points!
     }
     return "hi";
    }
   }
   ]]>
       </example>
       </rule>
  
      <rule name="UnusedModifier"
           message="Unused modifiers are, well, unused"
           class="net.sourceforge.pmd.rules.XPathRule">
       <description>
       Unused modifiers are, well, unused.
       </description>
          <properties>
              <property name="xpath">
                  <value>
                      <![CDATA[
      //InterfaceDeclaration//MethodDeclaration[@Public='true' or @Abstract = 'true']
                      ]]>
                  </value>
              </property>
          </properties>
          <priority>3</priority>
       <example>
   <![CDATA[
      public interface Foo {
       public abstract void bar(); // both abstract and public are ignored by the compiler
      }
   ]]>
       </example>
       </rule>
  
      <rule name="AssignmentInOperandRule"
        message="Avoid assigments in operands"
        class="net.sourceforge.pmd.rules.XPathRule">
    <description>
    Avoid assigments in operands; this can make code more complicated and harder to read.
    </description>
          <properties>
              <property name="xpath">
                  <value>
                      <![CDATA[
      //*[name()='WhileStatement' or name()='IfStatement'][Expression//AssignmentOperator]
                      ]]>
                  </value>
              </property>
           </properties>
      <priority>3</priority>
    <example>
    <![CDATA[
    public class Foo {
     public void bar() {
  int x = 2;
  if ((x = getX()) == 3) {
   System.out.println("3!");
  }
     }
     private int getX() {
  return 3;
     }
    }
  
    ]]>
    </example>
  </rule>
  
      <rule name="AtLeastOneConstructor"
        message="Each class should declare at least one constructor"
        class="net.sourceforge.pmd.rules.AtLeastOneConstructorRule">
    <description>
    Each class should declare at least one constructor.  Note that this rule is the
        opposite of UnnecessaryConstructorRule, so running them at the same time will
        result on a rule violation on every class.
    </description>
      <priority>3</priority>
  
    <example>
    <![CDATA[
    public class Foo {
     // no constructor!  not good!
    }
    ]]>
    </example>
  </rule>
  
  </ruleset>
  
  
  
  
  
  
  1.1                  maven/src/plugins-build/pmd/src/plugin-resources/rulesets/favorites.xml
  
  Index: favorites.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <ruleset name="Favorites">
    <description>
  The Favorites ruleset contains links to rules that I like to use.  Usually I
  combine this ruleset with the unusedcode.xml, basic.xml, and import.xml rulesets for my projects.
  This ruleset also serves as an example of do a custom ruleset.
    </description>
  
    <rule ref="rulesets/braces.xml/WhileLoopsMustUseBracesRule"/>
    <rule ref="rulesets/braces.xml/ForLoopsMustUseBracesRule"/>
      <rule ref="rulesets/design.xml/LooseCouplingRule"/>
      <rule ref="rulesets/design.xml/SimplifyBooleanReturnsRule"/>
      <rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault"/>
      <rule ref="rulesets/strings.xml/StringToString"/>
      <rule ref="rulesets/strings.xml/StringInstantiation"/>
       <rule ref="rulesets/controversial.xml/UnnecessaryConstructorRule"/>
    <rule ref="rulesets/controversial.xml/NullAssignment"/>
    <rule ref="rulesets/controversial.xml/UnusedModifier"/>
  
  </ruleset>
  
  
  
  
  
  
  1.1                  maven/src/plugins-build/pmd/src/plugin-resources/pmd.jsl
  
  Index: pmd.jsl
  ===================================================================
  <?xml version="1.0"?>
  
  <jsl:stylesheet
    select="$doc"
    xmlns:j="jelly:core"
    xmlns:jsl="jelly:jsl"
    xmlns:util="jelly:util"
    xmlns:x="jelly:xml"
    xmlns:doc="doc"
    xmlns="dummy" trim="false">
  
    <!-- This needs to be instantiated here to be available in the template matches -->
    <j:useBean var="mavenTool" class="org.apache.maven.MavenTool"/>
    <j:useBean var="htmlescape" class="org.apache.velocity.anakia.Escape"/>
    <j:useBean var="fileutil" class="org.apache.velocity.texen.util.FileUtil"/>
    <j:useBean var="pathtool" class="org.apache.maven.DVSLPathTool"/>
  
    <jsl:template match="pmd">
      <document>
  
        <properties>
          <title>PMD Results</title>
        </properties>
  
        <body>
          <section name="PMD Results">
            <p>
              The following document contains the results of
              <a
                href="http://pmd.sourceforge.net/">PMD</a>.
            </p>
          </section>
  
          <section name="Summary">
            <j:set var="fileCount"><x:expr select="count(file)"/></j:set>
            <j:set var="errorCount"><x:expr select="count(file/violation)"/></j:set>
            <table>
              <tr>
                <th>Files</th>
                <th>Errors</th>
              </tr>
              <tr>
                <td><doc:formatAsNumber string="${fileCount}" pattern="0"/></td>
                <td><doc:formatAsNumber string="${errorCount}" pattern="0"/></td>
              </tr>
            </table>
          </section>
  
          <section name="Files">
            <table>
              <tr>
                <th>Files</th>
                <th>Violations</th>
              </tr>
              <j:set var="fullSrcDir" value="${pom.build.sourceDirectory}"/>
              <j:set var="srcDir" value="${fileutil.file(fullSrcDir).getAbsolutePath()}"/>
              <j:set var="srcDirLength" value="${srcDir.length() + 1}"/>
              <x:set var="files" select="file"/>
              <!-- x:forEach is busted -->
              <j:forEach var="file" items="${files}">
                <!-- Type coercion doesn't work worth a fuck in jexl. -->
                <j:set var="name" value="${file.attribute('name').getValue()}"/>
                <j:set var="name" value="${name.substring(mavenTool.toInteger(srcDirLength.toString()))}"/>
                <util:replace var="name" value="${name}" oldChar="\\" newChar="/"/>
                <!--- +1 is for the trailing slash above -->
                <j:set var="errorCount"><x:expr select="count($file/violation)"/></j:set>
                
                <j:if test="${errorCount != 0}">
                  <tr>
                    <td>
                      <a href="#${name}">${name}</a>
                    </td>
                    <td><doc:formatAsNumber string="${errorCount}" pattern="0"/></td>
                  </tr>
                </j:if>
              </j:forEach>
            </table>
  
            <j:forEach var="file" items="${files}">
              <x:set var="errorCount" select="count($file/violation)"/>
              <j:if test="${errorCount != 0}">
                <j:set var="name" value="${file.attribute('name').getValue()}"/>
                <j:set var="name" value="${name.substring(mavenTool.toInteger(srcDirLength.toString()))}"/>
  			  <util:replace var="name" value="${name}" oldChar="\\" newChar="/"/>
                
                <subsection name="${name}">
                  <table>
                    <tr>
                      <th>Violation</th>
                      <th>Line</th>
                    </tr>
                    <x:set var="errors" select="$file/violation"/>
                    <j:forEach var="error" items="${errors}">
                      <tr>
                        <td>
                          <j:set var="errorMessage" value="${error.StringValue}"/>
                          ${htmlescape.getText(errorMessage)}
                        </td>
                        <td>
                          <j:set var="line" value="${error.attribute('line').getValue()}"/>
                          <j:set var="lastIndex" value="${name.lastIndexOf('.java')}"/>
                          <j:choose>
                            <j:when test="${lastIndex > 0}">
                              <j:set var="index" value="${mavenTool.toInteger(lastIndex.toString())}"/>
                              <j:set var="nameWithoutJavaExtension" value="${name.substring(0, index)}"/>
                              <util:replace var="nameWithoutJavaExtension" value="${nameWithoutJavaExtension}" oldChar="\\" newChar="/"/>
                              <a href="xref/${nameWithoutJavaExtension}.html#${line}">${line}</a>
                            </j:when>
                            <j:otherwise>
                              ${line}
                            </j:otherwise>
                          </j:choose>
                        </td>
                      </tr>
                    </j:forEach>
                  </table>
                </subsection>
              </j:if>
            </j:forEach>
          </section>
        </body>
      </document>
    </jsl:template>
  </jsl:stylesheet>
  
  
  
  1.4       +11 -20    maven/src/plugins-build/pmd/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/maven/src/plugins-build/pmd/project.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- project.xml	3 Apr 2003 19:30:41 -0000	1.3
  +++ project.xml	4 Apr 2003 11:06:44 -0000	1.4
  @@ -1,4 +1,4 @@
  -<?xml version="1.0" encoding="ISO-8859-1"?>
  +<?xml version="1.0" encoding="UTF-8"?>
   
   <project>
     <extend>${basedir}/../project.xml</extend>
  @@ -64,27 +64,18 @@
         <artifactId>pmd</artifactId>
         <version>1.04</version>
         <url>http://pmd.sourceforge.net</url>
  -      <properties>
  -        <classloader>root</classloader>
  -      </properties>
  +    </dependency>  
  +    <dependency>
  +      <groupId>jaxen</groupId>
  +      <artifactId>jaxen</artifactId>
  +      <version>1.0-FCS-full</version>
  +    </dependency>  
  +    <dependency>
  +      <groupId>saxpath</groupId>
  +      <artifactId>saxpath</artifactId>
  +      <version>1.0-FCS</version>
       </dependency>  
     </dependencies>
  -  
  -  <build>
  -    <resources>
  -      <resource>
  -        <directory>${basedir}</directory>
  -        <includes>
  -          <include>plugin.jelly</include>
  -          <include>plugin.properties</include>
  -          <include>project.properties</include>
  -          <include>project.xml</include>
  -          <include>pmd.jsl</include>
  -          <include>rulesets/**</include>
  -        </includes>
  -      </resource>
  -    </resources>
  -  </build>
   
   </project>
   
  
  
  
  1.2       +79 -46    maven/src/plugins-build/pmd/plugin.jelly
  
  Index: plugin.jelly
  ===================================================================
  RCS file: /home/cvs/maven/src/plugins-build/pmd/plugin.jelly,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- plugin.jelly	3 Apr 2003 18:58:11 -0000	1.1
  +++ plugin.jelly	4 Apr 2003 11:06:44 -0000	1.2
  @@ -1,66 +1,99 @@
   <?xml version="1.0"?>
   
  -<project 
  -    xmlns:j="jelly:core" 
  -    xmlns:doc="doc">
  -
  -    <goal name="maven-pmd-plugin:register">
  -      <j:if test="${sourcesPresent}">
  -        <doc:registerReport 
  -            name="PMD" 
  -            link="pmd-report"
  -            description="PMD Report."/>
  -      </j:if>
  -    </goal>
  -
  -    <!-- ================================================================== -->
  -    <!-- P M D  T A R G E T                                                 -->
  -    <!-- ================================================================== -->
  -  
  -    <goal name="pmd" description="Static Code Analyzer">
  -      <!-- Only run PMD if it is enabled -->
  -      <j:set var="enable" value="${maven.pmd.enable}"/>    
  -      <!-- Either am bloody dumb or this is the only way to make it work ?! -->
  -      <j:if test="${enable.toString().equalsIgnoreCase('true')}">
  -        <attainGoal name="maven-pmd-plugin:report"/>
  -      </j:if>    
  -    </goal>
  +<!--
  +  =============================================================================
  +    PMD Plugin. Generate PMD reports using the PMD framework.
  +  =============================================================================
  +-->
  +<project xmlns:j="jelly:core" xmlns:doc="doc">
  +
  +  <!--
  +     ========================================================================
  +       Register a PMD report.
  +     ========================================================================
  +  -->
  +  <goal name="maven-pmd-plugin:register">
  +    <j:if test="${sourcesPresent}">
  +      <doc:registerReport 
  +        name="PMD Report"
  +        pluginName="pmd"
  +        description="Verification of coding rules."
  +        link="pmd-report"/>
  +    </j:if>
  +  </goal>
  +
  +  <!--
  +     ========================================================================
  +       Deregister a PMD report.
  +     ========================================================================
  +  -->
  +  <goal name="maven-pmd-plugin:deregister">
  +    <j:if test="${sourcesPresent}">
  +      <doc:deregisterReport name="PMD Report"/>
  +    </j:if>
  +  </goal>
  +
  +  <!--
  +     ========================================================================
  +       Main PMD plugin goal.
  +     ========================================================================
  +  -->
  +  <goal name="pmd" description="Static Code Analyzer">
  +
  +    <!-- Only run PMD if it is enabled -->
  +    <j:set var="enable" value="${maven.pmd.enable}"/>    
  +
  +    <!-- Either am bloody dumb or this is the only way to make it work ?! -->
  +    <j:if test="${enable.toString().equalsIgnoreCase('true')}">
  +      <attainGoal name="pmd:report"/>
  +    </j:if>    
  +
  +  </goal>
  +
  +  <!--
  +     ========================================================================
  +       Generate the PMD report.
  +     ========================================================================
  +  -->
  +  <goal name="pmd:report" 
  +    description="Generate source code report with PMD">
   
  -    <goal name="maven-pmd-plugin:report" 
  -          description="Generate source code report with PMD">
  -
  -    <!-- Create the dirs if we start from a previously cleaned project -->
  -    
  +    <!-- Create the dirs if we start from a previously cleaned project -->   
       <mkdir dir="${maven.build.dir}"/>
       <mkdir dir="${maven.docs.dest}"/>
   
  -    <!-- Define a PMD task with the rulesets and all jars in the classpath -->
  -    
  -    <taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask"/>
  +    <!-- Define a PMD task with the rulesets and all jars in the 
  +         classpath -->   
  +    <taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask">
  +      <classpath>
  +        <pathelement location="${plugin.getDependencyPath('pmd:pmd')}"/>
  +        <pathelement location="${plugin.getDependencyPath('jaxen:jaxen')}"/>
  +        <pathelement location="${plugin.getDependencyPath('saxpath:saxpath')}"/>
  +      </classpath>
  +    </taskdef>
           
       <!-- Run the PMD task - need a way to define the rulesets dynamically -->
  -
       <echo>Running the PMD task with ${maven.pmd.rulesetfiles} ...</echo>
       
       <pmd rulesetfiles="${maven.pmd.rulesetfiles}">
  -         <formatter type="xml" toFile="${maven.build.dir}/pmd-raw-report.xml"/>
  -         <fileset dir="${basedir}/${pom.build.sourceDirectory}">
  -           <include name="**/*.java"/>
  -         </fileset>
  +      <formatter type="xml" toFile="${maven.build.dir}/pmd-raw-report.xml"/>
  +      <fileset dir="${basedir}/${pom.build.sourceDirectory}">
  +        <include name="**/*.java"/>
  +      </fileset>
       </pmd>
       
       <!-- Run DVSL to transform the report into XDOC -->
             
  -    <echo>Converting the PMD report to XDOC ...</echo>
  +    <echo>Converting the PMD report to xdoc ...</echo>
   
       <doc:jsl
  -        input="${maven.build.dir}/pmd-raw-report.xml"
  -        output="pmd-report.xml"
  -        stylesheet="${plugin.dir}/pmd.jsl"
  -        omitXmlDeclaration="true"
  -        outputMode="xml"
  -        prettyPrint="true"
  -        />
  +      input="${maven.build.dir}/pmd-raw-report.xml"
  +      output="pmd-report.xml"
  +      stylesheet="${plugin.resources}/pmd.jsl"
  +      omitXmlDeclaration="true"
  +      outputMode="xml"
  +      prettyPrint="true"
  +    />
   
     </goal>
     
  
  
  
  1.2       +1 -1      maven/src/plugins-build/pmd/plugin.properties
  
  Index: plugin.properties
  ===================================================================
  RCS file: /home/cvs/maven/src/plugins-build/pmd/plugin.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- plugin.properties	3 Apr 2003 18:58:11 -0000	1.1
  +++ plugin.properties	4 Apr 2003 11:06:44 -0000	1.2
  @@ -11,4 +11,4 @@
   # comma seperated list of rules to use
   # rulesets/experimental.xml is, well, experimental ... use at your own risk
   
  -maven.pmd.rulesetfiles=rulesets/strings.xml,rulesets/junit.xml,rulesets/braces.xml,rulesets/basic.xml,rulesets/unusedcode.xml,rulesets/design.xml,rulesets/naming.xml,rulesets/imports.xml,rulesets/codesize.xml
  +maven.pmd.rulesetfiles=${plugin.resources}/rulesets/strings.xml,${plugin.resources}/rulesets/junit.xml,${plugin.resources}/rulesets/braces.xml,${plugin.resources}/rulesets/basic.xml,${plugin.resources}/rulesets/unusedcode.xml,${plugin.resources}/rulesets/design.xml,${plugin.resources}/rulesets/naming.xml,${plugin.resources}/rulesets/imports.xml,${plugin.resources}/rulesets/codesize.xml
  
  
  
  1.3       +1 -0      maven/src/plugins-build/pmd/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  RCS file: /home/cvs/maven/src/plugins-build/pmd/.cvsignore,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- .cvsignore	3 Apr 2003 19:32:31 -0000	1.2
  +++ .cvsignore	4 Apr 2003 11:06:44 -0000	1.3
  @@ -3,3 +3,4 @@
   .project
   build.properties
   velocity.log
  +target
  \ No newline at end of file
  
  
  
  1.2       +6 -0      maven/src/plugins-build/pmd/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/maven/src/plugins-build/pmd/xdocs/changes.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- changes.xml	3 Apr 2003 18:58:12 -0000	1.1
  +++ changes.xml	4 Apr 2003 11:06:45 -0000	1.2
  @@ -10,6 +10,12 @@
   
       <release version="0.6" date="in CVS">
         <action dev="vmassol" type="update">
  +        Make the plugin work with Maven b9.
  +      </action>            
  +      <action dev="vmassol" type="add">
  +        Added support for PMD 1.04.
  +      </action>            
  +      <action dev="vmassol" type="update">
           Moved the PMD plugin from the 
           <link href="http://sourceforge.net/projects/maven-plugins">Maven-Plugins SF project</link>
           to the Maven project.
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org