SonarQube 9.1 does not calculate lines of code DotNet for some projects

Hi,

I’m using the taks “Prepare Analysis Configuration - community v4.8.0” and “Run Code Analysis v5.1.0” from Azure DevOps to report the analyses to the server SonarQube Community v9.1.
In some .NetCore 5 projects, the lines of code are empty or null.

Configuration from the taks “Prepare Analysis Configuration - community”:

  • task: SonarQubePrepareCommunityCommunity@4
    displayName: ‘SonarQube Prepare Analysis’
    inputs:
    SonarQube: ‘${{ parameters.SCAServerConnection }}’
    projectKey: ‘$(Build.DefinitionName)’
    projectName: ‘$(Build.DefinitionName)’
    projectVersion: ‘$(Build.BuildNumber)’
    extraProperties: |
    # Additional properties that will be passed to the scanner. Put one key=value per line
    sonar.verbose=true
    sonar.coverageReportPaths=$(Common.TestResultsDirectory)/Coverage/SonarQube.xml
    sonar.dependencyCheck.htmlReportPath=$(Common.TestResultsDirectory)/dependency-check/dependency-check-report.html
    sonar.dependencyCheck.reportPath=$(Common.TestResultsDirectory)/dependency-check/dependency-check-report.xml
    sonar.dependencyCheck.xmlReportPath=$(Common.TestResultsDirectory)/dependency-check/dependency-check-report.xml
    sonar.dependencyCheck.jsonReportPath=$(Common.TestResultsDirectory)/dependency-check/dependency-check-report.json
    sonar.dependencyCheck.htmlReportPath=$(Common.TestResultsDirectory)/dependency-check/dependency-check-report.html
    sonar.dependencyCheck.reportPath=$(Common.TestResultsDirectory)/dependency-check/dependency-check-report.xml
    sonar.dependencyCheck.xmlReportPath=$(Common.TestResultsDirectory)/dependency-check/dependency-check-report.xml
    sonar.dependencyCheck.jsonReportPath=$(Common.TestResultsDirectory)/dependency-check/dependency-check-report.json

Part of logs from console:

/usr/bin/dotnet /agent/_work/_tasks/SonarQubePrepareCommunityCommunity_33f55862-2cc1-4321-a3e5-6ff3d3f8600b/4.8.0/dotnet-sonar-scanner-msbuild/SonarScanner.MSBuild.dll begin /k:Service
SonarScanner for MSBuild 4.7.1
Using the .NET Core version of the Scanner for MSBuild

I need help to figure out what I’m doing wrong.

Thanks.

Hi @Zecarlos - welcome to the community.

If code smells are being reported but not lines of code, then that suggests the projects are being classified as test code rather than product code. This S4NET wiki page explains how the classification is done and how to check it for your build.

Hi @duncanp

Based on what you said, I’m able to focus where I needed to investigate and I found a package reference that changed the classification from product code to test code.

Thank you for your help.

1 Like

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