Code coverage not working anymore

  • ALM used - Azure DevOps
  • CI system used - Azure DevOps
  • Languages of the repository - .Net

Hello, I’m struggling with an issue for some time now, code coverage on PRs and on main branch is not working anymore as it used to. For example, there are times when some PRs with multiple new lines get code coverage but only for a few files, seems like there are files that have been excluded from analysis even though the settings remained the same, this has been happening since May and I noticed even a dramatic drop in overall detected lines of code for our project, see attached screenshots.

Screenshots related to PR with 0 CC


  - task: SonarCloudPrepare@2
    displayName: Prepare SonarCloud
    inputs:
      SonarCloud: SonarCloud
      organization: my_org
      scannerMode: MSBuild
      projectKey: my_org_project-api
      projectName: project-api
      projectVersion: $(Build.BuildNumber)
      cliSources: $(Build.SourcesDirectory)/src/api/
      configMode: manual
      extraProperties: |
        sonar.verbose=true
        sonar.cs.vstest.reportsPaths=$(System.DefaultWorkingDirectory)/src/api/**/*.trx
        sonar.cs.vscoveragexml.reportsPaths=$(System.DefaultWorkingDirectory)/src/api/merged.coverage.xml
        sonar.exclusions=**/*.js,**/*.map,**/*.css,**/*.xml,**/*.json,**/*.ruleset,**/SonarQube/*,**/Migrations/*,**/wwwroot/*,**/packages/**/*,**/*.dll,**/obj/**/*,**/com.strategikon.maestro.domain/Config/**,**/com.strategikon.maestro.test/**/*,**/com.strategikon.maestro.unittests/**/*,**/*tests.cs
        sonar.coverage.exclusions=**/*.js,**/*.map,**/*.css,**/*.json,**/*.ruleset,**/SonarQube/*,**/Migrations/*,**/wwwroot/*,**/packages/**/*,**/*.dll,**/obj/**/*,**/com.strategikon.maestro.domain/Config/**,**/com.strategikon.maestro.test/**/*,**/com.strategikon.maestro.unittests/**/*,**/*tests.cs      
        $(sonarTargetBranch)
        $(sonarPrBranch)
        $(sonarPrProvider)
        $(sonarPrVstsToken)
        ${{ parameters.testDir }}
    condition: and(succeeded(), eq(variables['detectapi.APIBUILD'], 'true'), or(eq(variables['Build.SourceBranch'], 'refs/heads/main'), eq(variables['Build.Reason'], 'PullRequest'), or(eq(variables['Build.Reason'], 'Manual'), eq(variables['RunSonarScan'], 'true'))),eq(variables.ShouldRunTestsAndScans,'true'))
    continueOnError: true

  - task: DotNetCoreCLI@2
    displayName: Restore NuGet Packages for sln
    env:
      NUGET_PACKAGES: $(Pipeline.Workspace)/.nuget/packages
    inputs:
      command: restore
      projects: |
        $(SolutionAll)
      verbosityRestore: Minimal
      includeNuGetOrg: true
    condition: and(succeeded(), eq(variables['detectapi.APIBUILD'], 'true'))

  - task: DotNetCoreCLI@2
    displayName: Build solutions
    inputs:
      projects: |      
        $(SolutionAll)
      arguments: -c $(BuildConfiguration) --no-restore /p:Version=$(BUILD.FILE_VERSION) -v m /nologo
    condition: and(succeeded(), eq(variables['detectapi.APIBUILD'], 'true'))

  - task: CmdLine@2
    inputs:
      script: |
        dotnet-coverage collect "dotnet test -c $(BuildConfiguration) --blame-hang-timeout 40m --blame-hang-dump-type full --no-restore --no-build -v:normal --nologo --logger trx;LogFileName=$(System.DefaultWorkingDirectory)/src/api/UnitTestResultsVision.trx" -f xml -o "vision.coverage.xml"
      workingDirectory: $(System.DefaultWorkingDirectory)/src/api/vision/com.strategikon.vision.tests
    displayName: Run Vision unit tests
    condition: and(succeeded(),eq(variables.ShouldRunTestsAndScans,'true'), eq(variables['detectapi.APIBUILD'], 'true'))

  - task: CmdLine@2
    inputs:
      script: |
        dotnet-coverage collect "dotnet test -c $(BuildConfiguration) --blame-hang-timeout 40m --blame-hang-dump-type full --no-restore --no-build -v:normal --nologo --logger trx;LogFileName=$(System.DefaultWorkingDirectory)/src/api/UnitTestResultsApi.trx" -f xml -o "api.coverage.xml"
      workingDirectory: $(System.DefaultWorkingDirectory)/src/api/com.strategikon.maestro.unittests
    displayName: Run API unit tests
    condition: and(succeeded(),eq(variables.ShouldRunTestsAndScans,'true'), eq(variables['detectapi.APIBUILD'], 'true'))

  - task: CmdLine@2
    inputs:
      script: |
        dotnet-coverage collect "dotnet test -c $(BuildConfiguration) --blame-hang-timeout 40m --blame-hang-dump-type full --no-restore --no-build -v:normal --nologo --logger trx;LogFileName=$(System.DefaultWorkingDirectory)/src/api/UnitTestWebServerResultsApi.trx" -f xml -o "web.coverage.xml"
      workingDirectory: $(System.DefaultWorkingDirectory)/src/api/com.strategikon.maestro.webserver.unittests
    displayName: Run API unit tests via web server
    condition: and(succeeded(),eq(variables.ShouldRunTestsAndScans,'true'), eq(variables['detectapi.APIBUILD'], 'true'))

  - task: CmdLine@2
    inputs:
      script: |
        dotnet-coverage collect "dotnet test -c $(BuildConfiguration) --blame-hang-timeout 40m --blame-hang-dump-type full --no-restore --no-build -v:normal --nologo --logger trx;LogFileName=$(System.DefaultWorkingDirectory)/src/api/UnitTestSharedComponentsTests.trx" -f xml -o "web.coverage.xml"
      workingDirectory: $(System.DefaultWorkingDirectory)/src/api/Commons/com.strategikon.shared.test
    displayName: Run tests for shared component
    condition: and(succeeded(),eq(variables.ShouldRunTestsAndScans,'true'), eq(variables['detectapi.APIBUILD'], 'true')) 

  - task: CmdLine@2
    inputs:
      script: |
        dotnet-coverage collect "dotnet test -c $(BuildConfiguration) --blame-hang-timeout 40m --blame-hang-dump-type full --no-restore --no-build -v:normal --nologo --logger trx;LogFileName=$(System.DefaultWorkingDirectory)/src/api/UnitTestResultsComment.trx" -f xml -o "comment.coverage.xml"
      workingDirectory: $(System.DefaultWorkingDirectory)/src/api/PlatformServices/Comment/com.strategikon.Comment.tests
    displayName: Run Comment unit tests
    condition: and(succeeded(),eq(variables.ShouldRunTestsAndScans,'true'), eq(variables['detectapi.APIBUILD'], 'true'))

  - task: CmdLine@2
    inputs:
      script: |
        dotnet-coverage collect "dotnet test -c $(BuildConfiguration) --blame-hang-timeout 40m --blame-hang-dump-type full --no-restore --no-build -v:normal --nologo --logger trx;LogFileName=$(System.DefaultWorkingDirectory)/src/api/UnitTestResultsList.trx" -f xml -o "list.coverage.xml"
      workingDirectory: $(System.DefaultWorkingDirectory)/src/api/PlatformServices/List/com.strategikon.list.tests
    displayName: Run List unit tests
    condition: and(succeeded(),eq(variables.ShouldRunTestsAndScans,'true'), eq(variables['detectapi.APIBUILD'], 'true'))

  - task: CmdLine@2
    inputs:
      script: |
        dotnet-coverage collect "dotnet test -c $(BuildConfiguration) --blame-hang-timeout 40m --blame-hang-dump-type full --no-restore --no-build -v:normal --nologo --logger trx;LogFileName=$(System.DefaultWorkingDirectory)/src/api/UnitTestResultsIdentity.trx" -f xml -o "identity.coverage.xml"
      workingDirectory: $(System.DefaultWorkingDirectory)/src/api/PlatformServices/Identity/Tests/com.strategikon.identity.tests
    displayName: Run Identity unit tests
    condition: and(succeeded(),eq(variables.ShouldRunTestsAndScans,'true'), eq(variables['detectapi.APIBUILD'], 'true'))

  - task: CmdLine@2
    inputs:
      script: |
        dotnet-coverage collect "dotnet test -c $(BuildConfiguration) --blame-hang-timeout 40m --blame-hang-dump-type full --no-restore --no-build -v:normal --nologo --logger trx;LogFileName=$(System.DefaultWorkingDirectory)/src/api/UnitTestResultsIdentity.trx" -f xml -o "platformcommon.coverage.xml"
      workingDirectory: $(System.DefaultWorkingDirectory)/src/api/PlatformServices/com.strategikon.common.tests
    displayName: Run Platform common unit tests
    condition: and(succeeded(),eq(variables.ShouldRunTestsAndScans,'true'), eq(variables['detectapi.APIBUILD'], 'true'))

  - task: CmdLine@2
    inputs:
      script: |
        dotnet-coverage collect "dotnet test -c $(BuildConfiguration) --blame-hang-timeout 40m --blame-hang-dump-type full --no-restore --no-build -v:normal --nologo --logger trx;LogFileName=$(System.DefaultWorkingDirectory)/src/api/UnitTestResultsNotification.trx" -f xml -o "notification.coverage.xml"
      workingDirectory: $(System.DefaultWorkingDirectory)/src/api/PlatformServices/Notification/com.strategikon.Notification.tests
    displayName: Run Notification unit tests
    condition: and(succeeded(),eq(variables.ShouldRunTestsAndScans,'true'), eq(variables['detectapi.APIBUILD'], 'true'))

  - task: CmdLine@2
    inputs:
      script: |
        dotnet-coverage collect "dotnet test -c $(BuildConfiguration) --blame-hang-timeout 40m --blame-hang-dump-type full --no-restore --no-build -v:normal --nologo --logger trx;LogFileName=$(System.DefaultWorkingDirectory)/src/api/UnitTestResultsIssueTracker.trx" -f xml -o "issuetracker.coverage.xml"
      workingDirectory: $(System.DefaultWorkingDirectory)/src/api/PlatformServices/IssueTracker/com.strategikon.issuetracker.tests
    displayName: Run Issue Tracker unit tests
    condition: and(succeeded(),eq(variables.ShouldRunTestsAndScans,'true'), eq(variables['detectapi.APIBUILD'], 'true'))

  - task: CmdLine@2
    inputs:
      script: |
        dotnet-coverage collect "dotnet test -c $(BuildConfiguration) --blame-hang-timeout 40m --blame-hang-dump-type full --no-restore --no-build -v:normal --nologo --logger trx;LogFileName=$(System.DefaultWorkingDirectory)/src/api/UnitTestResultsAttachment.trx" -f xml -o "attachment.coverage.xml"
      workingDirectory: $(System.DefaultWorkingDirectory)/src/api/PlatformServices/Attachment/com.strategikon.Attachment.tests
    displayName: Run Attachment unit tests
    condition: and(succeeded(),eq(variables.ShouldRunTestsAndScans,'true'), eq(variables['detectapi.APIBUILD'], 'true'))

  - task: CmdLine@2
    inputs:
      script: |
        dotnet-coverage collect "dotnet test -c $(BuildConfiguration) --blame-hang-timeout 40m --blame-hang-dump-type full --no-restore --no-build -v:normal --nologo --logger trx;LogFileName=$(System.DefaultWorkingDirectory)/src/api/UnitTestResultsEtl.trx" -f xml -o "etl.coverage.xml"
      workingDirectory: $(System.DefaultWorkingDirectory)/src/api/com.strategikon.etl.unittests
    displayName: Run ETL unit tests
    condition: and(succeeded(),eq(variables.ShouldRunTestsAndScans,'true'), eq(variables['detectapi.APIBUILD'], 'true'))

  - task: CmdLine@2
    inputs:
      script: |
        dotnet-coverage collect "dotnet test -c $(BuildConfiguration) --blame-hang-timeout 40m --blame-hang-dump-type full --no-restore --no-build -v:normal --nologo --logger trx;LogFileName=$(System.DefaultWorkingDirectory)/src/api/UnitTestResultsFormula.trx" -f xml -o "formula.coverage.xml"
      workingDirectory: $(System.DefaultWorkingDirectory)/src/api/Commons/Formula/com.strategikon.Formula.tests
    displayName: Run Formula unit tests
    condition: and(succeeded(),eq(variables.ShouldRunTestsAndScans,'true'), eq(variables['detectapi.APIBUILD'], 'true'))

  - task: CmdLine@2
    inputs:
      script: |
        dotnet-coverage collect "dotnet test -c $(BuildConfiguration) --blame-hang-timeout 40m --blame-hang-dump-type full --no-restore --no-build -v:normal --nologo --logger trx;LogFileName=$(System.DefaultWorkingDirectory)/src/api/UnitTestResultsPortfolio.trx" -f xml -o "portfolio.coverage.xml"
      workingDirectory: $(System.DefaultWorkingDirectory)/src/api/Maestro/Portfolio/Portfolio.tests
    displayName: Run Portfolio unit tests
    condition: and(succeeded(),eq(variables.ShouldRunTestsAndScans,'true'), eq(variables['detectapi.APIBUILD'], 'true'))

  - task: CmdLine@2
    inputs:
      script: |
        dotnet-coverage collect "dotnet test -c $(BuildConfiguration) --blame-hang-timeout 40m --blame-hang-dump-type full --no-restore --no-build -v:normal --nologo --logger trx;LogFileName=$(System.DefaultWorkingDirectory)/src/api/UnitTestResultsCustomAssumptions.trx" -f xml -o "customassumptions.coverage.xml"
      workingDirectory: $(System.DefaultWorkingDirectory)/src/api/Maestro/Portfolio/Portfolio.CustomAssumptions.tests
    displayName: Run CustomAssumptions unit tests
    condition: and(succeeded(),eq(variables.ShouldRunTestsAndScans,'true'), eq(variables['detectapi.APIBUILD'], 'true'))

  - task: CmdLine@2
    inputs:
      script: |
        dotnet-coverage collect "dotnet test -c $(BuildConfiguration) --blame-hang-timeout 40m --blame-hang-dump-type full --no-restore --no-build -v:normal --nologo --logger trx;LogFileName=$(System.DefaultWorkingDirectory)/src/api/UnitTestResultsQuestion.trx" -f xml -o "question.coverage.xml"
      workingDirectory: $(System.DefaultWorkingDirectory)/src/api/PlatformServices/Question/com.strategikon.Question.tests
    displayName: Run Question unit tests
    condition: and(succeeded(),eq(variables.ShouldRunTestsAndScans,'true'), eq(variables['detectapi.APIBUILD'], 'true'))

  - task: CmdLine@2
    inputs:
      script: |
        dotnet-coverage collect "dotnet test -c $(BuildConfiguration) --blame-hang-timeout 40m --blame-hang-dump-type full --no-restore --no-build -v:normal --nologo --logger trx;LogFileName=$(System.DefaultWorkingDirectory)/src/api/UnitTestResultsAudit.trx" -f xml -o "audit.coverage.xml"
      workingDirectory: $(System.DefaultWorkingDirectory)/src/api/PlatformServices/Audit/com.strategikon.audit.tests
    displayName: Run Audit unit tests
    condition: and(succeeded(),eq(variables.ShouldRunTestsAndScans,'true'), eq(variables['detectapi.APIBUILD'], 'true'))

  - task: CmdLine@2
    inputs:
      script: |
        dotnet-coverage collect "dotnet test -c $(BuildConfiguration) --blame-hang-timeout 40m --blame-hang-dump-type full --no-restore --no-build -v:normal --nologo --logger trx;LogFileName=$(System.DefaultWorkingDirectory)/src/api/UnitTestResultsRouting.trx" -f xml -o "routing.coverage.xml"
      workingDirectory: $(System.DefaultWorkingDirectory)/src/api/PlatformServices/Routing/Tests/com.strategikon.routing.tests
    displayName: Run Routing unit tests
    condition: and(succeeded(),eq(variables.ShouldRunTestsAndScans,'true'), eq(variables['detectapi.APIBUILD'], 'true'))

  - task: CmdLine@2
    inputs:
      script: |
        dotnet-coverage collect "dotnet test -c $(BuildConfiguration) --blame-hang-timeout 40m --blame-hang-dump-type full --no-restore --no-build -v:normal --nologo --logger trx;LogFileName=$(System.DefaultWorkingDirectory)/src/api/IntegrationTestResults.trx" -f xml -o "integration.coverage.xml"
      workingDirectory: $(System.DefaultWorkingDirectory)/src/api/com.strategikon.maestro.test
    displayName: Run API integration (DB) tests
    condition: and(succeeded(),eq(variables.ShouldRunTestsAndScans,'true'), eq(variables['detectapi.APIBUILD'], 'true'))  
    continueOnError: true      

  - task: DotNetCoreCLI@2
    displayName: 'Merge code coverage files'
    inputs:
      command: custom
      custom: coverage
      arguments: 'merge *.coverage.xml --recursive --output "$(System.DefaultWorkingDirectory)/src/api/merged.coverage.xml" --output-format xml'
    condition: and(succeeded(), eq(variables['detectapi.APIBUILD'], 'true'), eq(variables['RunSonarScan'], 'true'),eq(variables.ShouldRunTestsAndScans,'true'))      

  - task: SonarCloudAnalyze@2
    displayName: Perform analysis on SonarCloud
    condition: and(succeeded(), eq(variables['detectapi.APIBUILD'], 'true'), eq(variables['RunSonarScan'], 'true'),eq(variables.ShouldRunTestsAndScans,'true'))
    continueOnError: true

  - task: SonarCloudPublish@2
    displayName: Publishing SonarCloud scan results
    inputs:
      pollingTimeoutSec: 300
    condition: and(succeeded(), eq(variables['detectapi.APIBUILD'], 'true'), eq(variables['RunSonarScan'], 'true'),eq(variables.ShouldRunTestsAndScans,'true'))
    continueOnError: true    

Before these issues we used to restore & build each sln file individually, not the sln that contains all, also we were not merging code coverage files as well, these were some changes done to test if there will be any other outcome. As you can see we’re running the analysis in verbose, so I have full logs. Followed this guide How to find logs about importing code coverage related to the logs but I find anything useful. If anyone has a suggestion I can provide more logs as now I don’t really know what logs will be useful

hi @mateidoncu ,

can you check that the coverage file is generated in the working directory before the sonar analysis is executed?

The coverage files are generated fine, I checked that already.

Hi,

Can you post your full verbose log, please? Everything from the start command through to the end.

 
Thx,
Ann

sonar_verbose_logs.txt (7.1 MB)
Hello Ann,

I attached the full verbose log as txt file as there are too many lines to be posted in the thread.

Thanks for the help,
Matei

Hi Matei,

I wanted the start command and the build too, but fortunately what you provided turns out to be enough.

First we have this:

2024-08-05T06:49:15.6124985Z 06:49:15.553 INFO: Sensor C# Tests Coverage Report Import [csharp]
2024-08-05T06:49:15.6125854Z 06:49:15.554 DEBUG: Analyzing coverage with wildcardPatternFileProvider with base dir '/home/vsts/work/1/.' and file separator '/'.
2024-08-05T06:49:15.6126980Z 06:49:15.562 DEBUG: Pattern matcher extracted prefix/absolute path '/home/vsts/work/1/s/src/api/merged.coverage.xml' from the given pattern '/home/vsts/work/1/s/src/api/merged.coverage.xml'.
2024-08-05T06:49:15.6127901Z 06:49:15.563 DEBUG: Pattern matcher returns a single file: '/home/vsts/work/1/s/src/api/merged.coverage.xml'.
2024-08-05T06:49:15.6128710Z 06:49:15.563 DEBUG: The current user dir is '/home/vsts/work/1'.
2024-08-05T06:49:15.6129439Z 06:49:15.564 INFO: Parsing the Visual Studio coverage XML report /home/vsts/work/1/s/src/api/merged.coverage.xml

So the coverage file is found and successfully read.

And then there are about 400 lines like this

2024-08-05T06:49:15.6608563Z 06:49:15.660 DEBUG: Did not find deterministic source path in '/home/runner/work/testlogger/testlogger/src/TestLogger/TestLogger.cs'. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
2024-08-05T06:49:15.6663998Z 06:49:15.665 DEBUG: Did not find deterministic source path in '/home/runner/work/testlogger/testlogger/src/TestLogger/Utilities/AttachmentSetExtensions.cs'. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.

So the paths analysis is seeing don’t match the paths in the coverage report.

 
HTH,
Ann

Hello Ann,

Thanks for the answer, but unfortunately I don’t think this is the solution for my problem. I’ve checked again the logs and most of the lines that contain

DEBUG: Did not find deterministic source path in

have paths that are excluded from coverage

sonar.exclusions=**/*.js,**/*.map,**/*.css,**/*.xml,**/*.json,**/*.ruleset,**/SonarQube/*,**/Migrations/*,**/wwwroot/*,**/packages/**/*,**/*.dll,**/obj/**/*,**/com.strategikon.maestro.domain/Config/**,**/com.strategikon.maestro.test/**/*,**/com.strategikon.maestro.unittests/**/*,**/*tests.cs
sonar.coverage.exclusions=**/*.js,**/*.map,**/*.css,**/*.json,**/*.ruleset,**/SonarQube/*,**/Migrations/*,**/wwwroot/*,**/packages/**/*,**/*.dll,**/obj/**/*,**/com.strategikon.maestro.domain/Config/**,**/com.strategikon.maestro.test/**/*,**/com.strategikon.maestro.unittests/**/*,**/*tests.cs

I’m not sure about these paths, but I believe are related to the libraries used for tests and I think they should be expected

2024-08-05T06:49:15.6608563Z 06:49:15.660 DEBUG: Did not find deterministic source path in '/home/runner/work/testlogger/testlogger/src/TestLogger/TestLogger.cs'. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
2024-08-05T06:49:15.6663998Z 06:49:15.665 DEBUG: Did not find deterministic source path in '/home/runner/work/testlogger/testlogger/src/TestLogger/Utilities/AttachmentSetExtensions.cs'. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
07:09:24.414 DEBUG: Did not find deterministic source path in '/Users/jskinner/code/FluentValidation/src/FluentValidation/AbstractValidator.cs'. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
07:09:24.422 DEBUG: Did not find deterministic source path in '/Users/jskinner/code/FluentValidation/src/FluentValidation/AssemblyScanner.cs'. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
07:09:24.423 DEBUG: Did not find deterministic source path in '/Users/jskinner/code/FluentValidation/src/FluentValidation/DefaultValidatorExtensions.cs'. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
07:09:24.423 DEBUG: Did not find deterministic source path in '/Users/jskinner/code/FluentValidation/src/FluentValidation/DefaultValidatorExtensions_Validate.cs'. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
07:09:24.424 DEBUG: Did not find deterministic source path in '/Users/jskinner/code/FluentValidation/src/FluentValidation/DefaultValidatorOptions.cs'. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.

Hi,

If those files are excluded from coverage, perhaps you can get them out of the coverage report? Then a new log will only show the pertinent stuff.

 
Ann

Hello,

I tried to explicitly exclude those paths here, but no success, they are still appearing in the logs

sonar.exclusions=**/*.js,**/*.map,**/*.css,**/*.xml,**/*.json,**/*.ruleset,**/SonarQube/*,**/Migrations/*,**/wwwroot/*,**/packages/**/*,**/*.dll,**/obj/**/*,**/com.strategikon.maestro.domain/Config/**,**/com.strategikon.maestro.test/**/*,**/com.strategikon.maestro.unittests/**/*,**/*tests.cs,**/jskinner/code/FluentValidation/src/FluentValidation/**/*,**/testlogger/testlogger/src/TestLogger/**/*
sonar.coverage.exclusions=**/*.js,**/*.map,**/*.css,**/*.json,**/*.ruleset,**/SonarQube/*,**/Migrations/*,**/wwwroot/*,**/packages/**/*,**/*.dll,**/obj/**/*,**/com.strategikon.maestro.domain/Config/**,**/com.strategikon.maestro.test/**/*,**/com.strategikon.maestro.unittests/**/*,**/*tests.cs,**/jskinner/code/FluentValidation/src/FluentValidation/**/*,**/testlogger/testlogger/src/TestLogger/**/*

