aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorGodin <mandrikov@gmail.com>2010-11-26 14:32:21 +0000
committerGodin <mandrikov@gmail.com>2010-11-26 14:32:21 +0000
commit9aa8946e233c9f2fb46ed80f27a2d912516876ef (patch)
treee5551a9b81fdc03bf64afdfd0101a4fe4cb77330 /sonar-batch
parent9a062c018b178136cfef9b865fb157273d0e45d5 (diff)
downloadsonarqube-9aa8946e233c9f2fb46ed80f27a2d912516876ef.tar.gz
sonarqube-9aa8946e233c9f2fb46ed80f27a2d912516876ef.zip
SONAR-1405: The API must optionally allow plugins to add rule violations on lines with //NOSONAR tag
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/DefaultDecoratorContext.java10
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/DefaultSensorContext.java26
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java4
3 files changed, 22 insertions, 18 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/DefaultDecoratorContext.java b/sonar-batch/src/main/java/org/sonar/batch/DefaultDecoratorContext.java
index 55977a1c102..fe86e2c5414 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/DefaultDecoratorContext.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/DefaultDecoratorContext.java
@@ -154,12 +154,16 @@ public class DefaultDecoratorContext implements DecoratorContext {
public void deleteEvent(Event event) {
index.deleteEvent(event);
}
-
- public DefaultDecoratorContext saveViolation(Violation violation) {
+
+ public DefaultDecoratorContext saveViolation(Violation violation, boolean force) {
if (violation.getResource() == null) {
violation.setResource(resource);
}
- index.addViolation(violation);
+ index.addViolation(violation, force);
return this;
}
+
+ public DefaultDecoratorContext saveViolation(Violation violation) {
+ return saveViolation(violation, false);
+ }
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/DefaultSensorContext.java b/sonar-batch/src/main/java/org/sonar/batch/DefaultSensorContext.java
index f1f2921e570..24c70220e9d 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/DefaultSensorContext.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/DefaultSensorContext.java
@@ -19,6 +19,11 @@
*/
package org.sonar.batch;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
+
import org.sonar.api.batch.Event;
import org.sonar.api.batch.SensorContext;
import org.sonar.api.design.Dependency;
@@ -31,11 +36,6 @@ import org.sonar.api.resources.Resource;
import org.sonar.api.rules.Violation;
import org.sonar.batch.index.DefaultIndex;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-import java.util.Set;
-
public class DefaultSensorContext implements SensorContext {
private DefaultIndex index;
@@ -72,7 +72,7 @@ public class DefaultSensorContext implements SensorContext {
public String saveResource(Resource resource) {
Resource persistedResource = index.addResource(resource);
- if (persistedResource!=null) {
+ if (persistedResource != null) {
return persistedResource.getEffectiveKey();
}
return null;
@@ -94,15 +94,19 @@ public class DefaultSensorContext implements SensorContext {
return index.addMeasure(resourceOrProject(resource), measure);
}
- public void saveViolation(Violation violation) {
- if (violation.getResource()==null) {
+ public void saveViolation(Violation violation, boolean force) {
+ if (violation.getResource() == null) {
violation.setResource(resourceOrProject(violation.getResource()));
}
- index.addViolation(violation);
+ index.addViolation(violation, force);
+ }
+
+ public void saveViolation(Violation violation) {
+ saveViolation(violation, false);
}
public void saveViolations(Collection<Violation> violations) {
- if (violations!=null) {
+ if (violations != null) {
for (Violation violation : violations) {
saveViolation(violation);
}
@@ -150,6 +154,6 @@ public class DefaultSensorContext implements SensorContext {
}
private Resource resourceOrProject(Resource resource) {
- return (resource!=null ? resource : project);
+ return (resource != null ? resource : project);
}
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java
index bc333868624..927177d553e 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java
@@ -373,10 +373,6 @@ public final class DefaultIndex extends SonarIndex {
return bucket.getViolations();
}
- public void addViolation(Violation violation) {
- addViolation(violation, false);
- }
-
public void addViolation(Violation violation, boolean force) {
Bucket bucket;
Resource resource = violation.getResource();