admin管理员组

文章数量:1291175

When I open a PR on GitHub, SonarQube Cloud checks the source code and reports any problems. I also have the IntelliJ plugin "SonarQube for IDE" installed. By connecting the IDE plugin to SonarQube Cloud, the same rules are used in my IDE and on GitHub.

I want to exclude all the files in src/main/java/db/schema from SonarQube analysis in both cases (in the IDE and on GitHub).

I've added a .sonarcloud.properties file to my project root with the following property:

sonar.exclusions=src/main/java/db/schema/*

But when I manually trigger the SonarQube analysis in the IDE, violations in these files are reported.

When I open a PR on GitHub, SonarQube Cloud checks the source code and reports any problems. I also have the IntelliJ plugin "SonarQube for IDE" installed. By connecting the IDE plugin to SonarQube Cloud, the same rules are used in my IDE and on GitHub.

I want to exclude all the files in src/main/java/db/schema from SonarQube analysis in both cases (in the IDE and on GitHub).

I've added a .sonarcloud.properties file to my project root with the following property:

sonar.exclusions=src/main/java/db/schema/*

But when I manually trigger the SonarQube analysis in the IDE, violations in these files are reported.

Share Improve this question asked Feb 13 at 16:02 DónalDónal 187k177 gold badges584 silver badges844 bronze badges 4
  • Were you able to bind your project to SonarQube Cloud project ? – vht981230 Commented Feb 18 at 5:14
  • 1 @vht981230 yes, it's in connected mode – Dónal Commented Feb 18 at 13:17
  • Hi, when a project is connected to SonarQube or SonarCloud, exclusions defined in the server General Settings override your locally defined exclusions. – SeiryuV Commented Feb 20 at 11:54
  • Docs -docs.sonarsource/sonarqube-cloud/administering-sonarcloud/… – Jeevan ebi Commented Feb 21 at 8:35
Add a comment  | 

1 Answer 1

Reset to default 1

As per the documentation

When running in Connected mode with SonarQube (Server, Cloud) or SonarQube Community Build, SonarQube for IDE will ignore local exclusions and fetch file exclusions from the SonarQube (Server, Cloud) server.

This points that the way to configure exclusions is different whether you are running in Connected mode or not.


Connected mode

When in Connected mode, go to the SonarCloud > Project Settings > General Settings > Analysis Scope then search for the Exclusions section and add this pattern

src/main/java/db/schema/**

Local mode

When not in Connected mode, IntelliJ doesn't read exclusions in .sonarcloud.properties (as per the documentation). Instead, you'll want to create a sonar-project.properties file add inside of it the exclusion

sonar.exclusions=src/main/java/db/schema/**

Note: you can read about other approaches in the answers to this very similar question, as well as this one.

本文标签: Exclude directory from SonarQube analysisStack Overflow