I don’t think those paths can be excluded neither from sonar or source code to not post them into coverage report because those paths are generated by the .Net libraries we are using

Hi,

I don’t mean exclude them on the anlaysis side. I mean prevent them from being in your coverage report.

 
Ann

Hello Ann,

Sorry for coming back on this just now, but there were other important things to do and I had to postpone this. I managed to get rid of those paths from the coverage report as you suggested and I attached a new txt file with the new verbose logs
sonar_analysis_logs.txt (5.8 MB)

But still this doesn’t solve my problems with coverage on PRs or main branch. Ok on this PR I have 2 new lines which are just comments, but I suppose it should display 100% coverage, right?

Anyway the main issue still stands on the main branch where I still don’t have coverage for some of the folders I used to have

Any other suggestions are appreciated!

Thanks,
Matei

I also think the PR coverage issues are related to the bug mentioned in some other threads

E.g: Currently, SonarCloud does not show coverage analysis on each pull-request - #22 by weitzmax

Hi,

Did you check the new log?

We again have

2024-08-15T08:50:49.2223213Z 08:50:49.222 INFO: Sensor C# Tests Coverage Report Import [csharp]
2024-08-15T08:50:49.2234390Z 08:50:49.223 DEBUG: Analyzing coverage with wildcardPatternFileProvider with base dir '/home/vsts/work/1/.' and file separator '/'.
2024-08-15T08:50:49.2250500Z 08:50:49.224 DEBUG: Pattern matcher extracted prefix/absolute path '/home/vsts/work/1/s/src/api/merged.coverage.xml' from the given pattern '/home/vsts/work/1/s/src/api/merged.coverage.xml'.
2024-08-15T08:50:49.2259513Z 08:50:49.225 DEBUG: Pattern matcher returns a single file: '/home/vsts/work/1/s/src/api/merged.coverage.xml'.
2024-08-15T08:50:49.2267118Z 08:50:49.226 DEBUG: The current user dir is '/home/vsts/work/1'.
2024-08-15T08:50:49.2271296Z 08:50:49.226 INFO: Parsing the Visual Studio coverage XML report /home/vsts/work/1/s/src/api/merged.coverage.xml

And then 209 lines of

2024-08-15T08:50:49.5804710Z 08:50:49.578 DEBUG: The file '/_/src/HealthChecks.Publisher.ApplicationInsights/DependencyInjection/ApplicationInsightsHealthCheckBuilderExtensions.cs' is not indexed or does not have the supported language. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
2024-08-15T08:50:49.5995450Z 08:50:49.598 DEBUG: The file '/_/src/HealthChecks.Publisher.ApplicationInsights/ApplicationInsightsPublisher.cs' is not indexed or does not have the supported language. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
2024-08-15T08:50:49.6192498Z 08:50:49.618 DEBUG: The file '/_/src/HealthChecks.Publisher.ApplicationInsights/DependencyInjection/ApplicationInsightsHealthCheckBuilderExtensions.cs' is not indexed or does not have the supported language. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
2024-08-15T08:50:49.6386785Z 08:50:49.638 DEBUG: The file '/_/src/HealthChecks.Publisher.ApplicationInsights/ApplicationInsightsPublisher.cs' is not indexed or does not have the supported language. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
2024-08-15T08:50:49.6582681Z 08:50:49.657 DEBUG: The file '/_/src/HealthChecks.SqlServer/SqlServerHealthCheck.cs' is not indexed or does not have the supported language. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.

Yes, I agree.
AND that’s a whole separate question, and we try to keep it to one topic per thread. Otherwise it can get messy, fast. So let’s just set that aside.

