SonarQube Plugins
  1. SonarQube Plugins
  2. SONARPLUGINS-1123

Parsing GMetrics Report - Inner Classes leads to Exception and Termination of build

    Details

    • Number of attachments :
      0

      Description

      Here's the resulting stacktrace:

      [INFO]  Executing GMetrics                     
      [INFO]  No custom message bundle found for [gmetrics-messages]. Using default messages.  
      [INFO]  GMetrics completed: 5952ms
      [INFO]  parsing /daten/workspace/portal/target/sonar/gmetrics-report.xml      
      [INFO] ------------------------------------------------------------------------                    
      [INFO] BUILD FAILURE          
      [INFO] ------------------------------------------------------------------------                    
      [INFO] Total time: 32.089s    
      [INFO] Finished at: Fri Apr 29 14:02:42 CEST 2011    
      [INFO] Final Memory: 34M/996M 
      [INFO] ------------------------------------------------------------------------                    
      [ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.0-beta-2:sonar (default-cli) on project myProject: Can not execute Sonar: Flex inner classes are not supported : bla.blub.MyClass$bla.blub.MyInnerClass -> [Help 1]  
      org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.0-beta-2:sonar (default-cli) on project cogito-portal: Can not execute Sonar                    
              at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)         
              at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)         
              at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)         
              at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)        
              at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)        
              at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)            
              at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) 
              at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)   
              at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)     
              at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)         
              at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)          
              at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)            
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)      
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)           
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)   
              at java.lang.reflect.Method.invoke(Method.java:597)
              at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
              at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
              at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
              at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
      Caused by: org.apache.maven.plugin.MojoExecutionException: Can not execute Sonar
              at org.codehaus.mojo.sonar.Bootstraper.executeMojo(Bootstraper.java:118)
              at org.codehaus.mojo.sonar.Bootstraper.start(Bootstraper.java:65)
              at org.codehaus.mojo.sonar.SonarMojo.execute(SonarMojo.java:90)
              at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
              at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
              ... 19 more
      Caused by: java.lang.IllegalArgumentException: Flex inner classes are not supported : bla.blub.MyClass$bla.blub.MyInnerClass
              at org.sonar.plugins.groovy.foundation.GroovyFile.<init>(GroovyFile.java:51)
              at org.sonar.plugins.groovy.foundation.GroovyFile.<init>(GroovyFile.java:45)
              at org.sonar.plugins.groovy.gmetrics.GMetricsXMLParser$1.stream(GMetricsXMLParser.java:50)
              at org.sonar.api.utils.StaxParser.parse(StaxParser.java:110)
              at org.sonar.api.utils.StaxParser.parse(StaxParser.java:90)
              at org.sonar.api.utils.StaxParser.parse(StaxParser.java:80)
              at org.sonar.plugins.groovy.gmetrics.GMetricsXMLParser.parseAndProcessGMetricsResults(GMetricsXMLParser.java:84)
              at org.sonar.plugins.groovy.GroovySensor.computeGMetricsReport(GroovySensor.java:97)
              at org.sonar.plugins.groovy.GroovySensor.analyse(GroovySensor.java:74)
              at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:59)
              at org.sonar.batch.phases.Phases.execute(Phases.java:75)
              at org.sonar.batch.ProjectBatch.execute(ProjectBatch.java:55)
              at org.sonar.batch.Batch.analyzeModule(Batch.java:158)
              at org.sonar.batch.Batch.analyzeModules(Batch.java:76)
              at org.sonar.batch.Batch.execute(Batch.java:62)
              at org.sonar.maven3.SonarMojo.executeBatch(SonarMojo.java:144)
              at org.sonar.maven3.SonarMojo.execute(SonarMojo.java:135)
              at org.codehaus.mojo.sonar.Bootstraper.executeMojo(Bootstraper.java:113)
              ... 23 more
      [ERROR]
      
      

      Where the offending file looks like this:

      package bla.blub
      
      class MyClass {
      
          public enum MyInnerClass {
              AN_ENUM, OSME_OTHER_ENUM
          }
      }
      

      And the resulting gmetrics-report.xml looks something like this:

      <Class name="bla.blub.MyClass$bla.blub.MyInnerClass">
            <MetricResult name="CyclomaticComplexity" total="5" average="1.3"/>
            <MetricResult name="MethodLineCount" total="19" average="4.8"/>
            ...
            ...
      </Class>
      

        Issue Links

          Activity

          Hide
          Evgeny Mandrikov added a comment -

          Duplicates SONARPLUGINS-597

          Show
          Evgeny Mandrikov added a comment - Duplicates SONARPLUGINS-597
          Hide
          Steve Boardwell added a comment -

          Is this really the same Bug?

          I understood that SONARPLUGINS-597 handles the class wrongly but does not cause the analysis to fail.

          This ticket has IMO more severe implications because the analysis is terminated with an IllegalArgumentException, rather than simply not showing the correct result for that class and continuing the analysis.

          Show
          Steve Boardwell added a comment - Is this really the same Bug? I understood that SONARPLUGINS-597 handles the class wrongly but does not cause the analysis to fail. This ticket has IMO more severe implications because the analysis is terminated with an IllegalArgumentException, rather than simply not showing the correct result for that class and continuing the analysis.
          Hide
          Evgeny Mandrikov added a comment -

          Example which provided in a first comment for SONARPLUGINS-597 leads to exception, which mentioned in this ticket. For me SONARPLUGINS-597 is about inner classes in general.

          Show
          Evgeny Mandrikov added a comment - Example which provided in a first comment for SONARPLUGINS-597 leads to exception, which mentioned in this ticket. For me SONARPLUGINS-597 is about inner classes in general.
          Hide
          David Racodon added a comment -

          Manually tested.

          Show
          David Racodon added a comment - Manually tested.
          Hide
          Evgeny Mandrikov added a comment -

          Integration test is in place.

          Show
          Evgeny Mandrikov added a comment - Integration test is in place.

            People

            • Assignee:
              Evgeny Mandrikov
              Reporter:
              Steve Boardwell
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: