aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2011-06-17 18:01:48 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2011-06-17 18:01:57 +0200
commit9a7fb4969d31cf0b5f5c3dbafcc19d39b9d86016 (patch)
tree226688fc6a941bdc1e86290446ce016f40f7f3bb /sonar-plugin-api
parentc973498cfec4ff8e59ac33e9c9fb150a71ef828a (diff)
downloadsonarqube-9a7fb4969d31cf0b5f5c3dbafcc19d39b9d86016.tar.gz
sonarqube-9a7fb4969d31cf0b5f5c3dbafcc19d39b9d86016.zip
SONAR-2505 support tracking of violations on dry runs
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java9
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/rules/Violation.java26
2 files changed, 17 insertions, 18 deletions
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 4c82198ffdd..1e17e75dad1 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
@@ -99,6 +99,11 @@ public abstract class SonarIndex implements DirectedGraphAccessor<Resource, Depe
*/
public abstract void setSource(Resource reference, String source) throws DuplicatedSourceException;
+ /**
+ * @since 2.9
+ */
+ public abstract String getSource(Resource resource);
+
public abstract Project getProject();
public final Collection<Resource> getResources() {
@@ -133,8 +138,6 @@ public abstract class SonarIndex implements DirectedGraphAccessor<Resource, Depe
* as a parameter.
*
* @since 2.7
- * @param the
- * resource on which violations are searched
* @return the list of violations
*/
public final List<Violation> getViolations(Resource resource) {
@@ -153,8 +156,6 @@ public abstract class SonarIndex implements DirectedGraphAccessor<Resource, Depe
/**
* Warning: the resource is automatically indexed for backward-compatibility, but it should be explictly
* indexed before. Next versions will deactivate this automatic indexation.
- *
- * @throws SonarException if the metric is unknown.
*/
public abstract Measure addMeasure(Resource resource, Measure measure);
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rules/Violation.java b/sonar-plugin-api/src/main/java/org/sonar/api/rules/Violation.java
index fc7ec235484..efab4077464 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/rules/Violation.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/rules/Violation.java
@@ -40,6 +40,7 @@ public class Violation {
private Double cost;
private Date createdAt;
private boolean switchedOff=false;
+ private String checksum;
/**
* Creates of a violation from a rule. Will need to define the resource later on
@@ -238,27 +239,24 @@ public class Violation {
* Tells whether this violation is ON or OFF.
*
* @since 2.8
- * @return true if the violation has been switched off
*/
public boolean isSwitchedOff() {
return switchedOff;
}
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof Violation)) {
- return false;
- }
- if (this == obj) {
- return true;
- }
- Violation other = (Violation) obj;
- return new EqualsBuilder().append(rule, other.getRule()).append(resource, other.getResource()).isEquals();
+ /**
+ * Checksum is available in decorators executed after the barrier {@link org.sonar.api.batch.DecoratorBarriers#END_OF_VIOLATION_TRACKING}
+ */
+ public String getChecksum() {
+ return checksum;
}
- @Override
- public int hashCode() {
- return new HashCodeBuilder(17, 37).append(getRule()).append(getResource()).toHashCode();
+ /**
+ * For internal use only. Checksum is automatically set by Sonar. Plugins must not call this method.
+ */
+ public Violation setChecksum(String s) {
+ this.checksum = s;
+ return this;
}
@Override