lundi 22 juin 2020

Why does the SonarQube 8.3 does not check C# code?

I am new to SonarQube and its configuration. My post is similar to this, but it is an old one and as I understand several things inside the solution has changed. English is not my native language, please be patient.

I got an SonarQube 8.3 up and running with C# plugin 8.6.1, enter image description here

and a SonarScanner 4.3 running aswell for MSBuild for .Net Framework 4.6+. I did not edit the ..\conf\sonar-scanner.properties file,

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

I got a test demo in this directory:

C:\test-demo

That directory have these files

enter image description here

This is the sonar-project.properties file connfiguration,

# 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"

This is the code I want to test, SonarQube should find the errors,

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);
        }
    }
}

But when I run the Scanner I got this,

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: ------------------------------------------------------------------------

enter image description here

I followed the official guide and watched others guides to no avail , I don't know what I am doing wrong here, ¿Could you please help me?

Thank you in advance.

Aucun commentaire:

Enregistrer un commentaire