aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
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-plugin-api
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-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorContext.java7
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java10
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java19
3 files changed, 29 insertions, 7 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorContext.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorContext.java
index 8d3d14f2837..837cb557978 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorContext.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorContext.java
@@ -108,6 +108,13 @@ public interface DecoratorContext {
*/
List<Violation> getViolations();
+ /**
+ * Save a coding rule violation. The decorator which calls this method must be depended upon BatchBarriers.END_OF_VIOLATIONS_GENERATION.
+ *
+ * @since 2.5
+ * @param force allows to force creation of violation even if it was supressed by {@link org.sonar.api.rules.ViolationFilter}
+ */
+ DecoratorContext saveViolation(Violation violation, boolean force);
/**
* Save a coding rule violation. The decorator which calls this method must be depended upon BatchBarriers.END_OF_VIOLATIONS_GENERATION.
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java
index 0c6e13c6d81..e1082ecdf3e 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java
@@ -103,11 +103,19 @@ public interface SensorContext {
/**
* Save a coding rule violation.
+ *
+ * @since 2.5
+ * @param force allows to force creation of violation even if it was supressed by {@link org.sonar.api.rules.ViolationFilter}
+ */
+ void saveViolation(Violation violation, boolean force);
+
+ /**
+ * Save a coding rule violation.
*/
void saveViolation(Violation violation);
/**
- * Saves a list of violations
+ * Saves a list of violations.
*/
void saveViolations(Collection<Violation> violations);
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java
index 1fdddb46bc7..de6d6e1f670 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java
@@ -19,6 +19,11 @@
*/
package org.sonar.api.batch;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
+
import org.sonar.api.design.Dependency;
import org.sonar.api.measures.Measure;
import org.sonar.api.measures.MeasuresFilter;
@@ -29,11 +34,6 @@ import org.sonar.api.resources.Resource;
import org.sonar.api.rules.Violation;
import org.sonar.graph.DirectedGraphAccessor;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-import java.util.Set;
-
public abstract class SonarIndex implements DirectedGraphAccessor<Resource, Dependency> {
public abstract Project getProject();
@@ -54,7 +54,14 @@ public abstract class SonarIndex implements DirectedGraphAccessor<Resource, Depe
public abstract void setSource(Resource resource, String source);
- public abstract void addViolation(Violation violation);
+ /**
+ * @since 2.5
+ */
+ public abstract void addViolation(Violation violation, boolean force);
+
+ public final void addViolation(Violation violation) {
+ addViolation(violation, false);
+ }
public abstract Measure addMeasure(Resource resource, Measure measure);