SonarCloud ignore stylecop analyser error on test projects

We are using stylecop on all our projects also our tests projects(dotnet).

On our build agent we have SonarCloud with the task: “SonarCloudPrepare@1”
But it have a not intent effect that all our tests projects ignore errors and warnings from style cop.

So 1 developer can commit code to master branch and not see the error because he did not compile local
And then the next developer who try build master local have to fix it.

Is there a way to enable warnings and errors from style cop other than adding the property:

<SonarQubeTestProject>false</SonarQubeTestProject>

Hi @HenrikSommer-eng

Could you please give us a bit more details about your CI build?

  • the CI you use
  • your build script
  • if your organization and project are public, the organization key and project key

Thanks
Claire

Hi Claire.

We are using Azure devops pipeline yml.
To build dotnet core solutions.
Our projects are not public

I have add some of the yml steps I assume is relevant for this issue.

    - task: SonarCloudPrepare@1
      inputs:
         SonarCloud: 'SonarCloud'
         organization: '*********'
         scannerMode: 'MSBuild'
         projectKey: '[*projectKey*]'
         projectName: '[*projectName*]'

    - task: DotNetCoreCLI@2
      displayName: 'Build $(buildConfiguration)'
      inputs:
        command: build
        projects: $(solution)
        arguments: '--no-restore --configuration $(buildConfiguration)'


    - task: SonarCloudAnalyze@1
      condition: and(succeeded(), not(startsWith(variables['Build.SourceBranch'], 'refs/heads/features/')))

    - task: SonarCloudPublish@1
      condition: and(succeeded(), not(startsWith(variables['Build.SourceBranch'], 'refs/heads/features/')))
      inputs:
        pollingTimeoutSec: '300'

Hi @HenrikSommer-eng

We have an automatic detection of tests projects based on multiple criteria (You can find more details in our targets documentation just here)

Please note that the detection based on name will be removed in the next release, coming next week.

If you want to analyze your test project by our dotnet analyzer, then yes, the only way to do so would be to add the tag you mentionned.

HTH,
Mickaël

1 Like

But then SonarClould will also analyse the test project.
The problem is I dont want to run sonarclould rules on my test projects but I want to run my other (stylecop) dotnet analyzer on my test projects

Do you have a link to the release note?

Not yet.

Well i think it will give some problems for some :slight_smile: