SonarQube在Xamarin项目中没有检测到C#问题

问题描述 投票:1回答:1

我想使用SonarQube来分析带有Android和iOS应用程序的Xamarin.Forms项目的C#代码。为此,我创造了一个含有demo appcode issues,取自SonarQube examples。但是,扫描代码后,SonarQube无法检测到这些问题。我究竟做错了什么?

我按照these说明安装在macOS Sierra上:

  • SonarQube 6.7 LTS
  • 用于MSBuild 4.0.1.883的SonarQube扫描仪
  • SonarC#analyzer插件6.7(build 4267)

为了构建项目,我使用了Xamarin附带的msbuild 15.2.0.0。

在终端上,我将目录更改为cd /SonarQubeXamarinDemo/SonarQube并运行以下命令。

mono /Users/christopher/Downloads/sonar-scanner-msbuild-4.0.1.883/MSBuild.SonarQube.Runner.exe begin /k:"test" /d:sonar.host.url="http://localhost:9000" /d:sonar.login="***"


Default properties file was found at /Users/christopher/Downloads/sonar-scanner-msbuild-4.0.1.883/SonarQube.Analysis.xml
Loading analysis properties from /Users/christopher/Downloads/sonar-scanner-msbuild-4.0.1.883/SonarQube.Analysis.xml
Pre-processing started.
Preparing working directories...
15:14:24.778  Updating build integration targets...
15:14:24.796  Fetching analysis configuration settings...
15:14:25.164  Provisioning analyzer assemblies for cs...
15:14:25.165  Installing required Roslyn analyzers...
15:14:25.225  Pre-processing succeeded.

msbuild /t:Rebuild

...

mono /Users/christopher/Downloads/sonar-scanner-msbuild-4.0.1.883/MSBuild.SonarQube.Runner.exe end

