summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2017-12-05 18:04:06 +0100
committerSimon Brandhof <simon.brandhof@sonarsource.com>2018-01-10 06:48:47 +0100
commitbaccb26f1aecd27b7d7fc06a185e7fdeaf03ea83 (patch)
treef5e3cb8af2a4d355c415a0f8c7b2d459b4d0ccec /plugins
parent01c3e23df232c1006344f4957bf35af92b17a985 (diff)
downloadsonarqube-baccb26f1aecd27b7d7fc06a185e7fdeaf03ea83.tar.gz
sonarqube-baccb26f1aecd27b7d7fc06a185e7fdeaf03ea83.zip
SONAR-10117 SONAR-1018 Update measures after relevant issue changes and send webhooks
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneBugIssuePerLineSensor.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneBugIssuePerLineSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneBugIssuePerLineSensor.java
index fffd48a4de3..59574256742 100644
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneBugIssuePerLineSensor.java
+++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneBugIssuePerLineSensor.java
@@ -23,6 +23,7 @@ import org.sonar.api.batch.fs.FilePredicates;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.InputFile.Type;
+import org.sonar.api.batch.fs.TextRange;
import org.sonar.api.batch.sensor.Sensor;
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.batch.sensor.SensorDescriptor;
@@ -56,15 +57,20 @@ public class OneBugIssuePerLineSensor implements Sensor {
}
}
- private void createIssues(InputFile file, SensorContext context, String repo) {
+ private static void createIssues(InputFile file, SensorContext context, String repo) {
RuleKey ruleKey = RuleKey.of(repo, RULE_KEY);
for (int line = 1; line <= file.lines(); line++) {
+ TextRange text = file.selectLine(line);
+ // do not count empty lines, which can be a pain with end-of-file return
+ if (text.end().lineOffset() == 0) {
+ continue;
+ }
NewIssue newIssue = context.newIssue();
newIssue
.forRule(ruleKey)
.at(newIssue.newLocation()
.on(file)
- .at(file.selectLine(line))
+ .at(text)
.message("This bug issue is generated on each line"))
.save();
}