Not scanning all files

  • ALM used: Azure DevOps
  • CI system used: Azure DevOps
  • Scanner command used when applicable: Azure DevOps plugin with scanner mode MSBuild
  • Languages of the repository: C#, JS, CSS, LESS, SCSS
  • Only if the SonarCloud project is public, the URL: private
  • Error observed (wrap logs/code around with triple quotes ``` for proper formatting:

I am setting up SonarCloud for a large private project at the company I work for. I have added the three following tasks to our Azure DevOps CI pipeline:

- task: SonarCloudPrepare@1
    SonarCloud: 'SonarCloudSvcConn'
    organization: '***'
    scannerMode: 'MSBuild'
    projectKey: 'ECommerce'
    projectName: 'ECommerce'

MSBuild gets called…

- task: SonarCloudAnalyze@1

- task: SonarCloudPublish@1
    pollingTimeoutSec: '300'

And the pipeline has run successfully and I can see analysis results in SonarCloud, so I thought all was well however the number of lines of code shown was much lower than I expected so I started looking through files and found many didn’t appear to have been scanned, e.g:

The lines of code column against TipController.cs is “-”
Other files do get scanned:

When I looked on the build agent at the FilesToAnalyze.txt, I can see that the TipController should be analyzed:

The project that this is in is an MVC.Net web application containing a mixture of C#, JS, CSS etc… and as far as I can see only the CSS has results in SonarCloud.
Many other projects within the same solution have had their C# scanned and results are in SonarCloud.

Can anyone help?

I’ve found the issue: the project was being detected as a test project, so it wasn’t analyzing its files.

For anyone with a similar issue coming accross this:
I have added <SonarQubeTestProject>false</SonarQubeTestProject> under the PropertyGroup part of the *.csproj for the relevant project, and that forces SonarQube to treat it as not being a test project.

1 Like

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