问题描述
我正在将Sonarqube 5.1与MsBuildSonarRunner一起用于我的c#.net项目分析. Sonarqube 5.1附带了C#4.1插件,最近我升级到了4.2.我创建了具有仅Fxcop规则的质量配置文件.我已经按照Sonar网站中提到的步骤进行了分析.
I am using Sonarqube 5.1 with MsBuildSonarRunner for my c#.net project analysis. Sonarqube 5.1 has come with C# 4.1 plugin, Recently I upgraded to 4.2. I have created a quality profile with ONLY Fxcop rules. I have followed the steps mentioned in Sonar site for analysis.
在分析中,我发现已捕获FXcop规则违规.但是,当我浏览到SonarDash开发板时,它显示的技术债务为0,问题的显示为0.我已经多次检查了自己的步骤,但我没有看到任何错误.无法将问题发布到服务器的原因可能是什么.
In analysis, I see that FXcop rule violations are captured. But when I browse to SonarDash board, It shows technical debt as 0 and issues as 0. I have reviewed my steps many times and I don't see any mistakes from my side. What could be the reason why Issues are not posted to server.
这是我的构建命令日志.我清楚地看到在构建阶段会应用FXCOP规则,并在控制台上打印违规行为.
Here is my Build command log. I see clearly FXCOP rules are applied and violations are printed on console during build phase.
===========================================================
Microsoft (R) Build Engine version 12.0.21005.1
[Microsoft .NET Framework, version 4.0.30319.34209]
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 10/19/2015 12:20:14 PM.
Project "D:\Sqp\Polindrome\Polindrome\Polindrome.csproj" on node 1 (default targets).
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
CoreCompile:
Skipping target "CoreCompile" because all output files are up-to-date with respect to the input files.
_CopyAppConfigFile:
Skipping target "_CopyAppConfigFile" because all output files are up-to-date with respect to the input files.
CopyFilesToOutputDirectory:
Polindrome -> D:\Sqp\Polindrome\Polindrome\bin\Debug\Polindrome.exe
OverrideCodeAnalysisProperties:
Running FxCop analysis using the SonarQube ruleset. Ruleset: D:\Sqp\Polindrome\Polindrome\.sonarqube\conf\\SonarQubeFxCop-cs.ruleset
RunCodeAnalysis:
Running Code Analysis...
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Static Analysis Tools\FxCop\FxCopCmd.exe /outputCulture:1033 /out:"bin\Debug\Polindrome.exe.CodeAnalysisLog.xml" /file:"bin\Debug\Polindrome.exe" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Microsoft.CSharp.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\mscorlib.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\System.Data.DataSetExtensions.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\System.Data.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\System.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\System.Xml.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\System.Xml.Linq.dll" /directory:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1" /ruleSet:"=D:\Sqp\Polindrome\Polindrome\.sonarqube\conf\\SonarQubeFxCop-cs.ruleset" /rulesetdirectory:"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Static Analysis Tools\\Rule Sets" /rule:"-C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Static Analysis Tools\FxCop\\Rules" /searchgac /ignoreinvalidtargets /forceoutput /successfile /ignoregeneratedcode /saveMessagesToReport:Active /timeout:120
MSBUILD : **warning CA1823: Microsoft.Performance : It appears that field 'Program.AccountList' is never used or is only ever assigned to. Use this field or remove it.** [D:\Sqp\Polindrome\Polindrome\Polindrome.csproj]
Code Analysis Complete -- 0 error(s), 1 warning(s)
SetStyleCopAnalysisSettings:
Setting 'sonar.stylecop.projectFilePath' to 'D:\Sqp\Polindrome\Polindrome\Polindrome.csproj'
WriteSonarQubeProjectData:
Directory "D:\Sqp\Polindrome\Polindrome\.sonarqube\out\\Polindrome__AnyCPU_Debug_635803356164104589" doesn't exist. Skipping.
Creating directory "D:\Sqp\Polindrome\Polindrome\.sonarqube\out\\Polindrome__AnyCPU_Debug_635803356164104589".
Done Building Project "D:\Sqp\Polindrome\Polindrome\Polindrome.csproj" (default targets).
Build succeeded.
"D:\Sqp\Polindrome\Polindrome\Polindrome.csproj" (default target) (1) ->
(RunCodeAnalysis target) ->
MSBUILD : warning CA1823: Microsoft.Performance : It appears that field 'Program.AccountList' is never used or is only ever assigned to. Use this field or remove it. [D:\Sqp\Polindrome\Polindrome\Polindrome.csproj]
1 Warning(s)
0 Error(s)
Time Elapsed 00:00:01.82
推荐答案
FxCop分析程序集,并依靠* .pdb文件将问题映射回源代码中的位置(即,将特定行的特定* .cs文件映射).
FxCop analyzes assemblies, and relies on *.pdb files to map issues back to locations within the source code (i.e. to specific *.cs files at specific lines).
CA1823
报告的问题似乎在一个字段上,由于* .pdb格式的限制,未将其映射回源代码.在将FxCop结果导入SonarQube期间,将忽略这些问题.您可以通过手动打开FxCop报表(在.sonarqube \ out * \ ProjectInfo.xml中找到其路径)来验证这一点.
The issue reported by CA1823
seems to be on a field, which due to limitations of the *.pdb format are not being mapped back to source code. These issues are ignored during the import of FxCop results into SonarQube. You can verify that by manually opening the FxCop report (whose path you'll find in .sonarqube\out*\ProjectInfo.xml).
在将来的C#插件版本中已经有改进它的票证: https://jira.sonarsource.com/browse/SONARFXCOP-32
There is already a ticket to improve this in a future version of the C# plugin: https://jira.sonarsource.com/browse/SONARFXCOP-32
更新2015年11月18日
在对该答案进行了多次评论(请参阅下文)之后,终于找到了问题的根本原因:SQL Server排序规则必须区分大小写(CS)和区分重音(AS).
After many comments on this answer (see below), the root cause of the issue was finally found: The SQL Server collation must be case-sensitive (CS) and accent-sensitive (AS).
在这种情况下,SonarQube 5.3预计会更快地失败,以避免出现此类奇怪的问题: https://jira.sonarsource.com/browse/SONAR-6884
SonarQube 5.3 is expected to fail faster when this is not the case, to avoid these kind of strange problems: https://jira.sonarsource.com/browse/SONAR-6884
这篇关于MsbuildSonar Runner + Fxcop-没有fxcop问题发布到服务器.SonarDashBoard显示0的技术债务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!