Skip to content

Commit 0606222

Browse files
committed
Update configs to disable plugins
1 parent 9c6b81d commit 0606222

23 files changed

+73
-67
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ version, keep in mind that it might cause errors on SonarClojure analysis.
5454
### Configuring Sensors
5555

5656
#### Disabling
57-
Sensors can be disabled by setting `sonar.clojure.<sensorname>.disabled=true` in the sonar-project.properties or
58-
by using the command line argument `-Dsonar.clojure.<sensorname>.disabled` when running sonar-scanner.
57+
Sensors can be disabled by setting `sonar.clojure.<sensorname>.enabled=false` in the sonar-project.properties or
58+
by using the command line argument `-Dsonar.clojure.<sensorname>.enabled` when running sonar-scanner.
5959
Sensor names are `eastwood`, `kibit`, `clj-kondo`, `ancient`, `nvd` and `cloverage`.
6060

6161
#### Report file location

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>org.sonar.plugins.clojure</groupId>
88
<artifactId>sonar-clojure-plugin</artifactId>
9-
<version>2.1.0-SNAPSHOT</version>
9+
<version>2.2.0-SNAPSHOT</version>
1010
<packaging>sonar-plugin</packaging>
1111
<name>sonar-clojure</name>
1212
<description>SonarClojure is a plugin for SonarQube to analyze Clojure source.</description>

src/main/java/org/sonar/plugins/clojure/sensors/AbstractSensor.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ public AbstractSensor(LeiningenRunner leiningenRunner) {
2929
this.leiningenRunner = leiningenRunner;
3030
}
3131

