0

I'm new to Sonarqube. I've just started to run sonarscanner on a .Net Core C# application. The scan runs ok and the analysis is being shown on our corporate sonarqube site.

The solution has a UI project which contains javascript. I want to exclude those javascript files from the analysis

I've not been able to get that exclusion to work.

Can anyone suggest what i'm doing wrong?

I've added an exclusion to the begin statement (below) and since that didn't work, also added SonarQube.Analysis.xml to the root of the folder structure (below).

begin statement

dotnet "PathToSonarscanner\sonarscanner.msbuild.dll" begin /k:"projectkeygoeshere" /d:sonar.verbose=true /d:sonar.host.url="urlgoeshere" /d:sonar.login="loginkeygoeshere"  /d:sonar.coverage.exclusions="**/*.js"

SonarQube.Analysis.xml

<?xml version="1.0" encoding="utf-8" ?>
<SonarQubeAnalysisProperties
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns="http://www.sonarsource.com/msbuild/integration/2015/1">
  <Property Name="sonar.verbose">true</Property>
  <Property Name="sonar.host.url">urlgoeshere</Property>
  <Property Name="sonar.login">loginkeygoeshere</Property>
  <Property Name="sonar.projectKey">projectkeygoeshere</Property>
  <Property Name="sonar.sources">.</Property>
  <Property Name="sonar.coverage.exclusions">**/*.js</Property>
</SonarQubeAnalysisProperties>

1 Answers1

0

sonar.exclusions - Comma-delimited list of file path patterns to be excluded from analysis

sonar.coverage.exclusions - Comma-delimited list of file path patterns to be excluded from coverage calculations

So, according to your question, you wanted to exclude the files from analysis. So you need to include sonar.exclusions in your sonarqube.analysis.xml

<Property Name="sonar.exclusions">**/*.js</Property>

Note: The regex pattern should be correct in order to match the files. You can refer here for more patterns to exclude the files.

Sourav
  • 3,025
  • 2
  • 13
  • 29