我正在将 SonarQube 扫描仪用于 MSBuild 2.0 和 SonarQube 5.4。我已将 Roslyn Wintellect.Analyzers NuGet 包的 SonarQube 插件添加到 SonarQube 服务器,并将规则添加到我的 SonarQube 项目使用的质量配置文件中。在 C# 源代码中,我使用 #pragma 禁用了“Wintellect003”规则(然后我在内联和 GlobalSuppressions.cs 中尝试了 SuppressMessage 属性)。该规则在 Visual Studio 2015 和 msbuild 14 中成功禁用,但 SonarQube 不尊重我已禁用该规则的事实(对于这一行代码 - 我没有在 SonarQube 或规则集中禁用该规则)。
我可以看到 MsBuild.SonarQube.Runner.exe 正在识别抑制,因为在“结束”阶段它生成 RoslynCA.json 文件以发送到 SonarQube,它包括以下部分:-
"ruleId": "Wintellect003",
"kind": "warning",
"locations": [
{
"analysisTarget": [
{
"uri": "file:\/\/\/C:\/CS5Tests/Mycode.cs",
"region": {
"startLine": 920,
"startColumn": 17,
"endLine": 923,
"endColumn": 118
}
}
]
}
],
"shortMessage": "'if' statements must have braces",
"fullMessage": "If and else statements must use braces even for single line results",
"isSuppressedInSource": true,
正如你所看到的,它说“isSuppressedInSource”是真的。不幸的是,SonarQube 不尊重此设置。有任何想法吗?
(我曾尝试停止 SonarQube 服务器,删除 data\es 文件夹以清除缓存并重新启动 SonarQube 服务器,但这并没有帮助)。
最佳答案
C# 5.2 插件增加了对此的支持:
https://groups.google.com/d/msg/sonarqube/0gghnIQf3XU/aEMSwMkvBAAJ
We'd like to release the SonarQube C# Plugin version 5.2.
What's new?
Issue suppression through [SuppressMessage] is now supported
All FxCop issues are imported in SonarQube, even the ones on fields which could not be mapped back to a specific file
Adds 6 new rules This release closes the gap between the issues you see in Visual Studio and in SonarQube.
关于sonarqube - SonarQube 是否忽略 isSuppressedInSource?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36896474/