简体   繁体   English

声纳 C# 插件不起作用?

[英]Sonar C# plugin not working?

Our company was glad to see the release of the C# plugins for sonar , and jumped on the first release.我们公司很高兴看到声纳的 C# 插件的发布,并跳上了第一个版本。 However, we seem to be running into an execption reported by the ProjectLinkSensor.但是,我们似乎遇到了 ProjectLinkSensor 报告的异常。 Here's what we did:这是我们所做的:

On a Windows XP machine, we installed the following:在 Windows XP 机器上,我们安装了以下内容:

  • Windows 7 Development kit (to get to FxCop) Windows 7 开发套件(获取 FxCop)
  • Fxcop 10.0外汇战警 10.0
  • Gallio加里奥
  • Sonar 2.9 RC1 (running the Derby database) Sonar 2.9 RC1(运行 Derby 数据库)
  • Maven 2.2.1 Maven 2.2.1

Then we checked out the solution, and placed the following pom.xml in the directory where the sln file is:然后我们查看了解决方案,将以下pom.xml放在sln文件所在目录下:

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.rolfje</groupId>
  <artifactId>SomeSilverlightProject</artifactId>
  <version>1.0-SNAPSHOT</version>
  <name>SomeSilverlightProject</name>

  <properties>
    <sonar.language>cs</sonar.language>
  </properties>

  <build>
    <sourceDirectory>${basedir}</sourceDirectory>
  </build>
</project>

In the home directory of the user that's running the maven build we've placed the following settings.xml:在运行 maven 构建的用户的主目录中,我们放置了以下设置。xml:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <profiles>
   <profile>
      <id>dotnet</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <properties>

      <sonar.gallio.mode>skip</sonar.gallio.mode>
      <sonar.gallio.installDirectory>C:/Program Files/Gallio</sonar.gallio.installDirectory>

      <sonar.fxcop.mode>skip</sonar.fxcop.mode>
      <sonar.fxcop.installDirectory>D:/Program Files/Microsoft Fxcop 10.0</sonar.fxcop.installDirectory>

      <sonar.partcover.mode>skip</sonar.partcover.mode>
      <sonar.partcover.installDirectory>C:/Program Files/PartCover/PartCover .NET 4.0</sonar.partcover.installDirectory>

      <sonar.gendarme.mode>skip</sonar.gendarme.mode>
      <sonar.gendarme.installDirectory>C:/Program Files/gendarme-2.6-bin</sonar.gendarme.installDirectory>

      <sonar.gendarme.mode>skip</sonar.gendarme.mode>
      <sonar.stylecop.installDirectory>C:/Program Files/Microsoft StyleCop 4.3.2.1</sonar.stylecop.installDirectory>

      <sonar.jdbc.url>jdbc:derby://localhost:1527/sonar</sonar.jdbc.url>
      <sonar.jdbc.driver>org.apache.derby.jdbc.ClientDriver</sonar.jdbc.driver>
      <sonar.jdbc.username>sonar</sonar.jdbc.username>
      <sonar.jdbc.password>sonar</sonar.jdbc.password>
      <sonar.host.url>http://localhost:9000</sonar.host.url>

      </properties>
   </profile>
  </profiles>
</settings>

Please note that I put "skip" in front of all modules.请注意,我将“跳过”放在所有模块的前面。 I did this one by one, hoping that switching off one of these modules would remove the error and I would be able to give you a clearer bug report.我一个一个地做了这个,希望关闭其中一个模块可以消除错误,我可以给你一个更清晰的错误报告。 However this did not help.然而这并没有帮助。

When I go into the project directory (where the sln file is) and I run the following command: mvn -e clean sonar:sonar当我 go 进入项目目录(sln 文件所在的位置)并运行以下命令时: mvn -e clean sonar:sonar

I see that the maven sonar plugin does analysis, fetches settings from the local sonar instance, and generates the expected output files (target/sonar/stylecop-msbuild.xml for instance).我看到 maven 声纳插件进行分析,从本地声纳实例获取设置,并生成预期的 output 文件(目标/声纳/stylecop-msbuild.Z0F635D0E0F3874FFF8B581C1C1C1)。 However, these reports do not get uploaded to sonar, and I see the following error being reported by maven:但是,这些报告没有上传到声纳,我看到 maven 报告了以下错误:

