LoC and Issues missing in Analysis after upgrade from 7.9.1 to 9.2.4


SonarQube: 9.2.4
SonarQubeScanner: 5.3.1
Classic SonarQube Scanner MSBuild: 5.4.1
Azure DevOps and .NET 5 project.

Since I’ve upgraded SonarQube from 7.9.1 to 9.2.4 I have several analysis issues:

  • The number of line of code has reduced from 34k to 7k.
  • Half of the code smells were closed without fix (ex: We had 10+ TODO in the code and I only see 1 in the analysis, we had 15+ complex method to refactor and I see 0).

There is no errors in the logs of Azure DevOps and SonarQube.
I did not change any configuration (apart the version upgrade in the yaml build).

Lines of code

For 6 folders the number of line is not displayed and not counted.

We did no changes during a few months and not a lot changed since the last analysis.

I have upgraded the yaml build from @4 to @5.

  - task: SonarQubePrepare@5
    displayName: 'SonarQube Prepare'
      SonarQube: 'SonarQube'
      scannerMode: 'MSBuild'
      projectKey: 'xxx'
      projectName: 'xxx'
      extraProperties: |

  - task: NuGetToolInstaller@1
      versionSpec: 5.8.1

  - task: DotNetCoreCLI@2
    displayName:  'Restore'
      command: 'restore'
      projects: |
      feedsToUse: 'select'

  - task: DotNetCoreCLI@2
    displayName:  'Build'
      command: 'build'
      projects: |
      arguments: '--configuration $(buildConfiguration)'

# TEST #
  - task: DotNetCoreCLI@2
    displayName:  'Test'
      command: 'test'
      projects: '**/*Test/*.csproj'
      arguments: '--configuration $(BuildConfiguration) --collect:"XPlat Code Coverage"'
      nobuild: true

  - script: |
      dotnet tool install -g dotnet-reportgenerator-globaltool
      reportgenerator -reports:$(Agent.TempDirectory)\**\coverage.cobertura.xml -targetdir:$(Build.SourcesDirectory)\CodeCoverage -reporttypes:"HtmlInline_AzurePipelines;Cobertura;SonarQube"
    displayName: Create Code Coverage report

  - task: PublishCodeCoverageResults@1
    displayName: 'Publish code coverage'
      codeCoverageTool: Cobertura
      summaryFileLocation: '$(Build.SourcesDirectory)\CodeCoverage\Cobertura.xml'
      reportDirectory: '$(Build.SourcesDirectory)\CodeCoverage'
      failIfCoverageEmpty: false

# SonarQube #
  - task: SonarQubeAnalyze@5
    displayName: 'SonarQube Analyze'

  - task: SonarQubePublish@5
    displayName: 'SonarQube Publish'
      pollingTimeoutSec: '300'

When I do the analysis locally with SonarLint everything seems fine.
Can you help me please?


This looks like there’s been a change in the number of LOCs, which might be due to a change in a way projects are classified as Product code vs Test projects.

Could you please read How .NET projects are considered Prod or Test by the scanner and check the logs for the classification?

1 Like

This topic was automatically closed after 10 days. New replies are no longer allowed.