Analysis completed but Missing LOC, Duplications, Coverage

I am using SonarCloud analysis in Docker (from Azure DevOps), for solution (more than 100 .NET 6 projects).

Following logs everything seems fine - projects are being scaned by Sonar and I am getting a message that sonarcloud analysis is successful as well.

But, when I am checking results in sonarcloud.io, on the dahsboard i can notice that LOC, Duplications, Coverage and other stats are empty - except code smells.

Hi,

Welcome to the community!

When you dig in to one of those projects/directories that shows - for Lines of Code, what kinds of files (languages) do you see?

 
Ann

There is 40k lines of code - 37k of css and 3k of c#.

It is weird that i also tried to have explict inclusion and exclusion of files, but again i got same result:

RUN dotnet sonarscanner begin \
  /k:"$SONAR_PROJECT_KEY" \
  /o:"$SONAR_OGRANIZAION_KEY" \
  /d:sonar.host.url="$SONAR_HOST_URL" \
  /d:sonar.login="$SONAR_TOKEN" \
  /d:sonar.verbose=true \
  /d:sonar.exclusions=**/*.css \
  /d:sonar.inclusions=**/*.cs \
  /d:sonar.cs.dotcover.reportsPaths=dotCover.Output.html

Beside this I tried to use inclusion and exlusion on “Analysis Scope” as well, but result is same:

Hi,

There’s no need to explicitly include **/*.cs. That’s in there by default. Can you try without it? Also, can you post your analysis log?

The analysis log is what’s output from the analysis command. Hopefully, the log you provide will include that command as well.

 
Ann

Yes, i tried without explicit definition, but it was not working…I cannot share full log, but here is some parts of it:

Step 28/51 : RUN dotnet sonarscanner begin   /k:"$SONAR_PROJECT_KEY"   /o:"$SONAR_OGRANIZAION_KEY"   /d:sonar.host.url="$SONAR_HOST_URL"   /d:sonar.login="$SONAR_TOKEN"   /d:sonar.cs.dotcover.reportsPaths=dotCover.Output.html
 ---> Running in 3e0c3bfa680c
SonarScanner for MSBuild 5.7.1
Using the .NET Core version of the Scanner for MSBuild
Pre-processing started.
Preparing working directories...
19:26:19.523  Updating build integration targets...
19:26:19.863  Fetching analysis configuration settings...
19:26:20.26  Provisioning analyzer assemblies for cs...
19:26:20.261  Installing required Roslyn analyzers...
19:26:20.762  Provisioning analyzer assemblies for vbnet...
19:26:20.762  Installing required Roslyn analyzers...
19:26:20.794  Pre-processing succeeded.

…then in build action, a bunch of:

  XXXX.XXXX.Integration.Monitor -> /lens/src/core/XXXX.XXXX.Integration.Monitor/bin/Release/net6.0/XXXX.XXXX.Integration.Monitor.dll
  Sonar: (XXXX.XXXX.Integration.Monitor.csproj) Project processed successfully

And than after test execution:

lens-sonar | [JetBrains dotCover] Analyzed application exited with code '1'
lens-sonar | [JetBrains dotCover] Coverage session finished [07/05/2022 21:03:25]
lens-sonar | [JetBrains dotCover] Coverage results post-processing started [07/05/2022 21:03:25]
lens-sonar | [JetBrains dotCover] Merging snapshots [07/05/2022 21:03:25]
lens-sonar | [JetBrains dotCover] Snapshots merging finished [07/05/2022 21:03:45]
lens-sonar | [JetBrains dotCover] Report generation started [07/05/2022 21:03:45]
lens-sonar | [JetBrains dotCover] Report generation finished [07/05/2022 21:03:50]
lens-sonar | [JetBrains dotCover] Coverage results post-processing finished [07/05/2022 21:03:50]
lens-sonar | SonarScanner for MSBuild 5.7.1
lens-sonar | Using the .NET Core version of the Scanner for MSBuild
lens-sonar | Post-processing started.
lens-sonar | Calling the SonarScanner CLI...
lens-sonar | INFO: Scanner configuration file: /root/.dotnet/tools/.store/dotnet-sonarscanner/5.7.1/dotnet-sonarscanner/5.7.1/tools/net5.0/any/sonar-scanner-4.7.0.2747/conf/sonar-scanner.properties
lens-sonar | INFO: Project root configuration file: /lens/src/.sonarqube/out/sonar-project.properties
lens-sonar | INFO: SonarScanner 4.7.0.2747
lens-sonar | INFO: Java 11.0.15 Debian (64-bit)
lens-sonar | INFO: Linux 5.10.104-linuxkit amd64
lens-sonar | INFO: User cache: /root/.sonar/cache
lens-sonar | INFO: Scanner configuration file: /root/.dotnet/tools/.store/dotnet-sonarscanner/5.7.1/dotnet-sonarscanner/5.7.1/tools/net5.0/any/sonar-scanner-4.7.0.2747/conf/sonar-scanner.properties
lens-sonar | INFO: Project root configuration file: /lens/src/.sonarqube/out/sonar-project.properties
lens-sonar | INFO: Analyzing on SonarCloud
lens-sonar | INFO: Default locale: "en_US", source code encoding: "US-ASCII" (analysis is platform dependent)
lens-sonar | INFO: Load global settings
lens-sonar | INFO: Load global settings (done) | time=314ms
lens-sonar | INFO: Server id: 1BD809FA-AWHW8ct9-T_TB3XqouNu
lens-sonar | INFO: User cache: /root/.sonar/cache
lens-sonar | INFO: Load/download plugins
lens-sonar | INFO: Load plugins index
lens-sonar | INFO: Load plugins index (done) | time=94ms
lens-sonar | INFO: Load/download plugins (done) | time=36176ms
lens-sonar | INFO: Loaded core extensions: developer-scanner
lens-sonar | INFO: Load project settings for component key: 'Xxxx_xxxx'
lens-sonar | INFO: Load project settings for component key: 'Xxxx_xxxx' (done) | time=66ms
lens-sonar | INFO: Process project properties
lens-sonar | INFO: Execute project builders
lens-sonar | INFO: Execute project builders (done) | time=633ms
lens-sonar | INFO: Project key: Xxxx_xxxx
lens-sonar | INFO: Base dir: /lens/src
lens-sonar | INFO: Working dir: /lens/src/.sonarqube/out/.sonar
lens-sonar | INFO: Load project branches
lens-sonar | INFO: Load project branches (done) | time=64ms
lens-sonar | INFO: Check ALM binding of project 'Xxxx_xxxx'
lens-sonar | INFO: Detected project binding: BOUND
lens-sonar | INFO: Check ALM binding of project 'Xxxx_ xxxx' (done) | time=54ms
lens-sonar | INFO: Load project pull requests
lens-sonar | INFO: Load project pull requests (done) | time=58ms
lens-sonar | INFO: Load branch configuration
lens-sonar | INFO: Load branch configuration (done) | time=3ms
lens-sonar | INFO: Load quality profiles
lens-sonar | INFO: Load quality profiles (done) | time=135ms
lens-sonar | INFO: Load active rules
lens-sonar | INFO: Load active rules (done) | time=2910ms
lens-sonar | 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.
lens-sonar | INFO: Organization key: froda
lens-sonar | INFO: Load project repositories
lens-sonar | INFO: Load project repositories (done) | time=68ms
lens-sonar | INFO: Indexing files...
lens-sonar | INFO: Project configuration:
lens-sonar | INFO:   Excluded sources: **/build-wrapper-dump.json
lens-sonar | INFO: Indexing files of module 'XXX.Payouts.Tests'
lens-sonar | INFO:   Base dir: /xxx/src/core/XXXX.Payouts.Tests
lens-sonar | INFO:   Test paths: MemoryPayoutSigningSessionRepository.cs, MemoryPayoutsRepositor...
lens-sonar | INFO:   Excluded sources: **/build-wrapper-dump.json
lens-sonar | INFO: Indexing files of module 'XXX.XXX.BankIntegration.Tests'
lens-sonar | INFO:   Base dir: /xxx/src/core/XXX.XXX.BankIntegration.Tests
lens-sonar | INFO:   Test paths: BankAccountHelperTests.cs, BankDataReportProviderTests.cs, Serv...
lens-sonar | INFO:   Excluded sources: **/build-wrapper-dump.json
lens-sonar | INFO: Indexing files of module 'Froda.BankAccount.Test

