首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >为什么SonarQube 8.3不检查C#代码?

为什么SonarQube 8.3不检查C#代码?
EN

Stack Overflow用户
提问于 2020-06-23 09:35:48
回答 1查看 495关注 0票数 0

我不熟悉SonarQube和它的配置。我的帖子类似于this,但这是一个旧的帖子,据我所知,解决方案中的一些事情已经改变了。英语不是我的母语,请耐心等待。

我用C#插件8.6.1启动并运行了SonarQube 8.3,

以及运行在MSBuild上的.Net框架4.6+的SonarScanner 4.3。我没有编辑..\conf\sonar-scanner.properties文件,

代码语言:javascript
运行
复制
PS C:\test-demo> sonar-scanner
INFO: Scanner configuration file: C:\Sonar-Scanner-MSBuild\sonar-scanner-4.3.0.2102\bin\..\conf\sonar-scanner.properties

我在这个目录中有一个测试demo:

代码语言:javascript
运行
复制
C:\test-demo

该目录包含这些文件

这是sonar-project.properties文件connfiguration,

代码语言:javascript
运行
复制
# must be unique in a given SonarQube instance
sonar.projectKey=QRDemo
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
sonar.projectName=QRDemo
sonar.projectVersion=1.0
 
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# This property is optional if sonar.modules is set. 
sonar.sources=.
 
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
sonar.msbuild.testProjectPattern=*Tests;*UnitTests;*Demo
sonar.dotnet.visualstudio.solution.file="C:\\test-demo\\QrDemo.sln"

这是我要测试的代码,SonarQube应该能找到错误,

代码语言:javascript
运行
复制
using QRCoder;
using System;
using System.Collections.Generic;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Text;

namespace QrDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = 0;

            string token = "Esto lo vamos a volver qr";
            QRCodeGenerator qrGenerator = new QRCodeGenerator();
            QRCodeData qrCodeData = qrGenerator.CreateQrCode(token, QRCodeGenerator.ECCLevel.Q);
            QRCode qrCode = new QRCode(qrCodeData);
            System.Drawing.Bitmap qrCodeImage = qrCode.GetGraphic(10);

            //Opcion A: Desde el memoryStream puedo retornar la imagen sin necesidad de crear fisicamente
            //using (MemoryStream ms = new MemoryStream())
            //{
            //    qrCodeImage.Save(ms, ImageFormat.Png);
            //}

            //Opción B: Se guarda un QR Fisico
            qrCodeImage.Save("imagen.png", ImageFormat.Png);
        }
    }
}

但是当我运行扫描仪的时候,我得到了这个

代码语言:javascript
运行
复制
PS C:\test-demo> sonar-scanner
INFO: Scanner configuration file: C:\Sonar-Scanner-MSBuild\sonar-scanner-4.3.0.2102\bin\..\conf\sonar-scanner.properties
INFO: Project root configuration file: C:\test-demo\sonar-project.properties
INFO: SonarScanner 4.3.0.2102
INFO: Java 11.0.6 Oracle Corporation (64-bit)
INFO: Windows 10 10.0 amd64
INFO: User cache: C:\Users\hpayares\.sonar\cache
INFO: Scanner configuration file: C:\Sonar-Scanner-MSBuild\sonar-scanner-4.3.0.2102\bin\..\conf\sonar-scanner.properties
INFO: Project root configuration file: C:\test-demo\sonar-project.properties
INFO: Analyzing on SonarQube server 8.3.1
INFO: Default locale: "es_CO", source code encoding: "windows-1252" (analysis is platform dependent)
INFO: Load global settings
INFO: Load global settings (done) | time=61ms
INFO: Server id: BF41A1F2-AXK_1XzT0nTmQjkDht7H
INFO: User cache: C:\Users\hpayares\.sonar\cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=51ms
INFO: Load/download plugins (done) | time=144ms
INFO: Process project properties
INFO: Process project properties (done) | time=17ms
INFO: Execute project builders
INFO: Execute project builders (done) | time=5ms
INFO: Project key: QRDemo
INFO: Base dir: C:\test-demo
INFO: Working dir: C:\test-demo\.scannerwork
INFO: Load project settings for component key: 'QRDemo'
INFO: Load project settings for component key: 'QRDemo' (done) | time=19ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=85ms
INFO: Load active rules
INFO: Load active rules (done) | time=1196ms
WARN: SCM provider autodetection failed. Please use "sonar.scm.provider" to define SCM of your project, or disable the SCM Sensor in the project settings.
INFO: Indexing files...
INFO: Project configuration:
INFO: 19 files indexed
INFO: Quality profile for cs: Sonar way
INFO: ------------- Run sensors on module QRDemo
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=31ms
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by net.sf.cglib.core.ReflectUtils$1 (file:/C:/Users/hpayares/.sonar/cache/54f6535c111cefad0fb6a09ba3e61922/sonar-javascript-plugin.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of net.sf.cglib.core.ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
INFO: Sensor SonarCSS Rules [cssfamily]
INFO: No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped.
INFO: Sensor SonarCSS Rules [cssfamily] (done) | time=0ms
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: 'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=0ms
INFO: Sensor C# Properties [csharp]
WARN: Property missing: 'sonar.cs.analyzer.projectOutPaths'. No protobuf files will be loaded for this project.
WARN: No Roslyn issues report found for this project.
INFO: Sensor C# Properties [csharp] (done) | time=16ms
INFO: Sensor JavaXmlSensor [java]
INFO: Sensor JavaXmlSensor [java] (done) | time=0ms
INFO: Sensor HTML [web]
INFO: Sensor HTML [web] (done) | time=0ms
INFO: Sensor C# [csharp]
INFO: Sensor C# [csharp] (done) | time=0ms
INFO: ------------- Run sensors on project
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=0ms
INFO: SCM Publisher No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it.
INFO: CPD Executor Calculating CPD for 0 files
INFO: CPD Executor CPD calculation finished (done) | time=0ms
INFO: Load project repositories
INFO: Load project repositories (done) | time=31ms
INFO: Analysis report generated in 157ms, dir size=80 KB
INFO: Analysis report compressed in 47ms, zip size=12 KB
INFO: Analysis report uploaded in 31ms
INFO: ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard?id=QRDemo
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=AXLeZwScZSZ5s3S2FZtb
INFO: Analysis total time: 12.890 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 14.453s
INFO: Final Memory: 6M/30M
INFO: ------------------------------------------------------------------------

我跟着官方指南看了看别人的指南都没有用,我不知道我做错了什么,你能帮帮我吗?

提前谢谢你。

EN

回答 1

Stack Overflow用户

发布于 2020-10-20 17:09:58

您需要使用Scanner for MSBuild来分析.NET项目。请关注SonarScanner for MSBuild文档页面。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62525984

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档