aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2020-03-19 12:41:40 +0100
committersonartech <sonartech@sonarsource.com>2020-03-23 20:03:41 +0000
commita5e56c8d403ba0bfdb36e94acb8def5ceb065524 (patch)
tree184bce441b640428b2bc3f1bb6e176e9f8a2d6cd /plugins
parent0c8d18b4ed3e08536eef559153c62fb80cffa253 (diff)
downloadsonarqube-a5e56c8d403ba0bfdb36e94acb8def5ceb065524.tar.gz
sonarqube-a5e56c8d403ba0bfdb36e94acb8def5ceb065524.zip
SONAR-13214 Remove org.sonar.api.config.Settings from the API
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/Xoo.java11
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java1
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/extensions/XooProjectBuilder.java9
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/ChecksSensor.java2
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/CreateIssueByInternalKeySensor.java2
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/HasTagSensor.java2
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneIssuePerLineSensor.java6
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/RandomAccessSensor.java2
8 files changed, 14 insertions, 21 deletions
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/Xoo.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/Xoo.java
index 077eed2a593..ad450e34e74 100644
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/Xoo.java
+++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/Xoo.java
@@ -19,8 +19,7 @@
*/
package org.sonar.xoo;
-import java.util.Arrays;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
import org.sonar.api.resources.Language;
public class Xoo implements Language {
@@ -30,10 +29,10 @@ public class Xoo implements Language {
public static final String FILE_SUFFIXES_KEY = "sonar.xoo.file.suffixes";
public static final String DEFAULT_FILE_SUFFIXES = ".xoo";
- private final Settings settings;
+ private final Configuration config;
- public Xoo(Settings settings) {
- this.settings = settings;
+ public Xoo(Configuration config) {
+ this.config = config;
}
@Override
@@ -48,6 +47,6 @@ public class Xoo implements Language {
@Override
public String[] getFileSuffixes() {
- return Arrays.stream(settings.getStringArray(FILE_SUFFIXES_KEY)).filter(s -> s != null && !s.trim().isEmpty()).toArray(String[]::new);
+ return config.getStringArray(FILE_SUFFIXES_KEY);
}
}
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java
index bbc9c6cdb46..cb3bc1d7a36 100644
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java
+++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java
@@ -93,6 +93,7 @@ public class XooPlugin implements Plugin {
.description("Comma-separated list of suffixes for files to analyze. To not filter, leave the list empty.")
.subCategory("General")
.onQualifiers(Qualifiers.PROJECT)
+ .multiValues(true)
.build(),
// Used by DuplicationsTest and IssueFilterOnCommonRulesTest. If not declared it is not returned by api/settings
PropertyDefinition.builder("sonar.cpd.xoo.minimumTokens")
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/extensions/XooProjectBuilder.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/extensions/XooProjectBuilder.java
index f72b138f24f..5b6693ddad7 100644
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/extensions/XooProjectBuilder.java
+++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/extensions/XooProjectBuilder.java
@@ -22,19 +22,12 @@ package org.sonar.xoo.extensions;
import java.io.File;
import org.sonar.api.batch.bootstrap.ProjectBuilder;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
-import org.sonar.api.config.Settings;
public class XooProjectBuilder extends ProjectBuilder {
- private Settings settings;
-
- public XooProjectBuilder(Settings settings) {
- this.settings = settings;
- }
-
@Override
public void build(Context context) {
- if (!settings.getBoolean("sonar.xoo.enableProjectBuilder")) {
+ if (!context.config().getBoolean("sonar.xoo.enableProjectBuilder").orElse(false)) {
return;
}
ProjectDefinition root = context.projectReactor().getRoot();
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/ChecksSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/ChecksSensor.java
index f8e5445fc54..c759817d6a3 100644
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/ChecksSensor.java
+++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/ChecksSensor.java
@@ -50,7 +50,7 @@ public class ChecksSensor implements Sensor {
@Override
public void execute(SensorContext context) {
Checks<Check> checks = checkFactory.create(XooRulesDefinition.XOO_REPOSITORY);
- checks.addAnnotatedChecks(Check.ALL);
+ checks.addAnnotatedChecks((Object[]) Check.ALL);
FilePredicates p = context.fileSystem().predicates();
for (InputFile file : context.fileSystem().inputFiles(p.and(p.hasLanguages(Xoo.KEY), p.hasType(Type.MAIN)))) {
for (Check check : checks.all()) {
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/CreateIssueByInternalKeySensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/CreateIssueByInternalKeySensor.java
index e9caaef473a..a0870005056 100644
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/CreateIssueByInternalKeySensor.java
+++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/CreateIssueByInternalKeySensor.java
@@ -53,7 +53,7 @@ public class CreateIssueByInternalKeySensor implements Sensor {
private static void createIssues(InputFile file, SensorContext context) {
ActiveRule rule = context.activeRules().findByInternalKey(XooRulesDefinition.XOO_REPOSITORY,
- context.settings().getString(INTERNAL_KEY_PROPERTY));
+ context.config().get(INTERNAL_KEY_PROPERTY).orElse(null));
if (rule != null) {
NewIssue newIssue = context.newIssue();
newIssue
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/HasTagSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/HasTagSensor.java
index ac0b6ef1779..cd31cc5ea22 100644
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/HasTagSensor.java
+++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/HasTagSensor.java
@@ -67,7 +67,7 @@ public class HasTagSensor extends AbstractXooRuleSensor {
NewIssue newIssue = context.newIssue();
newIssue
.forRule(ruleKey)
- .gap(context.settings().getDouble(EFFORT_TO_FIX_PROPERTY))
+ .gap(context.config().getDouble(EFFORT_TO_FIX_PROPERTY).orElse(null))
.at(newIssue.newLocation()
.on(inputFile)
.at(inputFile.newRange(lineCounter[0], startIndex, lineCounter[0], startIndex + tag.length())))
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneIssuePerLineSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneIssuePerLineSensor.java
index 03a5d0bdc91..2b7e51b27ce 100644
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneIssuePerLineSensor.java
+++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneIssuePerLineSensor.java
@@ -63,7 +63,7 @@ public class OneIssuePerLineSensor implements Sensor {
private void createIssues(InputFile file, SensorContext context, String repo) {
RuleKey ruleKey = RuleKey.of(repo, RULE_KEY);
- String severity = context.settings().getString(FORCE_SEVERITY_PROPERTY);
+ String severity = context.config().get(FORCE_SEVERITY_PROPERTY).orElse(null);
for (int line = 1; line <= file.lines(); line++) {
NewIssue newIssue = context.newIssue();
newIssue
@@ -74,9 +74,9 @@ public class OneIssuePerLineSensor implements Sensor {
.message("This issue is generated on each line"))
.overrideSeverity(severity != null ? Severity.valueOf(severity) : null);
if (context.getSonarQubeVersion().isGreaterThanOrEqual(Version.create(5, 5))) {
- newIssue.gap(context.settings().getDouble(EFFORT_TO_FIX_PROPERTY));
+ newIssue.gap(context.config().getDouble(EFFORT_TO_FIX_PROPERTY).orElse(null));
} else {
- newIssue.gap(context.settings().getDouble(EFFORT_TO_FIX_PROPERTY));
+ newIssue.gap(context.config().getDouble(EFFORT_TO_FIX_PROPERTY).orElse(null));
}
newIssue.save();
}
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/RandomAccessSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/RandomAccessSensor.java
index 0a765fe411b..6ee907aa9e0 100644
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/RandomAccessSensor.java
+++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/RandomAccessSensor.java
@@ -49,7 +49,7 @@ public class RandomAccessSensor implements Sensor {
@Override
public void execute(SensorContext context) {
- File f = new File(context.settings().getString(SONAR_XOO_RANDOM_ACCESS_ISSUE_PATHS));
+ File f = new File(context.config().get(SONAR_XOO_RANDOM_ACCESS_ISSUE_PATHS).orElseThrow(() -> new IllegalStateException("Required property")));
FileSystem fs = context.fileSystem();
FilePredicates p = fs.predicates();
try {