Author: mperham
Date: Sat Jun  3 09:31:40 2006
New Revision: 411444

URL: http://svn.apache.org/viewvc?rev=411444&view=rev
Log:
PR: MPMD-32
Submitted by: Szczepan Faber
Add minimumPriority parameter

Modified:
    
maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java
    maven/plugins/trunk/maven-pmd-plugin/src/site/apt/howto.apt
    
maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/PmdReportTest.java
    
maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/custom-configuration/custom-configuration-plugin-config.xml
    
maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/custom-configuration/custom/configuration/App.java
    
maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/custom-configuration/resources/rulesets/custom.xml

Modified: 
maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java?rev=411444&r1=411443&r2=411444&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java
 (original)
+++ 
maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java
 Sat Jun  3 09:31:40 2006
@@ -71,6 +71,14 @@
      * @parameter expression="${targetJdk}"
      */
     private String targetJdk;
+    
+    /**
+     * The rule priority threshold; rules with lower priority
+     * than this will not be evaluated.
+     * 
+     * @parameter expression="${minimumPriority}" default-value="5"
+     */
+    private int minimumPriority = 5;
 
     /**
      * The PMD rulesets to use. See the <a 
href="http://pmd.sourceforge.net/rules/index.html";>Stock Rulesets</a> for a
@@ -149,6 +157,7 @@
 
             Locator locator = new Locator( getLog() );
             RuleSetFactory ruleSetFactory = new RuleSetFactory();
+            ruleSetFactory.setMinimumPriority(this.minimumPriority);
             RuleSet[] sets = new RuleSet[rulesets.length];
             try
             {

Modified: maven/plugins/trunk/maven-pmd-plugin/src/site/apt/howto.apt
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/site/apt/howto.apt?rev=411444&r1=411443&r2=411444&view=diff
==============================================================================
--- maven/plugins/trunk/maven-pmd-plugin/src/site/apt/howto.apt (original)
+++ maven/plugins/trunk/maven-pmd-plugin/src/site/apt/howto.apt Sat Jun  3 
09:31:40 2006
@@ -66,6 +66,7 @@
         <sourceEncoding>utf-8</sourceEncoding>
         <minimumTokens>100</minimumTokens>
         <targetJdk>1.5</targetJdk>
+        <minimumPriority>5</minimumPriority>
       </configuration>
     </plugin>
   </plugins>

Modified: 
maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/PmdReportTest.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/PmdReportTest.java?rev=411444&r1=411443&r2=411444&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/PmdReportTest.java
 (original)
+++ 
maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/PmdReportTest.java
 Sat Jun  3 09:31:40 2006
@@ -70,7 +70,6 @@
             readFile( new File( getBasedir(), 
"target/test/unit/default-configuration/target/site/pmd.html" ) );
         assertTrue( str.toLowerCase().indexOf( 
"/xref/def/configuration/AppSample.html#31".toLowerCase() ) != -1 );
 
-        str = readFile( new File( getBasedir(), 
"target/test/unit/default-configuration/target/site/pmd.html" ) );
         assertTrue( str.toLowerCase().indexOf( 
"/xref/def/configuration/App.html#12".toLowerCase() ) != -1 );
 
     }
@@ -101,10 +100,12 @@
         //check if custom ruleset was applied
         String str = readFile( new File( getBasedir(), 
"target/test/unit/custom-configuration/target/site/pmd.html" ) );
         assertTrue( str.toLowerCase().indexOf( "Avoid using if statements 
without curly braces".toLowerCase() ) != -1 );
-
-        str = readFile( new File( getBasedir(), 
"target/test/unit/custom-configuration/target/site/pmd.html" ) );
+        
         assertTrue(
             str.toLowerCase().indexOf( "Avoid using if...else statements 
without curly braces".toLowerCase() ) != -1 );
+        
+        assertTrue("unnecessary constructor should not be triggered because of 
low priority",
+            str.toLowerCase().indexOf( "Avoid unnecessary constructors - the 
compiler will generate these for you".toLowerCase() ) == -1 );
 
     }
 

Modified: 
maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/custom-configuration/custom-configuration-plugin-config.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/custom-configuration/custom-configuration-plugin-config.xml?rev=411444&r1=411443&r2=411444&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/custom-configuration/custom-configuration-plugin-config.xml
 (original)
+++ 
maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/custom-configuration/custom-configuration-plugin-config.xml
 Sat Jun  3 09:31:40 2006
@@ -28,6 +28,7 @@
             <ruleset>rulesets/imports.xml</ruleset>
           </rulesets>
           <targetJdk>1.4</targetJdk>
+          <minimumPriority>4</minimumPriority>          
           <excludes>
             <exclude>**/Sample.java</exclude>
             <exclude>**/AnotherSample.java</exclude>

Modified: 
maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/custom-configuration/custom/configuration/App.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/custom-configuration/custom/configuration/App.java?rev=411444&r1=411443&r2=411444&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/custom-configuration/custom/configuration/App.java
 (original)
+++ 
maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/custom-configuration/custom/configuration/App.java
 Sat Jun  3 09:31:40 2006
@@ -9,6 +9,11 @@
 {
 
     /**
+     * trigger Unnecessary constructor rule 
+     */
+    public App() {}
+    
+    /**
      * The main method
      *
      * @param args  an array of strings that contains the arguments
@@ -43,4 +48,4 @@
         System.out.println( "Test method" );
     }
 
-}
\ No newline at end of file
+}

Modified: 
maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/custom-configuration/resources/rulesets/custom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/custom-configuration/resources/rulesets/custom.xml?rev=411444&r1=411443&r2=411444&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/custom-configuration/resources/rulesets/custom.xml
 (original)
+++ 
maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/custom-configuration/resources/rulesets/custom.xml
 Sat Jun  3 09:31:40 2006
@@ -6,5 +6,11 @@
   <rule ref="rulesets/braces.xml">
     <exclude name="WhileLoopsMustUseBracesRule"/>
     <exclude name="IfElseStmtsMustUseBracesRule"/>
+  </rule>   
+  
+  <description>Lowest priority for unnecessary constructor</description>
+  <rule ref="rulesets/controversial.xml/UnnecessaryConstructor" >
+       <priority>5</priority>
   </rule>
-</ruleset>
\ No newline at end of file
+  
+</ruleset>


Reply via email to