aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2014-01-17 16:27:10 +0100
committerJulien HENRY <julien.henry@sonarsource.com>2014-01-17 16:27:10 +0100
commit347e09b4ff016135db4f6d45a541f6f1331f5089 (patch)
tree813cc5732e924c3648dcbeb6903d3f62bfbd8c63 /sonar-plugin-api
parentef0065bcf1ccffc3a488534fe91c8770e5d21264 (diff)
downloadsonarqube-347e09b4ff016135db4f6d45a541f6f1331f5089.tar.gz
sonarqube-347e09b4ff016135db4f6d45a541f6f1331f5089.zip
SONAR-926 Deprecate CLA qualifier. JavaFile are now FILE.
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/resources/JavaFile.java4
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/resources/Qualifiers.java20
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceUtils.java4
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/utils/CoberturaReportParserUtilsTest.java70
4 files changed, 59 insertions, 39 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/JavaFile.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/JavaFile.java
index 92c01f93d80..d8346fa13c4 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/JavaFile.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/JavaFile.java
@@ -171,11 +171,11 @@ public class JavaFile extends Resource {
}
/**
- * @return QUALIFIER_UNIT_TEST_CLASS or QUALIFIER_CLASS depending whether it is a unit test class
+ * @return QUALIFIER_UNIT_TEST_CLASS or QUALIFIER_FILE depending whether it is a unit test class
*/
@Override
public String getQualifier() {
- return unitTest ? Qualifiers.UNIT_TEST_FILE : Qualifiers.CLASS;
+ return unitTest ? Qualifiers.UNIT_TEST_FILE : Qualifiers.FILE;
}
/**
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/Qualifiers.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/Qualifiers.java
index af59617bc51..dfbb1eb1b0a 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/Qualifiers.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/Qualifiers.java
@@ -68,9 +68,25 @@ public final class Qualifiers {
public static final String PACKAGE = "PAC";
public static final String DIRECTORY = "DIR";
public static final String FILE = "FIL";
+ /**
+ * @deprecated since 4.2 now java files are considered as regular files. Use {@link #FILE} instead.
+ */
+ @Deprecated
public static final String CLASS = "CLA";
+ /**
+ * @deprecated since 4.2 resources under FILE level will no more be supported.
+ */
+ @Deprecated
public static final String PARAGRAPH = "PAR";
+ /**
+ * @deprecated since 4.2 resources under FILE level will no more be supported.
+ */
+ @Deprecated
public static final String METHOD = "MET";
+ /**
+ * @deprecated since 4.2 resources under FILE level will no more be supported.
+ */
+ @Deprecated
public static final String FIELD = "FLD";
// ugly, should be replaced by "natures"
@@ -137,9 +153,11 @@ public final class Qualifiers {
/**
* @param resource not nullable
+ * @deprecated since 4.2 CLA qualifier is deprecated
*/
+ @Deprecated
public static boolean isClass(final Resource resource) {
- return StringUtils.equals(CLASS, resource.getQualifier());
+ return StringUtils.equals(CLASS, resource.getQualifier()) || isFile(resource);
}
/**
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceUtils.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceUtils.java
index 3676e50b140..1745f57641c 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceUtils.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceUtils.java
@@ -111,9 +111,11 @@ public final class ResourceUtils {
/**
* @return whether a resource is a class
+ * @deprecated since 4.2 CLA qualifier is deprecated
*/
+ @Deprecated
public static boolean isClass(Resource resource) {
- return Qualifiers.CLASS.equals(resource.getQualifier());
+ return Qualifiers.CLASS.equals(resource.getQualifier()) || Qualifiers.FILE.equals(resource.getQualifier());
}
/**
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/CoberturaReportParserUtilsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/CoberturaReportParserUtilsTest.java
index 9260bcf908d..d0bb5d6015b 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/CoberturaReportParserUtilsTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/CoberturaReportParserUtilsTest.java
@@ -154,52 +154,52 @@ public class CoberturaReportParserUtilsTest {
@Test
public void shouldInsertCoverageAtFileLevel() throws URISyntaxException {
File coverage = new File(getClass().getResource(
- "/org/sonar/api/utils/CoberturaReportParserUtilsTest/shouldInsertCoverageAtFileLevel/coverage.xml").toURI());
+ "/org/sonar/api/utils/CoberturaReportParserUtilsTest/shouldInsertCoverageAtFileLevel/coverage.xml").toURI());
when(context.getResource(any(Resource.class))).thenReturn(new JavaFile("org.sonar.MyClass"));
CoberturaReportParserUtils.parseReport(coverage, context, JAVA_FILE_RESOLVER);
- verify(context).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.CLASS, "org.sonar.samples.InnerClass")),
- argThat(new IsMeasure(CoreMetrics.LINES_TO_COVER, 35.0)));
- verify(context).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.CLASS, "org.sonar.samples.InnerClass")),
- argThat(new IsMeasure(CoreMetrics.UNCOVERED_LINES, 22.0)));
+ verify(context).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.InnerClass")),
+ argThat(new IsMeasure(CoreMetrics.LINES_TO_COVER, 35.0)));
+ verify(context).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.InnerClass")),
+ argThat(new IsMeasure(CoreMetrics.UNCOVERED_LINES, 22.0)));
- verify(context).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.CLASS, "org.sonar.samples.InnerClass")),
- argThat(new IsMeasure(CoreMetrics.CONDITIONS_TO_COVER, 4.0)));
- verify(context).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.CLASS, "org.sonar.samples.InnerClass")),
- argThat(new IsMeasure(CoreMetrics.UNCOVERED_CONDITIONS, 3.0)));
+ verify(context).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.InnerClass")),
+ argThat(new IsMeasure(CoreMetrics.CONDITIONS_TO_COVER, 4.0)));
+ verify(context).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.InnerClass")),
+ argThat(new IsMeasure(CoreMetrics.UNCOVERED_CONDITIONS, 3.0)));
verify(context, never()).saveMeasure(
- argThat(new IsResource(Scopes.FILE, Qualifiers.CLASS, "org.sonar.samples.InnerClass$InnerClassInside")),
- argThat(new IsMeasure(CoreMetrics.LINES_TO_COVER)));
+ argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.InnerClass$InnerClassInside")),
+ argThat(new IsMeasure(CoreMetrics.LINES_TO_COVER)));
verify(context, never()).saveMeasure(
- argThat(new IsResource(Scopes.FILE, Qualifiers.CLASS, "org.sonar.samples.InnerClass$InnerClassInside")),
- argThat(new IsMeasure(CoreMetrics.CONDITIONS_TO_COVER)));
+ argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.InnerClass$InnerClassInside")),
+ argThat(new IsMeasure(CoreMetrics.CONDITIONS_TO_COVER)));
verify(context, never()).saveMeasure(
- argThat(new IsResource(Scopes.FILE, Qualifiers.CLASS, "org.sonar.samples.InnerClass$InnerClassInside")),
- argThat(new IsMeasure(CoreMetrics.UNCOVERED_CONDITIONS)));
+ argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.InnerClass$InnerClassInside")),
+ argThat(new IsMeasure(CoreMetrics.UNCOVERED_CONDITIONS)));
verify(context, never()).saveMeasure(
- argThat(new IsResource(Scopes.FILE, Qualifiers.CLASS, "org.sonar.samples.InnerClass$InnerClassInside")),
- argThat(new IsMeasure(CoreMetrics.UNCOVERED_LINES)));
+ argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.InnerClass$InnerClassInside")),
+ argThat(new IsMeasure(CoreMetrics.UNCOVERED_LINES)));
verify(context, never()).saveMeasure(
- argThat(new IsResource(Scopes.FILE, Qualifiers.CLASS, "org.sonar.samples.PrivateClass")),
- argThat(new IsMeasure(CoreMetrics.LINES_TO_COVER)));
+ argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.PrivateClass")),
+ argThat(new IsMeasure(CoreMetrics.LINES_TO_COVER)));
verify(context, never()).saveMeasure(
- argThat(new IsResource(Scopes.FILE, Qualifiers.CLASS, "org.sonar.samples.PrivateClass")),
- argThat(new IsMeasure(CoreMetrics.CONDITIONS_TO_COVER)));
+ argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.PrivateClass")),
+ argThat(new IsMeasure(CoreMetrics.CONDITIONS_TO_COVER)));
verify(context, never()).saveMeasure(
- argThat(new IsResource(Scopes.FILE, Qualifiers.CLASS, "org.sonar.samples.PrivateClass")),
- argThat(new IsMeasure(CoreMetrics.UNCOVERED_CONDITIONS)));
+ argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.PrivateClass")),
+ argThat(new IsMeasure(CoreMetrics.UNCOVERED_CONDITIONS)));
verify(context, never()).saveMeasure(
- argThat(new IsResource(Scopes.FILE, Qualifiers.CLASS, "org.sonar.samples.PrivateClass")),
- argThat(new IsMeasure(CoreMetrics.UNCOVERED_LINES)));
+ argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.PrivateClass")),
+ argThat(new IsMeasure(CoreMetrics.UNCOVERED_LINES)));
verify(context)
- .saveMeasure(
- eq(new JavaFile("org.sonar.samples.InnerClass")),
- argThat(new IsMeasure(
- CoreMetrics.COVERAGE_LINE_HITS_DATA,
- "22=2;25=0;26=0;29=0;30=0;31=0;34=1;35=1;36=1;37=0;39=1;41=1;44=2;46=1;47=1;50=0;51=0;52=0;53=0;55=0;57=0;60=0;61=0;64=1;71=1;73=1;76=0;77=0;80=0;81=0;85=0;87=0;91=0;93=0;96=1")));
+ .saveMeasure(
+ eq(new JavaFile("org.sonar.samples.InnerClass")),
+ argThat(new IsMeasure(
+ CoreMetrics.COVERAGE_LINE_HITS_DATA,
+ "22=2;25=0;26=0;29=0;30=0;31=0;34=1;35=1;36=1;37=0;39=1;41=1;44=2;46=1;47=1;50=0;51=0;52=0;53=0;55=0;57=0;60=0;61=0;64=1;71=1;73=1;76=0;77=0;80=0;81=0;85=0;87=0;91=0;93=0;96=1")));
}
@Test
@@ -207,9 +207,9 @@ public class CoberturaReportParserUtilsTest {
when(context.getResource(any(Resource.class))).thenReturn(new JavaFile("org.sonar.MyClass"));
CoberturaReportParserUtils.parseReport(getCoverageReport(), context, JAVA_FILE_RESOLVER);
verify(context).saveMeasure(
- eq(new JavaFile("org.apache.commons.chain.impl.CatalogBase")),
- argThat(new IsMeasure(CoreMetrics.COVERAGE_LINE_HITS_DATA,
- "48=117;56=234;66=0;67=0;68=0;84=999;86=999;98=318;111=18;121=0;122=0;125=0;126=0;127=0;128=0;131=0;133=0")));
+ eq(new JavaFile("org.apache.commons.chain.impl.CatalogBase")),
+ argThat(new IsMeasure(CoreMetrics.COVERAGE_LINE_HITS_DATA,
+ "48=117;56=234;66=0;67=0;68=0;84=999;86=999;98=318;111=18;121=0;122=0;125=0;126=0;127=0;128=0;131=0;133=0")));
}
@Test
@@ -218,8 +218,8 @@ public class CoberturaReportParserUtilsTest {
when(context.getResource(any(Resource.class))).thenReturn(new JavaFile("org.sonar.samples.MyClass"));
CoberturaReportParserUtils.parseReport(coverage, context, JAVA_FILE_RESOLVER);
- verify(context).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.CLASS, "org.sonar.samples.MyFile")),
- argThat(new IsMeasure(CoreMetrics.LINES_TO_COVER, 5.0))); // do not count line 26 twice
+ verify(context).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.MyFile")),
+ argThat(new IsMeasure(CoreMetrics.LINES_TO_COVER, 5.0))); // do not count line 26 twice
}
private File getCoverageReport() throws URISyntaxException {