diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2011-01-24 19:06:38 +0100 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2011-01-24 19:25:01 +0100 |
commit | 878cec92f8e39fd46628a83bba970293129de710 (patch) | |
tree | 8234845025634f6e8d589fc1ef5df79f4bb4fe12 /sonar-plugin-api | |
parent | eb9462d6002daf7f01f8fe627b4517c065bdb5af (diff) | |
download | sonarqube-878cec92f8e39fd46628a83bba970293129de710.tar.gz sonarqube-878cec92f8e39fd46628a83bba970293129de710.zip |
SONAR-791 When the source directory is not exactly the java package root, Sonar should stop the analysis
Diffstat (limited to 'sonar-plugin-api')
3 files changed, 19 insertions, 8 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractSourceImporter.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractSourceImporter.java index b11a96f5655..0c796b83ec0 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractSourceImporter.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractSourceImporter.java @@ -21,10 +21,7 @@ package org.sonar.api.batch; import org.apache.commons.io.FileUtils; import org.sonar.api.CoreProperties; -import org.sonar.api.resources.Language; -import org.sonar.api.resources.Project; -import org.sonar.api.resources.ProjectFileSystem; -import org.sonar.api.resources.Resource; +import org.sonar.api.resources.*; import org.sonar.api.utils.SonarException; import java.io.File; @@ -34,7 +31,7 @@ import java.util.List; /** * A pre-implementation for a sensor that imports sources - * + * * @since 1.10 */ @Phase(name = Phase.Name.PRE) @@ -103,7 +100,7 @@ public abstract class AbstractSourceImporter implements Sensor { if (resource != null) { resource.setLanguage(language); if (unitTest) { - resource.setQualifier(Resource.QUALIFIER_UNIT_TEST_CLASS); + resource.setQualifier(Qualifiers.UNIT_TEST_FILE); } } return resource; 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 8811492b955..06ae5ae80fd 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 @@ -124,6 +124,12 @@ public abstract class SonarIndex implements DirectedGraphAccessor<Resource, Depe addViolation(violation, false); } + /** + * 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); public abstract Dependency addDependency(Dependency dependency); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeasuresFilters.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeasuresFilters.java index 434fe55e23c..2b74a78a500 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeasuresFilters.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeasuresFilters.java @@ -45,7 +45,11 @@ public final class MeasuresFilters { } public static MeasuresFilter<Measure> metric(final Metric metric) { - return new MetricFilter<Measure>(metric) { + return metric(metric.getKey()); + } + + public static MeasuresFilter<Measure> metric(final String metricKey) { + return new MetricFilter<Measure>(metricKey) { public Measure filter(Collection<Measure> measures) { if (measures == null) { @@ -53,7 +57,7 @@ public final class MeasuresFilters { } for (Measure measure : measures) { if (measure.getClass().equals(Measure.class) && - measure.getMetricKey().equals(metric.getKey()) && + measure.getMetricKey().equals(metricKey) && measure.getCharacteristic()==null) { return measure; } @@ -165,6 +169,10 @@ public final class MeasuresFilters { this.metricKey = metric.getKey(); } + protected MetricFilter(String metricKey) { + this.metricKey = metricKey; + } + public String filterOnMetricKey() { return metricKey; } |