and then on the end:

lens-sonar | INFO: Adding this code coverage report to the cache for later reuse: /lens/src/./dotCover.Output.html
lens-sonar | INFO: Coverage Report Statistics: 3081 files, 50 main files, 50 main files with coverage, 3031 test files, 0 project excluded files, 0 other language files.
lens-sonar | INFO: Sensor C# Tests Coverage Report Import [csharp] (done) | time=1454ms
lens-sonar | INFO: Sensor Zero Coverage Sensor
lens-sonar | INFO: Sensor Zero Coverage Sensor (done) | time=2ms
lens-sonar | INFO: SCM Publisher No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it.
lens-sonar | INFO: CPD Executor 16 files had no CPD blocks
lens-sonar | INFO: CPD Executor Calculating CPD for 47 files
lens-sonar | INFO: CPD Executor CPD calculation finished (done) | time=57ms
lens-sonar | INFO: Analysis report generated in 1361ms, dir size=29 MB
lens-sonar | INFO: Analysis report compressed in 4160ms, zip size=10 MB
lens-sonar | INFO: Analysis report uploaded in 12858ms
lens-sonar | INFO: ANALYSIS SUCCESSFUL, you can find the results at: https://sonarcloud.io/dashboard?id=Xxxx_xxxx
lens-sonar | INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
lens-sonar | INFO: More about the report processing at https://sonarcloud.io/api/ce/task?id=AYHQLqx5cuUBuKXVTAXX
lens-sonar | INFO: Analysis total time: 55.742 s
lens-sonar | INFO: ------------------------------------------------------------------------
lens-sonar | INFO: EXECUTION SUCCESS
lens-sonar | INFO: ------------------------------------------------------------------------
lens-sonar | INFO: Total time: 1:36.959s
lens-sonar | INFO: Final Memory: 51M/180M
lens-sonar | INFO: ------------------------------------------------------------------------
lens-sonar | The SonarScanner CLI has finished
lens-sonar | 21:05:30.373  Post-processing succeeded.

Hi,

Thanks for the log.

I believe that because your project names all include “Tests” they’re being treated as test projects, and thus:

  • only rules related to test code will be executed.
  • test projects do not count towards to the Lines of Code (“LOC”) limit for commercial versions of SonarQube or private SonarCloud projects.
  • metrics and copy/paste detection data are not calculated for test projects, although syntax colourisation and symbol highlighting are supported.

 
HTH,
Ann

Hey Ann!

You are right with a cause - all other projects are categorized as Test projects, I am not sure why, cause definitely their names doesn’t include “Tests”.

Anyway, as solution I marked explicitly all my non-test projects with:

<SonarQubeTestProject>false</SonarQubeTestProject>

Thanks for help!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.