SonarQube Scanner for MSBuild 4.0.1
Default properties file was found at /Users/christopher/Downloads/sonar-scanner-msbuild-4.0.1.883/SonarQube.Analysis.xml
Loading analysis properties from /Users/christopher/Downloads/sonar-scanner-msbuild-4.0.1.883/SonarQube.Analysis.xml
Post-processing started.
SONAR_SCANNER_OPTS is not configured. Setting it to the default value of -Xmx1024m
Calling the SonarQube Scanner...
INFO: Scanner configuration file: /Users/christopher/Downloads/sonar-scanner-msbuild-4.0.1.883/sonar-scanner-3.0.3.778/conf/sonar-scanner.properties
INFO: Project root configuration file: /Users/christopher/Documents/SonarQubeXamarinDemo/SonarQube/.sonarqube/out/sonar-project.properties
INFO: SonarQube Scanner 3.0.3.778
INFO: Java 1.8.0_91 Oracle Corporation (64-bit)
INFO: Mac OS X 10.12.6 x86_64
INFO: SONAR_SCANNER_OPTS=-Xmx1024m
INFO: User cache: /Users/christopher/.sonar/cache
INFO: Publish mode
INFO: Load global settings
INFO: Load global settings (done) | time=92ms
INFO: Server id: AWBqDLDnW0cFaKeFAIpa
INFO: User cache: /Users/christopher/.sonar/cache
INFO: Load plugins index
INFO: Load plugins index (done) | time=47ms
INFO: SonarQube server 6.7.0
INFO: Default locale: "de_DE", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Process project properties
INFO: Load project repositories
INFO: Load project repositories (done) | time=104ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=28ms
INFO: Load active rules
INFO: Load active rules (done) | time=418ms
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=21ms
INFO: Project key: test
INFO: -------------  Scan SonarQube.iOS
INFO: Load server rules
INFO: Load server rules (done) | time=116ms
INFO: Base dir: /Users/christopher/Documents/SonarQubeXamarinDemo/SonarQube/iOS
INFO: Working dir: /Users/christopher/Documents/SonarQubeXamarinDemo/SonarQube/.sonarqube/out/.sonar/test_test_6E8E4F09-4D51-490F-A002-4E844C8CEC18
INFO: Source encoding: UTF-8, default locale: de_DE
INFO: Index files
INFO: 0 files indexed
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=0ms
INFO: Sensor Analyzer for "php.ini" files [php]
INFO: Sensor Analyzer for "php.ini" files [php] (done) | time=3ms
INFO: -------------  Scan SonarQube.Droid
INFO: Base dir: /Users/christopher/Documents/SonarQubeXamarinDemo/SonarQube/Droid
INFO: Working dir: /Users/christopher/Documents/SonarQubeXamarinDemo/SonarQube/.sonarqube/out/.sonar/test_test_E9EA7651-B0E9-4DAD-9256-A858860C4022
INFO: Source encoding: UTF-8, default locale: de_DE
INFO: Index files
INFO: 0 files indexed
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=0ms
INFO: Sensor Analyzer for "php.ini" files [php]
INFO: Sensor Analyzer for "php.ini" files [php] (done) | time=1ms
INFO: -------------  Scan SonarQube
INFO: Base dir: /Users/christopher/Documents/SonarQubeXamarinDemo/SonarQube/SonarQube
INFO: Working dir: /Users/christopher/Documents/SonarQubeXamarinDemo/SonarQube/.sonarqube/out/.sonar/test_test_9200C6D4-CA74-49DD-910F-6DAF012CCCDF
INFO: Source encoding: UTF-8, default locale: de_DE
INFO: Index files
INFO: 0 files indexed
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=1ms
INFO: Sensor Analyzer for "php.ini" files [php]
INFO: Sensor Analyzer for "php.ini" files [php] (done) | time=0ms
INFO: -------------  Scan test
INFO: Base dir: /Users/christopher/Documents/SonarQubeXamarinDemo/SonarQube
INFO: Working dir: /Users/christopher/Documents/SonarQubeXamarinDemo/SonarQube/.sonarqube/out/.sonar
INFO: Source paths: SonarQube/SonarQube.cs, SonarQube/Properties/AssemblyInfo.cs, SonarQube/packages.config, iOS/Main.cs, iOS/AppDelegate.cs, iOS/Info.plist, iOS/Entitlements.plist, iOS/packages.config, Droid/MainActivity.cs, Droid/Resources/Resource.designer.cs, Droid/Properties/AssemblyInfo.cs, Droid/Resources/AboutResources.txt, Droid/Properties/AndroidManifest.xml, Droid/Assets/AboutAssets.txt, Droid/packages.config
INFO: Source encoding: UTF-8, default locale: de_DE
INFO: Index files
INFO: 15 files indexed
INFO: Quality profile for cs: Sonar way
INFO: Quality profile for xml: Sonar way
INFO: Sensor C# Properties [csharp]
INFO: Sensor C# Properties [csharp] (done) | time=0ms
INFO: Sensor SonarJavaXmlFileSensor [java]
WARNING: WARN: Property missing: 'sonar.cs.analyzer.projectOutPaths'. No protobuf files will be loaded for this project.
WARNING: WARN: No roslyn issues report not found for this project.
INFO: 1 source files to be analyzed
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=62ms
INFO: 1/1 source files have been analyzed
INFO: Sensor XML Sensor [xml]
INFO: Sensor XML Sensor [xml] (done) | time=211ms
INFO: Sensor Analyzer for "php.ini" files [php]
INFO: Sensor Analyzer for "php.ini" files [php] (done) | time=0ms
INFO: Sensor C# [csharp]
INFO: Sensor C# [csharp] (done) | time=0ms
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=11ms
INFO: Sensor CPD Block Indexer
INFO: Sensor CPD Block Indexer (done) | time=0ms
INFO: SCM provider for this project is: git
INFO: 8 files to be analyzed
INFO: 0/8 files analyzed
WARNING: WARN: Missing blame information for the following files:
WARNING: WARN:   * Droid/MainActivity.cs
WARNING: WARN:   * Droid/Properties/AndroidManifest.xml
WARNING: WARN:   * Droid/Properties/AssemblyInfo.cs
WARNING: WARN:   * Droid/Resources/Resource.designer.cs
WARNING: WARN:   * SonarQube/Properties/AssemblyInfo.cs
WARNING: WARN:   * SonarQube/SonarQube.cs
WARNING: WARN:   * iOS/AppDelegate.cs
WARNING: WARN:   * iOS/Main.cs
WARNING: WARN: This may lead to missing/broken features in SonarQube
INFO: Calculating CPD for 0 files
INFO: CPD calculation finished
INFO: Analysis report generated in 99ms, dir size=216 KB
INFO: Analysis reports compressed in 19ms, zip size=37 KB
INFO: Analysis report uploaded in 48ms
INFO: ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard/index/test
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: More about the report processing at http://localhost:9000/api/ce/task?id=AWBvIYbsCU-ClqGI-H2t
INFO: Task total time: 3.392 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 4.593s
INFO: Final Memory: 49M/401M
INFO: ------------------------------------------------------------------------
The SonarQube Scanner has finished
15:15:56.62  Creating a summary markdown file...
15:15:56.627  Analysis results: http://localhost:9000/dashboard/index/test
15:15:56.628  Post-processing succeeded.

该报告未显示任何检测到的问题:

enter image description here

我注意到这些警告,但不知道它们是否与未检测到的代码问题相关:

WARNING: WARN: Property missing: 'sonar.cs.analyzer.projectOutPaths'. No protobuf files will be loaded for this project.
WARNING: WARN: No roslyn issues report not found for this project.

到目前为止我试图解决这个问题没有成功

  • 使用/d:sonar.language=cs将语言设置为C#
xamarin xamarin.forms sonarqube static-analysis
1个回答
0
投票

我面临同样的问题。所以我改变了方法如下:

sonar-scanner-msbuild-4.0.1.883\SonarQube.Scanner.MSBuild.exe begin /k:FAM dotnet restore dotnet build sonar-scanner-msbuild-4.0.1.883\SonarQube.Scanner.MSBuild.exe end

因此,您可以使用dotnet cli命令而不是使用msbuild.exe。

© www.soinside.com 2019 - 2024. All rights reserved.