]> source.dussan.org Git - sonarqube.git/commitdiff
Suppress warnings
authorDavid Gageot <david@gageot.net>
Fri, 25 May 2012 08:15:23 +0000 (10:15 +0200)
committerDavid Gageot <david@gageot.net>
Fri, 25 May 2012 09:17:22 +0000 (11:17 +0200)
14 files changed:
plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/bytecode/loader/FileSystemLoaderTest.java
plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/bytecode/loader/JarLoaderTest.java
sonar-batch-bootstrapper/src/test/java/org/sonar/batch/bootstrapper/BootstrapperTest.java
sonar-colorizer/src/main/java/org/sonar/colorizer/TokenizerDispatcher.java
sonar-core/src/main/java/org/sonar/core/persistence/DaoUtils.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/BatchExtensionDictionnary.java
sonar-plugin-api/src/main/java/org/sonar/api/utils/AnnotationUtils.java
sonar-plugin-api/src/main/java/org/sonar/api/utils/dag/DirectAcyclicGraph.java
sonar-squid/src/test/java/org/sonar/squid/measures/AbstractnessFormulaTest.java
sonar-squid/src/test/java/org/sonar/squid/measures/CommentLinesDensityFormulaTest.java
sonar-squid/src/test/java/org/sonar/squid/measures/CommentLinesWithoutHeaderFormulaTest.java
sonar-squid/src/test/java/org/sonar/squid/measures/DistanceFormulaTest.java
sonar-squid/src/test/java/org/sonar/squid/measures/InstabilityFormulaTest.java
sonar-squid/src/test/java/org/sonar/squid/measures/PublicDocumentedApiDensityFormulaTest.java

index 58ed17a4c3516c8a2f2f47f307011f10d2252b39..0af8f1752326c9912067d5d6cc1db56e350b6ab3 100644 (file)
  */
 package org.sonar.java.bytecode.loader;
 
+import org.junit.Test;
+import org.sonar.java.ast.SquidTestUtils;
+
+import java.io.File;
+import java.net.URL;
+
 import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.Matchers.allOf;
 import static org.hamcrest.Matchers.endsWith;
 import static org.hamcrest.Matchers.notNullValue;
 import static org.hamcrest.Matchers.startsWith;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.fail;
 
