Uploaded image for project: 'Maven Checkstyle Plugin'
  1. Maven Checkstyle Plugin
  2. MCHECKSTYLE-367

Regexp module fails when "id" property without a "." is provided

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Auto Closed
    • 3.0.0
    • None
    • checkstyle:check
    • None

    Description

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

       

      <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>

      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 what's causing the issue.

      Adding a "." to the "id" property resolves things, as follows:

      <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>

      We now get the message [WARNING] Example.java:[12] (extension) foo: Line matches the illegal pattern 'Use NuDateService'.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              robertandrewbain Robert Bain
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: