This is an automated email from the ASF dual-hosted git repository.

adangel pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-pmd-plugin.git

commit cd65bf96ab98127e58f9aeb55067a15937065610
Author: Andreas Dangel <adan...@apache.org>
AuthorDate: Fri Apr 27 18:38:16 2018 +0200

    [MPMD-261] Upgrade to PMD 6.2.0
    
    Adjust unit tests to changed rules
---
 .../java/org/apache/maven/plugins/pmd/PmdReportTest.java     |  6 ++++--
 .../unit/custom-configuration/custom/configuration/App.java  |  4 ++++
 .../unit/custom-configuration/resources/rulesets/custom.xml  | 12 ++++++------
 3 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java 
b/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java
index 72afd01..5fd1356 100644
--- a/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java
+++ b/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java
@@ -248,9 +248,11 @@ public class PmdReportTest
 
         // check if custom ruleset was applied
         String str = readFile( generatedFile );
-        assertTrue( lowerCaseContains( str, "Avoid using if statements without 
curly braces" ) );
 
-        // Must be false as IfElseStmtsMustUseBraces is excluded!
+        // codestyle.xml/ControlStatementBraces:
+        assertTrue( lowerCaseContains( str, "This statement should have 
braces" ) );
+
+        // Must be false as codestyle.xml/ControlStatementBraces with 
checkIfElseStmt=false is used
         assertFalse( lowerCaseContains( str, "Avoid using if...else statements 
without curly braces" ) );
 
         assertFalse( "unnecessary constructor should not be triggered because 
of low priority",
diff --git 
a/src/test/resources/unit/custom-configuration/custom/configuration/App.java 
b/src/test/resources/unit/custom-configuration/custom/configuration/App.java
index 8da80b7..477392b 100644
--- a/src/test/resources/unit/custom-configuration/custom/configuration/App.java
+++ b/src/test/resources/unit/custom-configuration/custom/configuration/App.java
@@ -49,11 +49,15 @@ public class App
      */
     protected void sampleMethod( String str )
     {
+        // if/else statement without braces
         if ( str.equals( "RED" ) )
             System.out.println( "The color is red." );
         else if ( str.equals( "BLLUE" ) )
             System.out.println( "The color is blue." );
 
+        // for loop without braces
+        for ( int i = 0; i < 10; i++ )
+            i = i + 1;
     }
 
     /**
diff --git 
a/src/test/resources/unit/custom-configuration/resources/rulesets/custom.xml 
b/src/test/resources/unit/custom-configuration/resources/rulesets/custom.xml
index 2d2da0a..743c9a5 100644
--- a/src/test/resources/unit/custom-configuration/resources/rulesets/custom.xml
+++ b/src/test/resources/unit/custom-configuration/resources/rulesets/custom.xml
@@ -23,12 +23,12 @@ under the License.
     xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 
http://pmd.sourceforge.net/ruleset_2_0_0.xsd";>
     <description>Just the braces rules I like</description>
 
-    <rule ref="category/java/codestyle.xml">
-        <exclude name="WhileLoopsMustUseBraces"/>
-        <exclude name="IfElseStmtsMustUseBraces"/>
-
-        <!-- needed to be excluded, otherwise the variable 
'noSoLongVariableName' will be reported -->
-        <exclude name="LocalVariableCouldBeFinal"/>
+    <rule ref="category/java/codestyle.xml/ShortClassName"/>
+    <rule ref="category/java/codestyle.xml/MethodArgumentCouldBeFinal"/>
+    <rule ref="category/java/codestyle.xml/ControlStatementBraces">
+        <properties>
+            <property name="checkIfElseStmt" value="false"/>
+        </properties>
     </rule>
 
     <!-- Lowest priority for unnecessary constructor -->

-- 
To stop receiving notification emails like this one, please contact
adan...@apache.org.

Reply via email to