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.
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.
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/**
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With