You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gb...@apache.org on 2018/02/24 22:10:25 UTC

[maven-checkstyle-plugin] 01/01: [MCHECKSTYLE-344] Fix category resolution when reporting violation of check with id parameter

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

gboue pushed a commit to branch MCHECKSTYLE-344
in repository https://gitbox.apache.org/repos/asf/maven-checkstyle-plugin.git

commit ca3eb97600576e0bee9f075b4bda0efdd0f6247d
Author: James Harrison <ja...@cognitran.com>
AuthorDate: Fri Jan 26 13:21:27 2018 +0000

    [MCHECKSTYLE-344] Fix category resolution when reporting violation of check with id parameter
    
    This closes #1.
---
 src/main/java/org/apache/maven/plugins/checkstyle/RuleUtil.java     | 2 +-
 src/test/java/org/apache/maven/plugins/checkstyle/RuleUtilTest.java | 5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/checkstyle/RuleUtil.java b/src/main/java/org/apache/maven/plugins/checkstyle/RuleUtil.java
index 79e943e..ff53a3e 100644
--- a/src/main/java/org/apache/maven/plugins/checkstyle/RuleUtil.java
+++ b/src/main/java/org/apache/maven/plugins/checkstyle/RuleUtil.java
@@ -92,7 +92,7 @@ public final class RuleUtil
         }
 
         int end = eventSrcName.lastIndexOf( '.' );
-        eventSrcName = eventSrcName.substring( 0,  end );
+        eventSrcName = end == -1 ? eventSrcName : eventSrcName.substring( 0,  end );
 
         if ( CHECKSTYLE_PACKAGE.equals( eventSrcName ) )
         {
diff --git a/src/test/java/org/apache/maven/plugins/checkstyle/RuleUtilTest.java b/src/test/java/org/apache/maven/plugins/checkstyle/RuleUtilTest.java
index 4b827c4..457be55 100644
--- a/src/test/java/org/apache/maven/plugins/checkstyle/RuleUtilTest.java
+++ b/src/test/java/org/apache/maven/plugins/checkstyle/RuleUtilTest.java
@@ -1,6 +1,6 @@
 package org.apache.maven.plugins.checkstyle;
 
-import org.apache.maven.plugins.checkstyle.RuleUtil;
+import junit.framework.TestCase;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -21,8 +21,6 @@ import org.apache.maven.plugins.checkstyle.RuleUtil;
  * under the License.
  */
 
-import junit.framework.TestCase;
-
 public class RuleUtilTest
     extends TestCase
 {
@@ -40,6 +38,7 @@ public class RuleUtilTest
         assertEquals( "misc", RuleUtil.getCategory( CHECKSTYLE_PACKAGE + ".FinalParametersCheck" ) );
         assertEquals( "test", RuleUtil.getCategory( CHECKSTYLE_PACKAGE + ".test.FinalParametersCheck" ) );
         assertEquals( "extension", RuleUtil.getCategory( "test.FinalParametersCheck" ) );
+        assertEquals( "extension", RuleUtil.getCategory( "copyright" ) );
         assertNull( RuleUtil.getCategory( (String) null ) );
     }
 

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