-import java.io.File;
-import java.net.URL;
-
-import org.junit.Test;
-import org.sonar.java.ast.SquidTestUtils;
-
 public class FileSystemLoaderTest {
 
   @Test(expected = IllegalArgumentException.class)
@@ -49,7 +48,8 @@ public class FileSystemLoaderTest {
 
     URL url = loader.findResource("tags/TagName.class");
     assertThat(url, notNullValue());
-    assertThat(url.toString(), allOf(startsWith("file:"), endsWith("TagName.class")));
+    assertThat(url.toString(), startsWith("file:"));
+    assertThat(url.toString(), endsWith("TagName.class"));
 
     loader.close();
 
index 424cea52fa0e9993cf379cbf04913b3452e0d647..3b21c63cd354e3ca4c2c883152197ec10d7d3c41 100644 (file)
@@ -49,7 +49,8 @@ public class JarLoaderTest {
 
     URL url = loader.findResource("META-INF/MANIFEST.MF");
     assertThat(url, notNullValue());
-    assertThat(url.toString(), allOf(startsWith("jar:"), endsWith("hello.jar!/META-INF/MANIFEST.MF")));
+    assertThat(url.toString(), startsWith("jar:"));
+    assertThat(url.toString(), endsWith("hello.jar!/META-INF/MANIFEST.MF"));
 
     InputStream is = url.openStream();
     try {
index 2321af9c15ed2dfa41d340fc3aa71e679acadb0d..8f3cc41871e259a1ea4898a2bd5f464249a1205b 100644 (file)
@@ -45,8 +45,10 @@ public class BootstrapperTest {
   public void shouldReturnUserAgent() {
     Bootstrapper bootstrapper = new Bootstrapper("test/0.1", "http://unknown.foo", new File("target"));
     String userAgent = bootstrapper.getUserAgent();
+
     assertThat(userAgent.length(), greaterThan(0));
-    assertThat(userAgent, allOf(startsWith("sonar-bootstrapper/"), endsWith(" test/0.1")));
+    assertThat(userAgent, startsWith("sonar-bootstrapper/"));
+    assertThat(userAgent, endsWith(" test/0.1"));
   }
 
   @Test
index 9e15ea5474adcccb27e34ceae770e14e3e414df9..a2c66b9aeb697c566374fcc0a32e0c265fb07df3 100644 (file)
@@ -26,7 +26,7 @@ import java.util.List;
 
 public class TokenizerDispatcher {
 
-  private Channel[] tokenizers;
+  private Channel<HtmlCodeBuilder>[] tokenizers;
 
   public TokenizerDispatcher(Channel<HtmlCodeBuilder>... tokenizers) {
     this.tokenizers = tokenizers;
index e31a623cc976fccfa83286812975076ac6cac831..8014061c509f1dbbb88143dab68cdb3cae187bf2 100644 (file)
@@ -41,6 +41,7 @@ public final class DaoUtils {
   private DaoUtils() {
   }
 
+  @SuppressWarnings("unchecked")
   public static List<Class<?>> getDaoClasses() {
     return ImmutableList.of(
         ActiveDashboardDao.class,
index 16cb667c5ef59d1952c22a5b7ca12bb756b5ed76..c8c58fab873a63d826d22f5b43fd5c10df269083 100644 (file)
@@ -156,7 +156,7 @@ public class BatchExtensionDictionnary {
   }
 
 
-  protected List evaluateAnnotatedClasses(Object extension, Class annotation) {
+  protected List evaluateAnnotatedClasses(Object extension, Class<? extends Annotation> annotation) {
     List<Object> results = Lists.newArrayList();
     Class aClass = extension.getClass();
     while (aClass != null) {
index c6e6d87633c46bd3121e54b5c93cbe8ac84da6f5..8ca55d28ae46953f58dce2232656fb607d067f4c 100644 (file)
@@ -21,6 +21,7 @@ package org.sonar.api.utils;
 
 import org.apache.commons.lang.ClassUtils;
 
+import java.lang.annotation.Annotation;
 import java.util.List;
 
 /**
@@ -36,20 +37,20 @@ public final class AnnotationUtils {
   /**
    * Searches for a class annotation. All inheritance tree is analysed.
    */
-  public static <A> A getClassAnnotation(final Object object, final Class<A> annotationClass) {
-    Class initialClass = (object instanceof Class ? (Class) object : object.getClass());
+  public static <A extends Annotation> A getClassAnnotation(Object object, Class<A> annotationClass) {
+    Class<?> initialClass = (object instanceof Class<?> ? (Class<?>) object : object.getClass());
     A result = null;
-    Class aClass=initialClass;
+    Class<?> aClass = initialClass;
     while (aClass != null && result == null) {
-      result = (A)aClass.getAnnotation(annotationClass);
+      result = aClass.getAnnotation(annotationClass);
       aClass = aClass.getSuperclass();
     }
 
-    if (result==null) {
-      List<Class> interfaces = ClassUtils.getAllInterfaces(initialClass);
-      for (Class anInterface : interfaces) {
-        result = (A)anInterface.getAnnotation(annotationClass);
-        if (result!=null) {
+    if (result == null) {
+      List<Class<?>> interfaces = ClassUtils.getAllInterfaces(initialClass);
+      for (Class<?> anInterface : interfaces) {
+        result = anInterface.getAnnotation(annotationClass);
+        if (result != null) {
           break;
         }
       }
index 1e7652f40f4b244ff4b87bc7e2fc9ced1d93287d..e5b091743e7b7b25856593c0f0881b4039d354dd 100644 (file)
@@ -19,6 +19,8 @@
  */
 package org.sonar.api.utils.dag;
 
+import com.google.common.collect.Lists;
+
 import org.sonar.api.utils.SonarException;
 
 import java.util.*;
@@ -61,7 +63,7 @@ public class DirectAcyclicGraph {
   public List sort() {
     sortNodes();
 
-    List result = new ArrayList();
+    List<Object> result = Lists.newArrayList();
     for (Node node : nodes) {
       result.add(node.getObject());
     }
index a3705488374a42eeee94f09cc13300ae08803907..6d4eff9827d2c7ab263e0b5f303c332818add0b6 100644 (file)
@@ -30,7 +30,7 @@ import static org.junit.Assert.assertEquals;
 public class AbstractnessFormulaTest {
 
   AbstractnessFormula abstractness = new AbstractnessFormula();
-  Measurable<Metric> measurable = new SourcePackage("pac1");
+  SourcePackage measurable = new SourcePackage("pac1");
 
   @Test
   public void testCalculate() {
index 496d62ce9638f36d50f7b116ade45bdbf96055e7..0cebec786c57179a6dee05483e1b4ff42084f69f 100644 (file)
@@ -28,7 +28,7 @@ import static org.junit.Assert.*;
 public class CommentLinesDensityFormulaTest {
 
   CommentLinesDensityFormula formula = new CommentLinesDensityFormula();
-  Measurable<Metric> measurable = new SourceClass("com.Toto");
+  SourceClass measurable = new SourceClass("com.Toto");
 
   @Test
   public void calculateDensityOnEmptyFile() {
index 9fb255e3e2cc5bdf227098f61477c94267ea4c83..968fd469bd8e86d88369c8e89aaa3d073ceae247 100644 (file)
@@ -28,7 +28,7 @@ import static org.junit.Assert.assertEquals;
 public class CommentLinesWithoutHeaderFormulaTest {
 
   CommentLinesWithoutHeaderFormula formula = new CommentLinesWithoutHeaderFormula();
-  Measurable<Metric> measurable = new SourceClass("com.Toto");
+  SourceClass measurable = new SourceClass("com.Toto");
 
   @Test
   public void calculateDensityOnEmptyFile() {
index 406fb2611712ac2f354b95a3973fa97794a5e714..8a2d95cb6e2990cbb2d446e6b28fa50fc8a9169f 100644 (file)
@@ -28,7 +28,7 @@ import static org.junit.Assert.assertEquals;
 public class DistanceFormulaTest {
 
   DistanceFormula distance = new DistanceFormula();
-  Measurable<Metric> measurable = new SourcePackage("pac1");
+  SourcePackage measurable = new SourcePackage("pac1");
 
   @Test
   public void calculateBestDistance() {
index 92f3aca2ace67d2aff537b946dc5a27c610101f8..c8c854ad29e7ce4ad0f46c59b1c1076d392f9910 100644 (file)
@@ -28,7 +28,7 @@ import static org.junit.Assert.assertEquals;
 public class InstabilityFormulaTest {
 
   InstabilityFormula distance = new InstabilityFormula();
-  Measurable<Metric> measurable = new SourcePackage("pac1");
+  SourcePackage measurable = new SourcePackage("pac1");
 
   @Test
   public void calculateBestStability() {
index bfc38bba20622a3c12c0812089a2ce4d662646be..c17e556ea5999cfc453ae2f58e78aaa26379fda8 100644 (file)
@@ -28,7 +28,7 @@ import static org.junit.Assert.*;
 public class PublicDocumentedApiDensityFormulaTest {
 
   PublicDocumentedApiDensityFormula formula = new PublicDocumentedApiDensityFormula();
-  Measurable<Metric> measurable = new SourceClass("com.Toto");
+  SourceClass measurable = new SourceClass("com.Toto");
 
   @Test
   public void calculateWhenNoPublicApi() {