[ https://issues.apache.org/jira/browse/MCHECKSTYLE-354?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16711542#comment-16711542 ]
Peter Lamby edited comment on MCHECKSTYLE-354 at 12/6/18 2:51 PM: ------------------------------------------------------------------ Why is this ticket still open? As James said the issue was fixed in MSCHECKSTYLE-344. was (Author: serra): Why is this ticket still open? As James said the issue was fixed in MSCHECKSTYLE-344. > Plugin throws exception on encountering rule: SeparatorWrapDot of Google > checkstyle > ----------------------------------------------------------------------------------- > > Key: MCHECKSTYLE-354 > URL: https://issues.apache.org/jira/browse/MCHECKSTYLE-354 > Project: Maven Checkstyle Plugin > Issue Type: Bug > Components: predefined ruleset: Maven > Affects Versions: 3.0.0 > Environment: Java 8 > Apache Maven 3.3.9 > Reporter: Jawwad Farooq > Priority: Major > > Version 3.0.0 of the plugin throws below exception if any voilation of rule > '*SeparatorWrapDot*' is found in the code. I am using Google checks as the > ruleset. > > {code:java} > Execution validate of goal > org.apache.maven.plugins:maven-checkstyle-plugin:3.0.0:check fa > iled: String index out of range: -1 > at > org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213) > at > org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154) > at > org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146) > at > org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117) > at > org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81) > at > org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) > at > org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) > at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309) > at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194) > at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107) > at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993) > at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345) > at org.apache.maven.cli.MavenCli.main(MavenCli.java:191) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:498) > at > org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) > at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) > at > org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) > at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) > Caused by: org.apache.maven.plugin.PluginExecutionException: Execution > validate of goal org.apache.maven.plugins:maven-checkstyle-plugin:3.0.0:check > failed: String index out of range: -1 > at > org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145) > at > org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) > ... 20 more > Caused by: java.lang.StringIndexOutOfBoundsException: String index out of > range: -1 > at java.lang.String.substring(String.java:1967) > at org.apache.maven.plugins.checkstyle.RuleUtil.getCategory(RuleUtil.java:95) > at > org.apache.maven.plugins.checkstyle.CheckstyleViolationCheckMojo.countViolations(CheckstyleViolationCheckMojo.java:646) > at > org.apache.maven.plugins.checkstyle.CheckstyleViolationCheckMojo.execute(CheckstyleViolationCheckMojo.java:564) > at > org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) > ... 21 more > {code} > > Reason: > Implementation of the function which is failing is below: > Class: RuleUtil > {code:java} > public static String getCategory( String eventSrcName ) > { > if ( eventSrcName == null ) > { > return null; > } > int end = eventSrcName.lastIndexOf( '.' ); > eventSrcName = eventSrcName.substring( 0, end ); > if ( CHECKSTYLE_PACKAGE.equals( eventSrcName ) ) > { > return "misc"; > } > else if ( !eventSrcName.startsWith( CHECKSTYLE_PACKAGE ) ) > { > return "extension"; > } > return eventSrcName.substring( eventSrcName.lastIndexOf( '.' ) + 1 ); > } > {code} > The code > {code:java} > eventSrcName = eventSrcName.substring( 0, end ); > {code} > The variable end is calculated using the statement: > {code:java} > int end = eventSrcName.lastIndexOf( '.' ); > {code} > And for this rule, variable eventSrcName contains 'SeparatorWrapDot'. It DOES > NOT contain eny dot in it. so end is -1 which results in: > {color:#FF0000}String index out of range: -1{color} -- This message was sent by Atlassian JIRA (v7.6.3#76005)