[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Can not execute Sonar

Embedded error: org.sonar.plugins.core.sensors.ProjectLinksSensor has unsatisfied dependency: class org.apache.maven.project.MavenProject among unsatisfiable dependencies: [[class org.apache.maven.project.MavenProject]] where org.sonar.batch.bootstrap.ProjectModule@2c507f:135<I<org.sonar.batch.bootstrap.BatchModule@659812:139<I<org.picocontainer.DefaultPicoContainer@eb1882:44<| was the leaf container being asked for dependencies.
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Can not execute Sonar
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:284)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)

Aside from the rather unhelpful error (ProjectModule@2c507f doesn't really tell me much), this looks like a nasty bug, which is causing the sonar upload (at least for me) to not work.除了相当无益的错误(ProjectModule@2c507f 并没有真正告诉我太多)之外,这看起来像是一个令人讨厌的错误,它导致声纳上传(至少对我而言)不起作用。

Did anybody else have this issue?其他人有这个问题吗? What is causing this and why is the error reporting so terrible in this case?是什么导致了这种情况,为什么在这种情况下错误报告如此糟糕?

Please note taht I've also reported this as a bug on Jira, because I really think the Sonar/C-Sharp plugin ecosystem is leaving me in the dark here.请注意,我也将此报告为 Jira 上的一个错误,因为我真的认为 Sonar/C-Sharp 插件生态系统让我一无所知。 However, it was put into the "Wont't fix" state without additional information.但是,它被放入“不会修复”state 中,没有其他信息。 The Jira bug is here: https://jira.codehaus.org/browse/SONARPLUGINS-1264 Jira 错误在这里: https://jira.codehaus.org/browse/SONARPLUGINS-1264

I don't know if this will solve your problem, but I noticed that you refer to the C drive in all of your <sonar.*.installDirectory> tags, except for <sonar.fxcop.installDirectory> .我不知道这是否能解决您的问题,但我注意到您在所有<sonar.*.installDirectory>标签中都引用了 C 驱动器,除了<sonar.fxcop.installDirectory>

Oh, and you could also try to disable the stylecop module since you've accidentally copy-pasted <sonar.gendarme.mode>skip</sonar.gendarme.mode> in front of that module...哦,您也可以尝试禁用 stylecop 模块,因为您不小心在该模块前面复制粘贴<sonar.gendarme.mode>skip</sonar.gendarme.mode> ...

I am one of the main developers of sonar for c#.我是 c# 声纳的主要开发人员之一。 I did not seen your jira ticket before.我以前没见过你的 jira 票。 I actually agree with Fabrice, you should have send a mail to the user mailing-list.我实际上同意 Fabrice,您应该向用户邮件列表发送邮件。

About your issue, my first guess is that there is an error with your pom.xml file.关于您的问题,我的第一个猜测是您的 pom.xml 文件有错误。 If you use "mvn -e clean sonar:sonar", you need to declare in the pom.xml file the "maven-dotnet-plugin" plugin.如果使用“mvn -e clean sonar:sonar”,则需要在 pom.xml 文件中声明“maven-dotnet-plugin”插件。 The "clean" part will be performed by this plugin. “干净”部分将由该插件执行。 Also, the correct command line would rather be "mvn clean package sonar:sonar", there will not be any assembly to analyse.此外,正确的命令行宁愿是“mvn clean package sonar:sonar”,不会有任何要分析的程序集。

For more information on the maven-dotnet-plugin you can check out the documentation on: http://maven-dotnet-plugin.appspot.com有关 maven-dotnet-plugin 的更多信息,您可以查看以下文档: http://maven-dotnet-plugin.appspot.com

You will find a pom example here: http://maven-dotnet-plugin.appspot.com/configuration.html你会在这里找到一个 pom 示例: http://maven-dotnet-plugin.appspot.com/configuration.html

Hope it helps希望能帮助到你

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM