SonarCloudPrepare@3 is scanning files it didn't scan in SonarCloudPrepare@2

Template for a good new topic, formatted with Markdown:

  • ALM used: Azure DevOps
  • CI system used: Azure DevOps
  • Scanner command used when applicable:
      - task: SonarCloudPrepare@3
        condition: eq( ${{ parameters.runSonar }}, 'true' )
        inputs:
          SonarCloud: '[Organization]'
          organization: '[Organization]'
          scannerMode: 'dotnet'
          ProjectKey: ${{ variables.sonarProjectKey }}
          extraProperties: |
            sonar.cs.opencover.reportsPaths=$(Build.SourcesDirectory)/**/coverage.opencover.xml
            sonar.cs.vstest.reportsPaths=$(Agent.TempDirectory)/**/*.trx
            sonar.exclusions= ${{ parameters.exclusions }}

      - task: DotNetCoreCLI@2
        inputs:
          command: 'restore'
          projects: 'services/${{ parameters.app }}/**/*.sln'
          feedsToUse: 'select'
          vstsFeed: '[Organization]'
        displayName: 'Restore Nuget Packages'

      - task: DotNetCoreCLI@2
        inputs:
          command: 'build'
          projects: 'services/${{ parameters.app }}/**/*.sln'
          arguments: '--no-restore'
        displayName: 'Build solution'

      - task: DotNetCoreCLI@2
        inputs:
          command: 'test'
          projects: '${{ variables.testProjects }}'
          arguments: '--no-build --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=opencover --collect "Code Coverage"'
        displayName: 'Run unit tests'

      - task: SonarCloudAnalyze@3
        condition: eq( ${{ parameters.runSonar }}, 'true' )
        inputs:
          jdkversion: 'JAVA_HOME_17_X64'

      - task: SonarCloudPublish@3
        condition: eq( ${{ parameters.runSonar }}, 'true' )
        inputs:
          pollingTimeoutSec: '300'

  • Languages of the repository: C#, JSON, YAML, VUE, TS, JS, HTML,
  • Private SonarCloud repository
  • Error observed: See below
  • Steps to reproduce: See below
  • Potential workaround: Excluding all other folders? Or only including the folder that the project is in?

I have an issue updating from V2 to V3. It might be related to some other reported issues, but as I’m not specifically using base folders I think my issue is slightly different.

I also have a monorepo.
My prepare is as follows

      - task: SonarCloudPrepare@3
        condition: eq( ${{ parameters.runSonar }}, 'true' )
        inputs:
          SonarCloud: '[Organization]'
          organization: '[Organization]'
          scannerMode: 'dotnet'
          ProjectKey: ${{ variables.sonarProjectKey }}
          extraProperties: |
            sonar.cs.opencover.reportsPaths=$(Build.SourcesDirectory)/**/coverage.opencover.xml
            sonar.cs.vstest.reportsPaths=$(Agent.TempDirectory)/**/*.trx
            sonar.exclusions= ${{ parameters.exclusions }}

What I am noticing in the new Sonarcloud Analyze v3, is that it’s not just analyzing the built program, but also all other non-dotnet files outside of the project. This includes irrelevant yaml files, as well as the entire UI which is also in a completely different map in the monorepo.
For comparison, V2 takes 27s and has 423 lines of logs,
V3 takes 9m 49s and has 8051 lines of logs.

And, because now it’s duplicating lines which are already pushed in other sonarcloud projects, the Publish fails: This analysis will make your organization to reach the maximum allowed lines limit (having 2112875 lines).

I will admit, I did miss the message in the prepare:

WARNING: Multi-Language analysis is enabled. If this was not intended and you have issues such as hitting your LOC limit or analyzing unwanted files, please set "/d:sonar.scanner.scanAll=false" in the begin step.

Now checking if that resolves the issue.

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