sonarqube - SonarQube 是否忽略 isSuppressedInSource?

标签 sonarqube sonarqube-msbuild-runner

我正在将 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/

相关文章:

sonarqube - 如何获取使用sonarqube创建的sonar-report.json文件?

java - 如何在 Sonar 上使用自定义java规则?

sonarqube-msbuild-runner - 如何将 -X 开关传递给 SonarQube Scanner for MSBuild?

c# - SonarQube MSBuild runner 中的编程覆盖排除

msbuild - 异常消息 : TF270015: 'MSBuild.SonarQube.Runner.exe' returned an unexpected exit code. 预期 '0' ;实际 '-532462766'

java - "JavaSonarQube"和 "Java Common Sonarqube"的分析器

java - 如何在SonarQube中忽略javax文件?

sonarqube - 当前线程不是锁的所有者!淡褐色