Regarding your screenshots, is the main concern all the rows / directories with dashes for Lines of Code and for Coverage? Because Lines of Code aren’t counted for tests, so the screenshot indicates that those are test directories.

 
HTH,
Ann

Hello,

I supposed these logs mean that the coverage report has been succesfully read, what’s wrong with that?

2024-08-15T08:50:49.2223213Z 08:50:49.222 INFO: Sensor C# Tests Coverage Report Import [csharp]
2024-08-15T08:50:49.2234390Z 08:50:49.223 DEBUG: Analyzing coverage with wildcardPatternFileProvider with base dir '/home/vsts/work/1/.' and file separator '/'.
2024-08-15T08:50:49.2250500Z 08:50:49.224 DEBUG: Pattern matcher extracted prefix/absolute path '/home/vsts/work/1/s/src/api/merged.coverage.xml' from the given pattern '/home/vsts/work/1/s/src/api/merged.coverage.xml'.
2024-08-15T08:50:49.2259513Z 08:50:49.225 DEBUG: Pattern matcher returns a single file: '/home/vsts/work/1/s/src/api/merged.coverage.xml'.
2024-08-15T08:50:49.2267118Z 08:50:49.226 DEBUG: The current user dir is '/home/vsts/work/1'.
2024-08-15T08:50:49.2271296Z 08:50:49.226 INFO: Parsing the Visual Studio coverage XML report /home/vsts/work/1/s/src/api/merged.coverage.xml