32-
protected boolean isPluginDisabled(SensorContext context, String pluginName, String propertyName, boolean defaultValue) {
33-
Boolean pluginDisabled = context.config().getBoolean(propertyName).orElse(defaultValue);
34-
LOG.debug(String.format("Property: %s Value: %s", propertyName, pluginDisabled));
35-
if (pluginDisabled) {
32+
protected boolean isPluginEnabled(SensorContext context, String pluginName, String propertyName, boolean defaultValue) {
33+
Boolean pluginEnabled = context.config().getBoolean(propertyName).orElse(defaultValue);
34+
LOG.debug(String.format("Property: %s Value: %s", propertyName, pluginEnabled));
35+
if (!pluginEnabled) {
3636
LOG.info(pluginName + " disabled");
3737
}
38-
return pluginDisabled;
38+
return pluginEnabled;
3939
}
4040

4141
protected Optional<InputFile> getFile(String filePath, FileSystem fileSystem) {

src/main/java/org/sonar/plugins/clojure/sensors/ancient/AncientSensor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
import java.util.Optional;
2323

2424
import static org.sonar.plugins.clojure.sensors.ancient.AncientOutputParser.parse;
25-
import static org.sonar.plugins.clojure.settings.AncientProperties.DISABLED_PROPERTY;
26-
import static org.sonar.plugins.clojure.settings.AncientProperties.DISABLED_PROPERTY_DEFAULT;
25+
import static org.sonar.plugins.clojure.settings.AncientProperties.ENABLED_PROPERTY;
26+
import static org.sonar.plugins.clojure.settings.AncientProperties.ENABLED_PROPERTY_DEFAULT;
2727
import static org.sonar.plugins.clojure.settings.Properties.SENSORS_TIMEOUT_PROPERTY;
2828
import static org.sonar.plugins.clojure.settings.Properties.SENSORS_TIMEOUT_PROPERTY_DEFAULT;
2929

@@ -47,7 +47,7 @@ public void describe(SensorDescriptor descriptor) {
4747

4848
@Override
4949
public void execute(SensorContext context) {
50-
if (!isPluginDisabled(context, PLUGIN_NAME, DISABLED_PROPERTY, DISABLED_PROPERTY_DEFAULT)) {
50+
if (isPluginEnabled(context, PLUGIN_NAME, ENABLED_PROPERTY, ENABLED_PROPERTY_DEFAULT)) {
5151
LOG.info("Running Lein Ancient");
5252

5353
long timeOut = context.config().getLong(SENSORS_TIMEOUT_PROPERTY)

src/main/java/org/sonar/plugins/clojure/sensors/cloverage/CloverageSensor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public void describe(SensorDescriptor descriptor) {
3737

3838
@Override
3939
public void execute(SensorContext context) {
40-
if (!isPluginDisabled(context, PLUGIN_NAME, DISABLED_PROPERTY, DISABLED_PROPERTY_DEFAULT)) {
40+
if (isPluginEnabled(context, PLUGIN_NAME, ENABLED_PROPERTY, ENABLED_PROPERTY_DEFAULT)) {
4141
LOG.info("Running " + PLUGIN_NAME);
4242

4343
long timeOut = context.config().getLong(SENSORS_TIMEOUT_PROPERTY)

src/main/java/org/sonar/plugins/clojure/sensors/eastwood/EastwoodSensor.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public void execute(SensorContext context) {
4747

4848
LOG.debug("Saving issues: " + issues.size());
4949
issues.forEach(issue -> saveIssue(issue, context));
50+
} else {
51+
LOG.info("Eastwood disabled");
5052
}
5153
}
5254
private boolean isSensorEnabled(SensorContext context) {

src/main/java/org/sonar/plugins/clojure/sensors/kibit/KibitSensor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void describe(SensorDescriptor descriptor) {
3838

3939
@Override
4040
public void execute(SensorContext context) {
41-
if (!isPluginDisabled(context, PLUGIN_NAME, KibitProperties.DISABLED_PROPERTY, KibitProperties.DISABLED_PROPERTY_DEFAULT)) {
41+
if (isPluginEnabled(context, PLUGIN_NAME, KibitProperties.ENABLED_PROPERTY, KibitProperties.ENABLED_PROPERTY_DEFAULT)) {
4242
LOG.info("Running Kibit");
4343
long timeOut = context.config().getLong(SENSORS_TIMEOUT_PROPERTY)
4444
.orElse(Long.valueOf(SENSORS_TIMEOUT_PROPERTY_DEFAULT));

src/main/java/org/sonar/plugins/clojure/sensors/kondo/KondoSensor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ private Severity getSeverity(String level) {
8686

8787
@Override
8888
public void execute(SensorContext context) {
89-
if (!isPluginDisabled(context, PLUGIN_NAME, DISABLED_PROPERTY, DISABLED_PROPERTY_DEFAULT)) {
89+
if (isPluginEnabled(context, PLUGIN_NAME, ENABLED_PROPERTY, ENABLED_PROPERTY_DEFAULT)) {
9090
LOG.info("Running clj-kondo");
9191

9292
String config = context.config().get(CONFIG).orElse(DEFAULT_CONFIG);

src/main/java/org/sonar/plugins/clojure/sensors/leinnvd/LeinNvdSensor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public void describe(SensorDescriptor descriptor) {
4343
@Override
4444
public void execute(SensorContext context) {
4545

46-
if (!isPluginDisabled(context, PLUGIN_NAME, DISABLED_PROPERTY, DISABLED_PROPERTY_DEFAULT)) {
46+
if (isPluginEnabled(context, PLUGIN_NAME, ENABLED_PROPERTY, ENABLED_PROPERTY_DEFAULT)) {
4747
LOG.info("Running Lein NVD");
4848
String reportPath = context.config().get(NvdProperties.REPORT_LOCATION_PROPERTY).orElse(REPORT_LOCATION_DEFAULT);
4949

src/main/java/org/sonar/plugins/clojure/settings/AncientProperties.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010
import static org.sonar.plugins.clojure.settings.Properties.SUB_CATEGORY;
1111

1212
public class AncientProperties {
13-
public static final String DISABLED_PROPERTY = "sonar.clojure.ancient.disabled";
14-
public static final boolean DISABLED_PROPERTY_DEFAULT = false;
13+
public static final String ENABLED_PROPERTY = "sonar.clojure.ancient.enabled";
14+
public static final boolean ENABLED_PROPERTY_DEFAULT = true;
1515

1616
private AncientProperties() {
1717
}
1818

1919
static PropertyDefinition getAncientDisabled() {
20-
return PropertyDefinition.builder(DISABLED_PROPERTY)
20+
return PropertyDefinition.builder(ENABLED_PROPERTY)
2121
.category(MAIN_CATEGORY)
2222
.subCategory(SUB_CATEGORY)
23-
.defaultValue(valueOf(DISABLED_PROPERTY_DEFAULT))
23+
.defaultValue(valueOf(ENABLED_PROPERTY_DEFAULT))
2424
.name("Ancient Disabled")
2525
.description("Indicates the ancient sensor should be disabled")
2626
.build();

0 commit comments

Comments
 (0)