Sonar are not Analyzing C# Code

Server SonarQube:

  • Linux: Ubuntu 20.04
  • Developer Edition Version 8.9 (build 43852)

Source Code

  • Dotnet Core 3.2 e 5.0
  • Files extension *.cs

CI/CD Environment

  • Jenkins with Pipeline
  • dotnet-sonarscanner 5.3.1 – sonar-scanner-4.6.2.2472

Parameter used

NOTE: I change some values because of privacy and security.

dotnet-sonarscanner begin /k:"PB" /d:sonar.login="$TOKEN" \
/n:"Project BackEnd" \
/v:"$BUILD_NUMBER" \
/d:sonar.verbose="false" \
/d:sonar.host.url="https://domain.com/codeverification" \
/d:sonar.branch.name="$BRANCH_NAME" \
/d:sonar.exclusions="ClientApp/**" \
/d:sonar.sourceEncoding="UTF-8"
dotnet build Project.sln
dotnet-sonarscanner end /d:sonar.login="$TOKEN"

Result

INFO: Analysis report uploaded in 745ms
INFO: ANALYSIS SUCCESSFUL, you can browse https://domain.com/codeverification/dashboard?id=PB&branch=develop
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 https://domain.com/codeverification/api/ce/task?id=AXurMLIyCt0QsHalqs3N
INFO: Analysis total time: 7.793 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 22.774s
INFO: Final Memory: 10M/485M
INFO: ------------------------------------------------------------------------
The SonarScanner CLI has finished

PROBLEM

image

  • First, don’t check the lines of other folders, in other words, not doing the analysis.

    NOTE: Inside these folders, I have a lot of files *.cs.

  • Second, I try to exclude ClientApp but continue to load.

  • Third, I am receiving these two warnings.

Conclusion

I don’t know what’s happening, why the sonar is not getting those files, and analyzing the files inside the folders.

Hello @jaderoliver

You have a warning that there is only TEST-code for C#, please take a look at the following document describing the project categorisation process, and check why there is not MAIN-code detected.

There is a warning reported regarding the file encoding. First of all take a look at Program.cs and Startup.cs. These files are detected, but being reported to not contain any lines of code. This leads me to the assumption that the file encoding is wrong here. Maybe the files are encoded in ANSI and not UTF-8. Please check that with Notepad++ e.g.

Hello @jaderoliver

Did you manage to solve the problem you had?