I know these following logs suggest that those files will be skipped same as the ones I got rid of from the report, but I don’t really care about those paths, those are generated by the libraries, those can not be found in the source code whatsoever so they can be skipped just fine, why they should really affect the coverage in the first place?

2024-08-15T08:50:49.5804710Z 08:50:49.578 DEBUG: The file '/_/src/HealthChecks.Publisher.ApplicationInsights/DependencyInjection/ApplicationInsightsHealthCheckBuilderExtensions.cs' is not indexed or does not have the supported language. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
2024-08-15T08:50:49.5995450Z 08:50:49.598 DEBUG: The file '/_/src/HealthChecks.Publisher.ApplicationInsights/ApplicationInsightsPublisher.cs' is not indexed or does not have the supported language. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
2024-08-15T08:50:49.6192498Z 08:50:49.618 DEBUG: The file '/_/src/HealthChecks.Publisher.ApplicationInsights/DependencyInjection/ApplicationInsightsHealthCheckBuilderExtensions.cs' is not indexed or does not have the supported language. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
2024-08-15T08:50:49.6386785Z 08:50:49.638 DEBUG: The file '/_/src/HealthChecks.Publisher.ApplicationInsights/ApplicationInsightsPublisher.cs' is not indexed or does not have the supported language. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
2024-08-15T08:50:49.6582681Z 08:50:49.657 DEBUG: The file '/_/src/HealthChecks.SqlServer/SqlServerHealthCheck.cs' is not indexed or does not have the supported language. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.

