Sonarqube在不同的文件夹中产生不同的结果 [英] Sonarqube producing different results in different folders

查看:326
本文介绍了Sonarqube在不同的文件夹中产生不同的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新1:

实际上与构建服务器无关,我已将我的仓库签出到一个新文件夹中,可以观察到相同的行为,因此绝对不是版本问题。我已经比较了.sonarqube文件夹,看不到任何异常。是什么导致从另一个位置进行构建时一个csproj的结果被忽略?

It is actually not related to the build server, I have checkout my repo into a fresh folder and can observe the same behavior so it definitely isn't a version problem. I have compared the .sonarqube folders and cannot see anything unusual. What could be causing the results from one csproj to be ignored when building from another location?

原始问题:

我正在为.net项目(1 .sln,2 .csproj)设置声纳,当我在计算机上运行分析程序时,它可以工作,所有文件都被分析,我得到了一个不错的选择报告。

I'm setting up sonarqube for a .net project (1 .sln, 2 .csproj), when I run the analysis on my machine it works, all the files are analysed and I get a nice report.

在新构建服务器上运行时,仅上载.csproj之一的结果。

When I run on the new build server only results from one of the .csproj is uploaded.

我已经验证了相同版本的msbuild和声纳扫描仪。

I have verified the same versions of msbuild and sonar scanner.

我在输出中看到的一些差异是:

some differences I see in the output are:


  1. 构建服务器上没有要分析的文件:

local:

INFO: Index files
INFO: 84 files indexed
INFO: Quality profile for cs: Sonar way
INFO: Sensor C# Properties [csharp]
INFO: Sensor C# Properties [csharp] (done) | time=1ms
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=1ms
INFO: SCM provider for this project is: git
INFO: 39 files to be analyzed
INFO: 0/39 files analyzed

构建服务器:

INFO: Index files
INFO: 86 files indexed
INFO: Quality profile for cs: Sonar way
INFO: Sensor C# Properties [csharp]
INFO: Sensor C# Properties [csharp] (done) | time=2ms
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=1ms




  1. 索引时的文件数不同CPD区块

本地:

INFO: Index files
INFO: 0 files indexed
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=0ms
INFO: Sensor C# [csharp]
WARNING: WARN:   * ${filename}.cs
WARNING: WARN:   * ${filename}.cs
INFO: Importing results from 6 proto files in '${projectDir}\.sonarqube\out\0\output-cs'
WARNING: WARN:   * ${filename}.cs
  // 5 more files
INFO: Importing results from 6 proto files in '${projectDir}\.sonarqube\out\1\output-cs'
WARNING: WARN:   * ${filename}.cs
  // 18 more files
WARNING: WARN: This may lead to missing/broken features in SonarQube
INFO: Importing 2 Roslyn reports
INFO: Sensor C# [csharp] (done) | time=5245ms
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=143ms
INFO: Sensor CPD Block Indexer
INFO: Sensor CPD Block Indexer (done) | time=5ms
INFO: 7 files had no CPD blocks
INFO: Calculating CPD for 71 files
INFO: CPD calculation finished
INFO: Analysis report generated in 3159ms, dir size=468 KB
INFO: Analysis reports compressed in 881ms, zip size=256 KB
INFO: Analysis report uploaded in 287ms
INFO: ANALYSIS SUCCESSFUL, you can browse ${sonarUrl}

构建服务器:

INFO: Index files
INFO: 0 files indexed
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=1ms
INFO: Sensor C# [csharp]
INFO: Importing results from 6 proto files in '${projectDir}\.sonarqube\out\0\output-cs'
INFO: Importing results from 6 proto files in '${projectDir}\.sonarqube\out\1\output-cs'
INFO: Importing 2 Roslyn reports
INFO: Sensor C# [csharp] (done) | time=652ms
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=85ms
INFO: Sensor CPD Block Indexer
INFO: Sensor CPD Block Indexer (done) | time=0ms
INFO: 1 file had no CPD blocks
INFO: Calculating CPD for 2 files
INFO: CPD calculation finished
INFO: Analysis report generated in 2326ms, dir size=234 KB
INFO: Analysis reports compressed in 268ms, zip size=116 KB
INFO: Analysis report uploaded in 95ms
INFO: ANALYSIS SUCCESSFUL, you can browse ${sonarUrl}

我使用以下命令运行分析:

I run the analysis with these commands:

SonarQube.Scanner.MSBuild.exe begin /k:"key" /d:sonar.host.url="url" /d:sonar.login="token"
MSBuild.exe /t:Rebuild
SonarQube.Scanner.MSBuild.exe end /d:sonar.login="token"


推荐答案

解决了这个问题,MsBuild对于文件夹名称不区分大小写,Sonarqube则区分大小写。

Solved it, MsBuild is not case sensitive with regards to folder names, Sonarqube is.

我的解决方案文件引用了

My solution file had a reference to

My.Project1 / My.Project1.csproj ,但在源代码管理中,该文件夹名为 MY.Project1 / My.Project1.csproj

My.Project1/My.Project1.csproj but in source control the folder was named MY.Project1/My.Project1.csproj

以某种方式,我在本地计算机上有了工作文件夹名称。

Somehow on my local machine I had the working folder name.

这篇关于Sonarqube在不同的文件夹中产生不同的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