aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2015-08-05 10:34:26 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2015-08-05 13:52:59 +0200
commite2daa5befa8916b585567a942141edcb7eff9a19 (patch)
tree379a210d60f42922461a33e065f112ba710655d9 /plugins
parent92ab7df5f6d58a9711cdc00dbaafd0648b22e940 (diff)
downloadsonarqube-e2daa5befa8916b585567a942141edcb7eff9a19.tar.gz
sonarqube-e2daa5befa8916b585567a942141edcb7eff9a19.zip
Fix some quality flaws
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/SymbolReferencesSensor.java11
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/SyntaxHighlightingSensor.java11
-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/MultilineIssuesSensor.java41
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneIssueOnDirPerFileSensor.java2
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/RandomAccessSensor.java2
6 files changed, 39 insertions, 30 deletions
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/SymbolReferencesSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/SymbolReferencesSensor.java
index e69aa54c210..66573470ddb 100644
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/SymbolReferencesSensor.java
+++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/SymbolReferencesSensor.java
@@ -20,6 +20,10 @@
package org.sonar.xoo.lang;
import com.google.common.base.Splitter;
+import java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.sonar.api.batch.fs.InputFile;
@@ -33,11 +37,6 @@ import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
import org.sonar.xoo.Xoo;
-import java.io.File;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.List;
-
/**
* Parse files *.xoo.symbol
*/
@@ -79,7 +78,7 @@ public class SymbolReferencesSensor implements Sensor {
}
}
- private void processLine(File symbolFile, int lineNumber, Symbolizable.SymbolTableBuilder symbolTableBuilder, String line) {
+ private static void processLine(File symbolFile, int lineNumber, Symbolizable.SymbolTableBuilder symbolTableBuilder, String line) {
try {
Iterator<String> split = Splitter.on(",").split(line).iterator();
int startOffset = Integer.parseInt(split.next());
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/SyntaxHighlightingSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/SyntaxHighlightingSensor.java
index bd273dec4ff..a059d8b26be 100644
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/SyntaxHighlightingSensor.java
+++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/SyntaxHighlightingSensor.java
@@ -20,6 +20,10 @@
package org.sonar.xoo.lang;
import com.google.common.base.Splitter;
+import java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.sonar.api.batch.fs.InputFile;
@@ -32,11 +36,6 @@ import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
import org.sonar.xoo.Xoo;
-import java.io.File;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.List;
-
/**
* Parse files *.xoo.highlighting
*/
@@ -69,7 +68,7 @@ public class SyntaxHighlightingSensor implements Sensor {
}
}
- private void processLine(File highlightingFile, int lineNumber, NewHighlighting highlightingBuilder, String line) {
+ private static void processLine(File highlightingFile, int lineNumber, NewHighlighting highlightingBuilder, String line) {
try {
Iterator<String> split = Splitter.on(":").split(line).iterator();
int startOffset = Integer.parseInt(split.next());
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 e92e5c12564..cbff8a7e1f6 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
@@ -51,7 +51,7 @@ public class CreateIssueByInternalKeySensor implements Sensor {
}
}
- private void createIssues(InputFile file, SensorContext context) {
+ private static void createIssues(InputFile file, SensorContext context) {
ActiveRule rule = context.activeRules().findByInternalKey(XooRulesDefinition.XOO_REPOSITORY,
context.settings().getString(INTERNAL_KEY_PROPERTY));
if (rule != null) {
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/MultilineIssuesSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/MultilineIssuesSensor.java
index 57dbc84464b..81891faf809 100644
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/MultilineIssuesSensor.java
+++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/MultilineIssuesSensor.java
@@ -61,13 +61,38 @@ public class MultilineIssuesSensor implements Sensor {
}
}
- private void createIssues(InputFile file, SensorContext context) {
+ private static void createIssues(InputFile file, SensorContext context) {
Pattern startPattern = Pattern.compile(START_ISSUE_PATTERN);
Pattern endPattern = Pattern.compile(END_ISSUE_PATTERN);
Map<Integer, Map<Integer, TextPointer>> startPositions = new HashMap<>();
Map<Integer, Map<Integer, TextPointer>> endPositions = new HashMap<>();
RuleKey ruleKey = RuleKey.of(XooRulesDefinition.XOO_REPOSITORY, RULE_KEY);
+ parse(file, context, startPattern, endPattern, startPositions, endPositions);
+ createIssues(file, context, startPositions, endPositions, ruleKey);
+ }
+
+ private static void createIssues(InputFile file, SensorContext context, Map<Integer, Map<Integer, TextPointer>> startPositions,
+ Map<Integer, Map<Integer, TextPointer>> endPositions,
+ RuleKey ruleKey) {
+ for (Map.Entry<Integer, Map<Integer, TextPointer>> entry : startPositions.entrySet()) {
+ NewIssue newIssue = context.newIssue().forRule(ruleKey);
+ for (Map.Entry<Integer, TextPointer> location : entry.getValue().entrySet()) {
+ NewIssueLocation newLocation = newIssue.newLocation()
+ .on(file)
+ .at(file.newRange(location.getValue(), endPositions.get(entry.getKey()).get(location.getKey())));
+ if (location.getKey() == 1) {
+ newIssue.at(newLocation.message("Primary location"));
+ } else {
+ newIssue.addLocation(newLocation.message("Location #" + location.getKey()));
+ }
+ }
+ newIssue.save();
+ }
+ }
+
+ private static void parse(InputFile file, SensorContext context, Pattern startPattern, Pattern endPattern, Map<Integer, Map<Integer, TextPointer>> startPositions,
+ Map<Integer, Map<Integer, TextPointer>> endPositions) {
int currentLine = 0;
try {
for (String lineStr : Files.readAllLines(file.path(), context.fileSystem().encoding())) {
@@ -98,20 +123,6 @@ public class MultilineIssuesSensor implements Sensor {
} catch (IOException e) {
throw new IllegalStateException("Unable to read file", e);
}
- for (Map.Entry<Integer, Map<Integer, TextPointer>> entry : startPositions.entrySet()) {
- NewIssue newIssue = context.newIssue().forRule(ruleKey);
- for (Map.Entry<Integer, TextPointer> location : entry.getValue().entrySet()) {
- NewIssueLocation newLocation = newIssue.newLocation()
- .on(file)
- .at(file.newRange(location.getValue(), endPositions.get(entry.getKey()).get(location.getKey())));
- if (location.getKey() == 1) {
- newIssue.at(newLocation.message("Primary location"));
- } else {
- newIssue.addLocation(newLocation.message("Location #" + location.getKey()));
- }
- }
- newIssue.save();
- }
}
}
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneIssueOnDirPerFileSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneIssueOnDirPerFileSensor.java
index b2d047a9994..e3a7b30d3d2 100644
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneIssueOnDirPerFileSensor.java
+++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneIssueOnDirPerFileSensor.java
@@ -47,7 +47,7 @@ public class OneIssueOnDirPerFileSensor implements Sensor {
}
}
- private void createIssues(InputFile file, SensorContext context) {
+ private static void createIssues(InputFile file, SensorContext context) {
RuleKey ruleKey = RuleKey.of(XooRulesDefinition.XOO_REPOSITORY, RULE_KEY);
InputDir inputDir = context.fileSystem().inputDir(file.file().getParentFile());
if (inputDir != null) {
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 bc7b90a69ae..94cc2144387 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
@@ -61,7 +61,7 @@ public class RandomAccessSensor implements Sensor {
}
}
- private void createIssues(InputFile file, SensorContext context) {
+ private static void createIssues(InputFile file, SensorContext context) {
RuleKey ruleKey = RuleKey.of(XooRulesDefinition.XOO_REPOSITORY, RULE_KEY);
NewIssue newIssue = context.newIssue();
newIssue