To answer the question related to screenshots, yes, the issue is with all the directories that have dashes for lines of code and coverage and indeed some of them are test directories and have been excluded from the analysis as can be seen in the sonar configuration

sonar.exclusions=**/*.js,**/*.map,**/*.css,**/*.xml,**/*.json,**/*.ruleset,**/SonarQube/*,**/Migrations/*,**/wwwroot/*,**/packages/**/*,**/*.dll,**/obj/**/*,**/com.strategikon.maestro.domain/Config/**,**/com.strategikon.maestro.test/**/*,**/com.strategikon.maestro.unittests/**/*,**/*tests.cs
sonar.coverage.exclusions=**/*.js,**/*.map,**/*.css,**/*.json,**/*.ruleset,**/SonarQube/*,**/Migrations/*,**/wwwroot/*,**/packages/**/*,**/*.dll,**/obj/**/*,**/com.strategikon.maestro.domain/Config/**,**/com.strategikon.maestro.test/**/*,**/com.strategikon.maestro.unittests/**/*,**/*tests.cs

But there are many other directories which are not test directories and which don’t have neither lines of code or coverage detected, that’s my biggest concern and also the dramatic decrease in lines to cover and covered lines, which i believe is related to the coverage detected for directories, that can be seen in the chart which I already investigated because I thought is due to changes in the code, but there are no commits that might have affected it

Hi,

It sounds like, for one reason or another, they’ve been detected as tests. As I said before, Lines of Code aren’t counted for test files, and - naturally - they’re not eligible for coverage.

These docs may help.

 
HTH,
Ann