SonarException:未知指标:temp-method-lines

时间:2013-02-07 14:02:49

标签: c# code-analysis sonarqube

我正在寻找答案很多个小时,但我没有找到任何解决方案。

我正在为C#项目运行声纳,我使用Sonar 3.4和声纳运行器2.0和C#插件:

  • 声纳-CSHARP-芯插件-1.4
  • 声纳-CSHARP-的FxCop-插件-1.4
  • 声纳-CSHARP-加利奥-插件-1.4
  • 声纳-CSHARP-宪兵-插件-1.4
  • 声纳-CSHARP-ndeps-插件-1.4
  • 声纳-CSHARP-SQUID-插件-1.4
  • 声纳-CSHARP-了StyleCop-插件-1.4

在通过声纳 - 跑步者进行分析后,我得到了那个例外

    Exception in thread "main" org.sonar.runner.RunnerException: org.sonar.api.utils.SonarException: Fail to decorate 'org.sonar.api.resources.File@243e2c21[key=ApplicationName.cs,dir=,filename=ApplicationName.cs,language=C#]'
        at org.sonar.runner.Runner.delegateExecution(Runner.java:288)
        at org.sonar.runner.Runner.execute(Runner.java:151)
        at org.sonar.runner.Main.execute(Main.java:84)
        at org.sonar.runner.Main.main(Main.java:56)
    Caused by: org.sonar.api.utils.SonarException: Fail to      decorate'org.sonar.api.resources.File@243e2c21[key=ApplicationName.cs,dir=,filename=ApplicationName.cs,language=C#]'
        at org.sonar.batch.phases.DecoratorsExecutor.executeDecorator(DecoratorsExecutor.java:84)
        at org.sonar.batch.phases.DecoratorsExecutor.decorateResource(DecoratorsExecutor.java:70)
        at org.sonar.batch.phases.DecoratorsExecutor.decorateResource(DecoratorsExecutor.java:63)
        at org.sonar.batch.phases.DecoratorsExecutor.decorateResource(DecoratorsExecutor.java:63)
        at org.sonar.batch.phases.DecoratorsExecutor.execute(DecoratorsExecutor.java:55)
        at org.sonar.batch.phases.Phases.execute(Phases.java:92)
        at org.sonar.batch.bootstrap.ProjectModule.doStart(ProjectModule.java:129)
        at org.sonar.batch.bootstrap.Module.start(Module.java:68)
        at org.sonar.batch.bootstrap.BatchModule.analyze(BatchModule.java:147)
        at org.sonar.batch.bootstrap.BatchModule.analyze(BatchModule.java:141)
        at org.sonar.batch.bootstrap.BatchModule.doStart(BatchModule.java:136)
        at org.sonar.batch.bootstrap.Module.start(Module.java:68)
        at org.sonar.batch.bootstrap.BootstrapModule.doStart(BootstrapModule.java:83)
        at org.sonar.batch.bootstrap.Module.start(Module.java:68)
        at org.sonar.batch.Batch.execute(Batch.java:106)
        at org.sonar.runner.internal.batch.Launcher.executeBatch(Launcher.java:6
        at org.sonar.runner.internal.batch.Launcher.execute(Launcher.java:61)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.sonar.runner.Runner.delegateExecution(Runner.java:285)
        ... 3 more
    Caused by: org.sonar.api.utils.SonarException: Unknown metric: temp-method-lines
        at org.sonar.batch.index.DefaultIndex.addMeasure(DefaultIndex.java:184)
        at org.sonar.batch.DefaultDecoratorContext.saveMeasure(DefaultDecoratorContext.java:111)
        at org.sonar.plugins.uselesscodetracker.decorator.TempMethodLinesDecorator.computeDistributionFromChildren(TempMethodLinesDecorator.java:58)
        at org.sonar.plugins.uselesscodetracker.decorator.TempMethodLinesDecorator.decorate(TempMethodLinesDecorator.java:49)
        at org.sonar.batch.phases.DecoratorsExecutor.executeDecorator(DecoratorsExecutor.java:79)
        ... 24 more

1 个答案:

答案 0 :(得分:1)

我不知道这个“临时方法行”指标是什么,从来没有听说过......

请安装最新版本的.NET& C#插件生态系统:version 2.0。另外,请确保卸载任何其他可能带来此未知指标的插件(可能是您编写的自定义插件?)。

请升级到Sonar 3.4.1,因为3.4版本存在严重错误。