Unable to run check class org.sonar.java.checks.IndentationCheck

  • SonarQube: Version 6.7.4 (build 38452
  • Java version: 1.8
09:47:17.255 DEBUG: Plugins:
09:47:17.255 DEBUG:   * Issue resolver 1.0.2 (issueresolver)
09:47:17.255 DEBUG:   * C++ (Community) 1.2.2.1653 (cxx)
09:47:17.255 DEBUG:   * SonarPython 1.13.0.2922 (python)
09:47:17.255 DEBUG:   * SonarCSS 1.0.3.724 (cssfamily)
09:47:17.256 DEBUG:   * PMD 3.2.0 (pmd)
09:47:17.256 DEBUG:   * Svn 1.8.0.1168 (scmsvn)
09:47:17.256 DEBUG:   * SonarJS 5.2.0.7766 (javascript)
09:47:17.256 DEBUG:   * Findbugs 3.9.4 (findbugs)
09:47:17.256 DEBUG:   * Portuguese Pack 6.4 (l10npt)
09:47:17.256 DEBUG:   * SonarC# 7.14.0.8411 (csharp)
09:47:17.256 DEBUG:   * Groovy 1.5 (groovy)
09:47:17.256 DEBUG:   * SonarJava 5.13.0.18197 (java)
09:47:17.256 DEBUG:   * LDAP 2.2.0.608 (ldap)
09:47:17.256 DEBUG:   * SonarHTML 3.0.1.1444 (web)
09:47:17.256 DEBUG:   * Git 1.7.0.1491 (scmgit)
09:47:17.256 DEBUG:   * SonarFlex 2.4.0.1222 (flex)
09:47:17.257 DEBUG:   * SonarXML 2.0.1.2020 (xml)
09:47:17.263 DEBUG:   * SonarPHP 3.0.0.4537 (php)
09:47:17.263 DEBUG:   * Checkstyle 4.20 (checkstyle)

09:47:20.030 DEBUG: Available languages:
09:47:20.030 DEBUG:   * C++ (Community) => "c++"
09:47:20.030 DEBUG:   * Python => "py"
09:47:20.030 DEBUG:   * CSS => "css"
09:47:20.030 DEBUG:   * JavaScript => "js"
09:47:20.030 DEBUG:   * JSP => "jsp"
09:47:20.030 DEBUG:   * C# => "cs"
09:47:20.031 DEBUG:   * Groovy => "grvy"
09:47:20.031 DEBUG:   * Java => "java"
09:47:20.032 DEBUG:   * HTML => "web"
09:47:20.032 DEBUG:   * Flex => "flex"
09:47:20.032 DEBUG:   * XML => "xml"
09:47:20.032 DEBUG:   * PHP => "php"

During the analysis of a java file there is an exception wihtin the IndentationCheck

This exception occurs every analisys

**00:36:22** [ERROR] Unable to run check class org.sonar.java.checks.IndentationCheck - IndentationCheck on file 'xxxx', To help improve SonarJava, please report this problem to SonarSource : see https://www.sonarqube.org/community/
**00:36:22** java.lang.StringIndexOutOfBoundsException: String index out of range: 0
**00:36:22** at java.lang.String.charAt(String.java:658)
**00:36:22** at org.sonar.java.checks.IndentationCheck.checkIndentation(IndentationCheck.java:184)
**00:36:22** at org.sonar.java.checks.IndentationCheck.checkIndentation(IndentationCheck.java:175)
**00:36:22** at org.sonar.java.checks.IndentationCheck.visitClass(IndentationCheck.java:85)
**00:36:22** at org.sonar.java.model.declaration.ClassTreeImpl.accept(ClassTreeImpl.java:203)
**00:36:22** at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:40)
**00:36:22** at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:34)
**00:36:22** at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitCompilationUnit(BaseTreeVisitor.java:52)
**00:36:22** at org.sonar.java.model.JavaTree$CompilationUnitTreeImpl.accept(JavaTree.java:189)
**00:36:22** at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:40)
**00:36:22** at org.sonar.java.checks.IndentationCheck.scanFile(IndentationCheck.java:69)
**00:36:22** at org.sonar.java.model.VisitorsBridge.runScanner(VisitorsBridge.java:149)
**00:36:22** at org.sonar.java.model.VisitorsBridge.lambda$visitFile$1(VisitorsBridge.java:140)
**00:36:22** at java.util.ArrayList.forEach(ArrayList.java:1249)
**00:36:22** at org.sonar.java.model.VisitorsBridge.visitFile(VisitorsBridge.java:140)
**00:36:22** at org.sonar.java.ast.JavaAstScanner.simpleScan(JavaAstScanner.java:90)
**00:36:22** at org.sonar.java.ast.JavaAstScanner.scan(JavaAstScanner.java:67)
**00:36:22** at org.sonar.java.JavaSquid.scanSources(JavaSquid.java:115)
**00:36:22** at org.sonar.java.JavaSquid.scan(JavaSquid.java:109)
**00:36:22** at org.sonar.plugins.java.JavaSquidSensor.execute(JavaSquidSensor.java:88)
**00:36:22** at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:53)
**00:36:22** at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:88)
**00:36:22** at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:82)
**00:36:22** at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:68)
**00:36:22** at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:88)
**00:36:22** at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:177)
**00:36:22** at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
**00:36:22** at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
**00:36:22** at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:291)
**00:36:22** at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:286)
**00:36:22** at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:284)
**00:36:22** at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:264)
**00:36:22** at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
**00:36:22** at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
**00:36:22** at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:48)
**00:36:22** at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:84)
**00:36:22** at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
**00:36:22** at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
**00:36:22** at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:121)
**00:36:22** at org.sonar.batch.bootstrapper.Batch.doExecuteTask(Batch.java:116)
**00:36:22** at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:71)
**00:36:22** at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
**00:36:22** at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
**00:36:22** at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
**00:36:22** at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
**00:36:22** at java.lang.reflect.Method.invoke(Method.java:498)
**00:36:22** at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
**00:36:22** at com.sun.proxy.$Proxy16.execute(Unknown Source)
**00:36:22** at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:185)
**00:36:22** at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:137)
**00:36:22** at org.sonarsource.scanner.maven.bootstrap.ScannerBootstrapper.execute(ScannerBootstrapper.java:65)
**00:36:22** at org.sonarsource.scanner.maven.SonarQubeMojo.execute(SonarQubeMojo.java:104)
**00:36:22** at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
**00:36:22** at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
**00:36:22** at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
**00:36:22** at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
**00:36:22** at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
**00:36:22** at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
**00:36:22** at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
**00:36:22** at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
**00:36:22** at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
**00:36:22** at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
**00:36:22** at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
**00:36:22** at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
**00:36:22** at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
**00:36:22** at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
**00:36:22** at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
**00:36:22** at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
**00:36:22** at java.lang.reflect.Method.invoke(Method.java:498)
**00:36:22** at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
**00:36:22** at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
**00:36:22** at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
**00:36:22** at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)

Hello @JoaoRocha, and welcome on this forum.

Could you extract a self-contained reproducer from the file making the analysis fail?

Without an example of code, it’s going to be hard to guess the root cause of the issue. If you can not extract a simple case, you can still send me the file using private messages.

Regards,
Michael