You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Robert Bain (JIRA)" <ji...@apache.org> on 2019/01/31 18:40:00 UTC

[jira] [Created] (MCHECKSTYLE-367) Regexp module fails when "id" property without a "." is provided

Robert Bain created MCHECKSTYLE-367:
---------------------------------------

             Summary: Regexp module fails when "id" property without a "." is provided
                 Key: MCHECKSTYLE-367
                 URL: https://issues.apache.org/jira/browse/MCHECKSTYLE-367
             Project: Maven Checkstyle Plugin
          Issue Type: Bug
          Components: checkstyle:check
    Affects Versions: 3.0.0
            Reporter: Robert Bain


Using an "id" property without a "." as follows, the following stack trace is produced:

 
{code:java}
<module name="Regexp">
 <property name="severity" value="warning" />
 <property name="id" value="wibble" />
 <property name="format" value="(LocalDate(Time)?\.now|new (LocalDate(Time)?|Date(Midnight)?))\(\)" />
 <property name="message" value="Use NuDateService" />
 <property name="illegalPattern" value="true" />
 </module>{code}
java.lang.StringIndexOutOfBoundsException: begin 0, end -1, length 6

at java.lang.String.checkBoundsBeginEnd (String.java:3116)
 at java.lang.String.substring (String.java:1885)
 at org.apache.maven.plugins.checkstyle.RuleUtil.getCategory (RuleUtil.java:95)

 

It's pretty clear from [the code|https://github.com/apache/maven-plugins/blob/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugins/checkstyle/RuleUtil.java#L95] what's causing the issue.

Adding a "." to the "id" property resolves things, as follows:
{code:java}
<module name="Regexp">
 <property name="severity" value="warning" />
 <property name="id" value="wibble.foo" />
 <property name="format" value="(LocalDate(Time)?\.now|new (LocalDate(Time)?|Date(Midnight)?))\(\)" />
 <property name="message" value="Use NuDateService" />
 <property name="illegalPattern" value="true" />
 </module>{code}
We now get the message [WARNING] Example.java:[12] (extension) foo: Line matches the illegal pattern 'Use NuDateService'.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)