0

我目前正在开发 Xamarin 移动应用程序,并尝试使用 SonarQube 作为 CI 流程的一部分来强制执行代码质量。

有没有人有这样做的经验?

到目前为止,通过我的实验,我在使用 SonarLint for Visual Studio 和 StyleCop 时遇到了问题,我不知道这是否是因为这些项目是使用 xbuild 而不是 Visual Studio 或 MSBuild 构建的。

我看到的分类或错误是

Unhandled Exception: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.

这似乎发生在调用 Visual Studio 的 SonarLint 之后。

编辑:

14:59:19.350 INFO  - SonarLint for Visual Studio version 1.3.0.0
14:59:20.154 ERROR - 
14:59:20.337 ERROR - Unhandled Exception: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
14:59:20.338 ERROR -    at System.Collections.Immutable.ImmutableDictionary`2.get_Item(TKey key)
14:59:20.340 ERROR -    at SonarLint.Runner.Configuration.AddAnalyzerCommentRegularExpression(Builder builder)
14:59:20.341 ERROR -    at SonarLint.Runner.Configuration.Analyzers()
14:59:20.341 ERROR -    at SonarLint.Runner.Program.Main(String[] args)
4

2 回答 2

0

适用于 MSBuild 的 SonarQube 扫描仪不支持 xbuild:如果您仍然尝试使用它,预计会遇到一些困难。

看来您使用的是早于 4.4 的 SonarQube C# 插件版本。可用的最新版本是 4.5,并AddAnalyzerCommentRegularExpression根据您的堆栈跟踪删除了当前失败的这部分代码。

于 2016-03-01T15:52:36.620 回答
0

最后我设法找出了问题的根源。

SonarLint KeyNotFoundException

于 2016-03-22T16:55:11.580 回答