diff options
author | David Gageot <david@gageot.net> | 2012-05-25 10:15:23 +0200 |
---|---|---|
committer | David Gageot <david@gageot.net> | 2012-05-25 11:17:22 +0200 |
commit | 2f751bd1fa0fc9202f73d3ba165af02182e17b0c (patch) | |
tree | d1c4dab703f3b62a86503ef5dc154997faa4ebae | |
parent | 06d5b65b5ef22119ee9e48216c211bbb8832c53e (diff) | |
download | sonarqube-2f751bd1fa0fc9202f73d3ba165af02182e17b0c.tar.gz sonarqube-2f751bd1fa0fc9202f73d3ba165af02182e17b0c.zip |
Suppress warnings
14 files changed, 35 insertions, 28 deletions
diff --git a/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/bytecode/loader/FileSystemLoaderTest.java b/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/bytecode/loader/FileSystemLoaderTest.java index 58ed17a4c35..0af8f175232 100644 --- a/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/bytecode/loader/FileSystemLoaderTest.java +++ b/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/bytecode/loader/FileSystemLoaderTest.java @@ -19,20 +19,19 @@ */ 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(); diff --git a/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/bytecode/loader/JarLoaderTest.java b/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/bytecode/loader/JarLoaderTest.java index 424cea52fa0..3b21c63cd35 100644 --- a/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/bytecode/loader/JarLoaderTest.java +++ b/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/bytecode/loader/JarLoaderTest.java @@ -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 { diff --git a/sonar-batch-bootstrapper/src/test/java/org/sonar/batch/bootstrapper/BootstrapperTest.java b/sonar-batch-bootstrapper/src/test/java/org/sonar/batch/bootstrapper/BootstrapperTest.java index 2321af9c15e..8f3cc41871e 100644 --- a/sonar-batch-bootstrapper/src/test/java/org/sonar/batch/bootstrapper/BootstrapperTest.java +++ b/sonar-batch-bootstrapper/src/test/java/org/sonar/batch/bootstrapper/BootstrapperTest.java @@ -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 diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/TokenizerDispatcher.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/TokenizerDispatcher.java index 9e15ea5474a..a2c66b9aeb6 100644 --- a/sonar-colorizer/src/main/java/org/sonar/colorizer/TokenizerDispatcher.java +++ b/sonar-colorizer/src/main/java/org/sonar/colorizer/TokenizerDispatcher.java @@ -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; diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/DaoUtils.java b/sonar-core/src/main/java/org/sonar/core/persistence/DaoUtils.java index e31a623cc97..8014061c509 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/DaoUtils.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/DaoUtils.java @@ -41,6 +41,7 @@ public final class DaoUtils { private DaoUtils() { } + @SuppressWarnings("unchecked") public static List<Class<?>> getDaoClasses() { return ImmutableList.of( ActiveDashboardDao.class, diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/BatchExtensionDictionnary.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/BatchExtensionDictionnary.java index 16cb667c5ef..c8c58fab873 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/BatchExtensionDictionnary.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/BatchExtensionDictionnary.java @@ -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) { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/AnnotationUtils.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/AnnotationUtils.java index c6e6d87633c..8ca55d28ae4 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/AnnotationUtils.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/AnnotationUtils.java @@ -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; } } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/dag/DirectAcyclicGraph.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/dag/DirectAcyclicGraph.java index 1e7652f40f4..e5b091743e7 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/dag/DirectAcyclicGraph.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/dag/DirectAcyclicGraph.java @@ -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()); } diff --git a/sonar-squid/src/test/java/org/sonar/squid/measures/AbstractnessFormulaTest.java b/sonar-squid/src/test/java/org/sonar/squid/measures/AbstractnessFormulaTest.java index a3705488374..6d4eff9827d 100644 --- a/sonar-squid/src/test/java/org/sonar/squid/measures/AbstractnessFormulaTest.java +++ b/sonar-squid/src/test/java/org/sonar/squid/measures/AbstractnessFormulaTest.java @@ -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() { diff --git a/sonar-squid/src/test/java/org/sonar/squid/measures/CommentLinesDensityFormulaTest.java b/sonar-squid/src/test/java/org/sonar/squid/measures/CommentLinesDensityFormulaTest.java index 496d62ce963..0cebec786c5 100644 --- a/sonar-squid/src/test/java/org/sonar/squid/measures/CommentLinesDensityFormulaTest.java +++ b/sonar-squid/src/test/java/org/sonar/squid/measures/CommentLinesDensityFormulaTest.java @@ -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() { diff --git a/sonar-squid/src/test/java/org/sonar/squid/measures/CommentLinesWithoutHeaderFormulaTest.java b/sonar-squid/src/test/java/org/sonar/squid/measures/CommentLinesWithoutHeaderFormulaTest.java index 9fb255e3e2c..968fd469bd8 100644 --- a/sonar-squid/src/test/java/org/sonar/squid/measures/CommentLinesWithoutHeaderFormulaTest.java +++ b/sonar-squid/src/test/java/org/sonar/squid/measures/CommentLinesWithoutHeaderFormulaTest.java @@ -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() { diff --git a/sonar-squid/src/test/java/org/sonar/squid/measures/DistanceFormulaTest.java b/sonar-squid/src/test/java/org/sonar/squid/measures/DistanceFormulaTest.java index 406fb261171..8a2d95cb6e2 100644 --- a/sonar-squid/src/test/java/org/sonar/squid/measures/DistanceFormulaTest.java +++ b/sonar-squid/src/test/java/org/sonar/squid/measures/DistanceFormulaTest.java @@ -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() { diff --git a/sonar-squid/src/test/java/org/sonar/squid/measures/InstabilityFormulaTest.java b/sonar-squid/src/test/java/org/sonar/squid/measures/InstabilityFormulaTest.java index 92f3aca2ace..c8c854ad29e 100644 --- a/sonar-squid/src/test/java/org/sonar/squid/measures/InstabilityFormulaTest.java +++ b/sonar-squid/src/test/java/org/sonar/squid/measures/InstabilityFormulaTest.java @@ -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() { diff --git a/sonar-squid/src/test/java/org/sonar/squid/measures/PublicDocumentedApiDensityFormulaTest.java b/sonar-squid/src/test/java/org/sonar/squid/measures/PublicDocumentedApiDensityFormulaTest.java index bfc38bba206..c17e556ea59 100644 --- a/sonar-squid/src/test/java/org/sonar/squid/measures/PublicDocumentedApiDensityFormulaTest.java +++ b/sonar-squid/src/test/java/org/sonar/squid/measures/PublicDocumentedApiDensityFormulaTest.java @@ -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() { |