我想通过詹金斯客户端上的gradle sonarrunner插件运行StyleCop(4.7.47)。它运行良好,但由于某种原因,它不使用我的Settings.StyleCop文件,其中我禁用了一些规则,所以Sonar(3.7)报告了我不感兴趣的违规。如何为Sonar指定StyleCop设置?
c#项目具有以下结构:
/Root
Src/
Project1/...
Project2/...
MySolution.sln
Settings.StyleCop
build.gradle
我Settings.StyleCop文件看起来像这样:
<StyleCopSettings Version="105">
<GlobalSettings>
<StringProperty Name="MergeSettingsFiles">NoMerge</StringProperty>
</GlobalSettings>
<Analyzers>
<Analyzer AnalyzerId="StyleCop.CSharp.DocumentationRules">
<Rules>
<Rule Name="ElementDocumentationMustBeSpelledCorrectly">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
</Analyzer>
</Analyzers>
</StyleCopSettings>
而且我对sonarrunner gradle这个插件指定声纳性能:
property "sonar.language" , "cs"
property "sonar.sources" , "Src"
property "sonar.dotnet.visualstudio.solution.file" ,"Src/MySolution.sln"
property "sonar.dotnet.key.generation.strategy", "safe"
property "sonar.sourceEncoding" , "UTF-8"
我也试过指定sonar.stylecop.analyzers.settings property
,尽管Sonar FAQ提到这不能用来指定活动规则。
当我在VisualStudio中运行了StyleCop它使用正确的规则。
有没有一种方法来验证哪里了StyleCop得到它的设置?我错过了明显的东西吗?
任何帮助表示赞赏。
谢谢。不是我所希望的答案,但它澄清了事情。这意味着您必须手动确保本地和构建环境使用相同的StyleCop设置。 – GlennV
不幸的是,是的。 SonarQube维护者已经采取了SonarQube应该成为运行规则的主要来源的立场,等等。然而,包括SyleCop插件在内的几个插件提供了一种将SonarQube设置导出为其他应用可用的配置文件的方法。如果进入QualityProfiles页面并单击“Permalinks”选项卡,StyleCop链接将下载带有Sonar设置的StyleCop配置文件。不过,我不能说我已经尝试过。 –