diff options
author | David Gageot <david@gageot.net> | 2012-04-24 10:12:28 +0200 |
---|---|---|
committer | David Gageot <david@gageot.net> | 2012-04-27 14:58:59 +0200 |
commit | 872b3923f80d9a2bcc13713f41cf801f2a7024eb (patch) | |
tree | 2ef0a5003c3becb1b0e53d5683e60ed3c9f759b5 /plugins | |
parent | 4b262d15878b31c6c2c7efd8236fb5c65093ba11 (diff) | |
download | sonarqube-872b3923f80d9a2bcc13713f41cf801f2a7024eb.tar.gz sonarqube-872b3923f80d9a2bcc13713f41cf801f2a7024eb.zip |
Remove warnings
Diffstat (limited to 'plugins')
39 files changed, 326 insertions, 304 deletions
diff --git a/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleConfiguration.java b/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleConfiguration.java index 803dfc1ddf9..550c7e4b1f4 100644 --- a/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleConfiguration.java +++ b/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleConfiguration.java @@ -37,7 +37,11 @@ import org.sonar.api.resources.Java; import org.sonar.api.resources.ProjectFileSystem; import org.sonar.api.utils.SonarException; -import java.io.*; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.Writer; import java.nio.charset.Charset; import java.util.List; import java.util.Locale; @@ -56,10 +60,10 @@ public class CheckstyleConfiguration implements BatchExtension { private static final Logger LOG = LoggerFactory.getLogger(CheckstyleConfiguration.class); public static final String PROPERTY_GENERATE_XML = "sonar.checkstyle.generateXml"; - private CheckstyleProfileExporter confExporter; - private RulesProfile profile; - private Settings conf; - private ProjectFileSystem fileSystem; + private final CheckstyleProfileExporter confExporter; + private final RulesProfile profile; + private final Settings conf; + private final ProjectFileSystem fileSystem; public CheckstyleConfiguration(Settings conf, CheckstyleProfileExporter confExporter, RulesProfile profile, ProjectFileSystem fileSystem) { this.conf = conf; @@ -96,7 +100,7 @@ public class CheckstyleConfiguration implements BatchExtension { return null; } - public com.puppycrawl.tools.checkstyle.api.Configuration getCheckstyleConfiguration() throws IOException, CheckstyleException { + public com.puppycrawl.tools.checkstyle.api.Configuration getCheckstyleConfiguration() throws CheckstyleException { File xmlConfig = getXMLDefinitionFile(); LOG.info("Checkstyle configuration: " + xmlConfig.getAbsolutePath()); diff --git a/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java b/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java index 9bba008989b..b81a8454578 100644 --- a/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java +++ b/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java @@ -19,12 +19,13 @@ */ package org.sonar.plugins.checkstyle; +import com.google.common.collect.ImmutableList; +import org.sonar.api.Extension; import org.sonar.api.Properties; import org.sonar.api.Property; import org.sonar.api.PropertyType; import org.sonar.api.SonarPlugin; -import java.util.Arrays; import java.util.List; @Properties({ @@ -39,17 +40,17 @@ import java.util.List; type = PropertyType.TEXT)}) public final class CheckstylePlugin extends SonarPlugin { - public List getExtensions() { - return Arrays.asList( - CheckstyleSensor.class, - CheckstyleConfiguration.class, - CheckstyleExecutor.class, - CheckstyleAuditListener.class, - CheckstyleProfileExporter.class, - CheckstyleProfileImporter.class, - CheckstyleRuleRepository.class, - SonarWayProfile.class, - SunConventionsProfile.class, - SonarWayWithFindbugsProfile.class); + public List<Class<? extends Extension>> getExtensions() { + return ImmutableList.of( + CheckstyleSensor.class, + CheckstyleConfiguration.class, + CheckstyleExecutor.class, + CheckstyleAuditListener.class, + CheckstyleProfileExporter.class, + CheckstyleProfileImporter.class, + CheckstyleRuleRepository.class, + SonarWayProfile.class, + SunConventionsProfile.class, + SonarWayWithFindbugsProfile.class); } } diff --git a/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleConfigurationTest.java b/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleConfigurationTest.java index 8ab95ac7f9a..69831487119 100644 --- a/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleConfigurationTest.java +++ b/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleConfigurationTest.java @@ -21,7 +21,6 @@ package org.sonar.plugins.checkstyle; import org.apache.commons.io.FileUtils; import org.junit.Test; -import org.sonar.api.config.Settings; import org.sonar.api.profiles.RulesProfile; import org.sonar.api.resources.Project; import org.sonar.api.test.MavenTestUtils; @@ -29,8 +28,6 @@ import org.sonar.api.test.MavenTestUtils; import java.io.File; import java.io.IOException; import java.io.Writer; -import java.util.Locale; - import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; diff --git a/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaPlugin.java b/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaPlugin.java index fcea73baa5e..222c2c5ac77 100644 --- a/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaPlugin.java +++ b/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaPlugin.java @@ -19,32 +19,35 @@ */ package org.sonar.plugins.cobertura; -import org.sonar.api.*; +import com.google.common.collect.ImmutableList; +import org.sonar.api.BatchExtension; +import org.sonar.api.CoreProperties; +import org.sonar.api.Properties; +import org.sonar.api.Property; +import org.sonar.api.SonarPlugin; -import java.util.ArrayList; import java.util.List; @Properties({ - @Property( - key = CoreProperties.COBERTURA_REPORT_PATH_PROPERTY, - name = "Report path", - description = "Path (absolute or relative) to Cobertura xml report file.", - project = true, - global = false), - @Property( - key = CoreProperties.COBERTURA_MAXMEM_PROPERTY, - defaultValue = CoreProperties.COBERTURA_MAXMEM_DEFAULT_VALUE, - name = "Maxmem", - description = "Maximum memory to pass to JVM of Cobertura processes", - project = true, - global = true) }) + @Property( + key = CoreProperties.COBERTURA_REPORT_PATH_PROPERTY, + name = "Report path", + description = "Path (absolute or relative) to Cobertura xml report file.", + project = true, + global = false), + @Property( + key = CoreProperties.COBERTURA_MAXMEM_PROPERTY, + defaultValue = CoreProperties.COBERTURA_MAXMEM_DEFAULT_VALUE, + name = "Maxmem", + description = "Maximum memory to pass to JVM of Cobertura processes", + project = true, + global = true)}) public class CoberturaPlugin extends SonarPlugin { - public List<Class<? extends Extension>> getExtensions() { - List<Class<? extends Extension>> list = new ArrayList<Class<? extends Extension>>(); - list.add(CoberturaSensor.class); - list.add(CoberturaMavenPluginHandler.class); - list.add(CoberturaMavenInitializer.class); - return list; + public List<Class<? extends BatchExtension>> getExtensions() { + return ImmutableList.of( + CoberturaSensor.class, + CoberturaMavenPluginHandler.class, + CoberturaMavenInitializer.class); } } diff --git a/plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaSensorTest.java b/plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaSensorTest.java index dd37f433f62..83db39159c6 100644 --- a/plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaSensorTest.java +++ b/plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaSensorTest.java @@ -19,26 +19,36 @@ */ package org.sonar.plugins.cobertura; -import static org.hamcrest.CoreMatchers.is; -import static org.mockito.Matchers.*; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - import org.junit.Before; import org.junit.Test; import org.sonar.api.CoreProperties; import org.sonar.api.batch.SensorContext; import org.sonar.api.measures.CoreMetrics; import org.sonar.api.measures.Measure; -import org.sonar.api.resources.*; +import org.sonar.api.resources.JavaFile; +import org.sonar.api.resources.JavaPackage; +import org.sonar.api.resources.Project; +import org.sonar.api.resources.ProjectFileSystem; +import org.sonar.api.resources.Qualifiers; +import org.sonar.api.resources.Resource; +import org.sonar.api.resources.Scopes; import org.sonar.api.test.IsMeasure; import org.sonar.api.test.IsResource; import java.io.File; import java.net.URISyntaxException; +import static org.hamcrest.CoreMatchers.is; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyDouble; +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.argThat; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + public class CoberturaSensorTest { private SensorContext context; @@ -51,7 +61,7 @@ public class CoberturaSensorTest { } @Test - public void shouldNotFailIfReportNotSpecifiedOrNotFound() throws URISyntaxException { + public void shouldNotFailIfReportNotSpecifiedOrNotFound() { ProjectFileSystem pfs = mock(ProjectFileSystem.class); when(pfs.resolvePath(anyString())) .thenReturn(new File("notFound.xml")); diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java index 71c09d25209..29764d34fdc 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java @@ -223,7 +223,7 @@ import java.util.List; public final class CorePlugin extends SonarPlugin { @SuppressWarnings({"rawtypes", "unchecked"}) - public List getExtensions() { + public List<Class<? extends Extension>> getExtensions() { List extensions = Lists.newLinkedList(); extensions.add(DefaultResourceTypes.class); diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/GenerateAlertEventsTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/GenerateAlertEventsTest.java index 4e2d41888ab..f6ccdb668b3 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/GenerateAlertEventsTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/GenerateAlertEventsTest.java @@ -19,13 +19,8 @@ */ package org.sonar.plugins.core.sensors; -import org.dbunit.dataset.DataSetException; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; import org.junit.Before; import org.junit.Test; -import static org.mockito.Matchers.anyObject; -import static org.mockito.Mockito.*; import org.sonar.api.batch.DecoratorContext; import org.sonar.api.batch.Event; import org.sonar.api.batch.TimeMachine; @@ -41,6 +36,16 @@ import org.sonar.api.test.ProjectTestBuilder; import java.util.Arrays; import java.util.Date; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; +import static org.mockito.Matchers.anyObject; +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.isNull; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + public class GenerateAlertEventsTest { private GenerateAlertEvents decorator; private DecoratorContext context; @@ -113,14 +118,14 @@ public class GenerateAlertEventsTest { } @Test - public void shouldNotCreateEventWhenNoAlertStatus() throws DataSetException { + public void shouldNotCreateEventWhenNoAlertStatus() { decorator.decorate(project, context); verify(context, never()).createEvent(anyString(), anyString(), anyString(), (Date) isNull()); } @Test - public void shouldNotCreateEventWhenSameLevel() throws DataSetException { + public void shouldNotCreateEventWhenSameLevel() { when(timeMachine.getMeasures((TimeMachineQuery) anyObject())).thenReturn(Arrays.asList(newAlertStatus(Metric.Level.ERROR, "desc"))); when(context.getMeasure(CoreMetrics.ALERT_STATUS)).thenReturn(newAlertStatus(Metric.Level.ERROR, "desc")); @@ -130,7 +135,7 @@ public class GenerateAlertEventsTest { } @Test - public void shouldNotCreateEventIfNoMoreAlertStatus() throws DataSetException { + public void shouldNotCreateEventIfNoMoreAlertStatus() { when(timeMachine.getMeasures((TimeMachineQuery) anyObject())).thenReturn(Arrays.asList(newAlertStatus(Metric.Level.ERROR, "desc"))); when(context.getMeasure(CoreMetrics.ALERT_STATUS)).thenReturn(null); @@ -139,7 +144,6 @@ public class GenerateAlertEventsTest { verify(context, never()).createEvent(anyString(), anyString(), anyString(), (Date) isNull()); } - private Measure newAlertStatus(Metric.Level level, String label) { Measure measure = new Measure(CoreMetrics.ALERT_STATUS, level); measure.setAlertStatus(level); diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/ProfileEventsSensorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/ProfileEventsSensorTest.java index f0626571a47..f2b885fb65d 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/ProfileEventsSensorTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/ProfileEventsSensorTest.java @@ -19,11 +19,6 @@ */ package org.sonar.plugins.core.sensors; -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.*; -import static org.mockito.Mockito.*; - import org.junit.Before; import org.junit.Test; import org.sonar.api.batch.Event; @@ -36,11 +31,23 @@ import org.sonar.api.profiles.RulesProfile; import org.sonar.api.resources.Project; import org.sonar.api.resources.Resource; -import java.text.ParseException; import java.util.Arrays; import java.util.Collections; import java.util.Date; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyObject; +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.eq; +import static org.mockito.Matchers.same; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.when; + public class ProfileEventsSensorTest { private Project project; @@ -61,7 +68,7 @@ public class ProfileEventsSensorTest { } @Test - public void shouldDoNothingIfNoProfile() throws ParseException { + public void shouldDoNothingIfNoProfile() { ProfileEventsSensor sensor = new ProfileEventsSensor(null, null); sensor.analyse(project, context); @@ -70,7 +77,7 @@ public class ProfileEventsSensorTest { } @Test - public void shouldDoNothingIfNoProfileChange() throws ParseException { + public void shouldDoNothingIfNoProfileChange() { RulesProfile profile = mockProfileWithVersion(1); TimeMachine timeMachine = mockTM(project, 22.0, "Foo", 1.0); // Same profile, same version ProfileEventsSensor sensor = new ProfileEventsSensor(profile, timeMachine); @@ -81,7 +88,7 @@ public class ProfileEventsSensorTest { } @Test - public void shouldCreateEventIfProfileChange() throws ParseException { + public void shouldCreateEventIfProfileChange() { RulesProfile profile = mockProfileWithVersion(1); TimeMachine timeMachine = mockTM(project, 21.0, "Bar", 1.0); // Different profile ProfileEventsSensor sensor = new ProfileEventsSensor(profile, timeMachine); @@ -95,7 +102,7 @@ public class ProfileEventsSensorTest { } @Test - public void shouldCreateEventIfProfileVersionChange() throws ParseException { + public void shouldCreateEventIfProfileVersionChange() { RulesProfile profile = mockProfileWithVersion(2); TimeMachine timeMachine = mockTM(project, 22.0, "Foo", 1.0); // Same profile, different version ProfileEventsSensor sensor = new ProfileEventsSensor(profile, timeMachine); @@ -109,7 +116,7 @@ public class ProfileEventsSensorTest { } @Test - public void shouldNotCreateEventIfFirstAnalysis() throws ParseException { + public void shouldNotCreateEventIfFirstAnalysis() { RulesProfile profile = mockProfileWithVersion(2); TimeMachine timeMachine = mockTM(project, null, null); ProfileEventsSensor sensor = new ProfileEventsSensor(profile, timeMachine); @@ -120,7 +127,7 @@ public class ProfileEventsSensorTest { } @Test - public void shouldCreateEventIfFirstAnalysisWithVersionsAndVersionMoreThan1() throws ParseException { + public void shouldCreateEventIfFirstAnalysisWithVersionsAndVersionMoreThan1() { RulesProfile profile = mockProfileWithVersion(2); TimeMachine timeMachine = mockTM(project, 22.0, "Foo", null); ProfileEventsSensor sensor = new ProfileEventsSensor(profile, timeMachine); diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/VersionEventsSensorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/VersionEventsSensorTest.java index 1c8db23ba19..65af02fcab2 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/VersionEventsSensorTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/VersionEventsSensorTest.java @@ -19,6 +19,15 @@ */ package org.sonar.plugins.core.sensors; +import com.google.common.collect.Lists; +import org.junit.Test; +import org.sonar.api.batch.Event; +import org.sonar.api.batch.SensorContext; +import org.sonar.api.resources.Project; +import org.sonar.api.resources.Resource; + +import java.util.Date; + import static org.mockito.Matchers.anyObject; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; @@ -28,23 +37,8 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; - -import org.junit.Test; -import org.sonar.api.batch.Event; -import org.sonar.api.batch.SensorContext; -import org.sonar.api.resources.Project; -import org.sonar.api.resources.Resource; - public class VersionEventsSensorTest { - private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); - private SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyyMMdd HH:mm"); - @Test public void shouldDoNothingIfNoVersion() { VersionEventsSensor sensor = new VersionEventsSensor(); @@ -83,7 +77,7 @@ public class VersionEventsSensorTest { Project project = mock(Project.class); when(project.getAnalysisVersion()).thenReturn("1.5-SNAPSHOT"); - when(context.getEvents(project)).thenReturn(new ArrayList(Arrays.asList(sameVersionEvent, otherEvent, anotherEvent))); + when(context.getEvents(project)).thenReturn(Lists.newArrayList(sameVersionEvent, otherEvent, anotherEvent)); sensor.analyse(project, context); @@ -99,7 +93,7 @@ public class VersionEventsSensorTest { SensorContext context = mock(SensorContext.class); Project project = mock(Project.class); when(project.getAnalysisVersion()).thenReturn("1.5"); - when(context.getEvents(project)).thenReturn(new ArrayList(Arrays.asList(snapshotVersion, otherEvent))); + when(context.getEvents(project)).thenReturn(Lists.newArrayList(snapshotVersion, otherEvent)); VersionEventsSensor sensor = new VersionEventsSensor(); sensor.analyse(project, context); @@ -114,13 +108,4 @@ public class VersionEventsSensorTest { when(event.getName()).thenReturn(version); return event; } - - private Event mockEvent(String name, String yyyyMMdd) throws ParseException { - Event event = mock(Event.class); - when(event.isVersionCategory()).thenReturn(false); - when(event.isLinkedToSnapshot()).thenReturn(false); - when(event.getName()).thenReturn(name); - when(event.getDate()).thenReturn(dateFormat.parse(yyyyMMdd)); - return event; - } } diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersisterTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersisterTest.java index 36a0abc05a7..da8bc44ac4c 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersisterTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersisterTest.java @@ -26,7 +26,6 @@ import org.sonar.batch.components.PastSnapshot; import org.sonar.batch.components.TimeMachineConfiguration; import org.sonar.jpa.test.AbstractDbUnitTestCase; -import java.text.ParseException; import java.util.Arrays; import static org.mockito.Mockito.mock; @@ -35,7 +34,7 @@ import static org.mockito.Mockito.when; public class TimeMachineConfigurationPersisterTest extends AbstractDbUnitTestCase { @Test - public void shouldSaveConfigurationInSnapshotsTable() throws ParseException { + public void shouldSaveConfigurationInSnapshotsTable() { setupData("shared"); TimeMachineConfiguration conf = mock(TimeMachineConfiguration.class); diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/ViolationTrackingDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/ViolationTrackingDecoratorTest.java index 7ec500b954c..911f66ff443 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/ViolationTrackingDecoratorTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/ViolationTrackingDecoratorTest.java @@ -28,12 +28,13 @@ import org.sonar.api.rules.Rule; import org.sonar.api.rules.Violation; import org.sonar.api.utils.DateUtils; -import java.text.ParseException; import java.util.Collections; import java.util.Date; import java.util.Map; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.nullValue; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -41,10 +42,10 @@ import static org.mockito.Mockito.when; public class ViolationTrackingDecoratorTest { private ViolationTrackingDecorator decorator; - private Date analysisDate = DateUtils.parseDate("2010-12-25"); + private final Date analysisDate = DateUtils.parseDate("2010-12-25"); @Before - public void setUp() throws ParseException { + public void setUp() { Project project = mock(Project.class); when(project.getAnalysisDate()).thenReturn(analysisDate); decorator = new ViolationTrackingDecorator(project, null, null); @@ -183,7 +184,7 @@ public class ViolationTrackingDecoratorTest { Violation newViolation = newViolation("message", 1, 50, "checksum"); assertThat(newViolation.getCreatedAt(), nullValue()); - Map<Violation, RuleFailureModel> mapping = decorator.mapViolations(Lists.newArrayList(newViolation), Collections.<RuleFailureModel>emptyList()); + Map<Violation, RuleFailureModel> mapping = decorator.mapViolations(Lists.newArrayList(newViolation), Collections.<RuleFailureModel> emptyList()); assertThat(mapping.size(), is(0)); assertThat(newViolation.getCreatedAt(), is(analysisDate)); assertThat(newViolation.isNew(), is(true)); @@ -197,7 +198,7 @@ public class ViolationTrackingDecoratorTest { referenceViolation.setCreatedAt(referenceDate); assertThat(newViolation.getCreatedAt(), nullValue()); - Map<Violation, RuleFailureModel> mapping = decorator.mapViolations(Lists.newArrayList(newViolation), Lists.<RuleFailureModel>newArrayList(referenceViolation)); + Map<Violation, RuleFailureModel> mapping = decorator.mapViolations(Lists.newArrayList(newViolation), Lists.<RuleFailureModel> newArrayList(referenceViolation)); assertThat(mapping.size(), is(1)); assertThat(newViolation.getCreatedAt(), is(referenceDate)); assertThat(newViolation.isNew(), is(false)); diff --git a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/CpdPlugin.java b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/CpdPlugin.java index 2708f843d17..9b734290990 100644 --- a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/CpdPlugin.java +++ b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/CpdPlugin.java @@ -19,13 +19,17 @@ */ package org.sonar.plugins.cpd; -import org.sonar.api.*; +import com.google.common.collect.ImmutableList; +import org.sonar.api.BatchExtension; +import org.sonar.api.CoreProperties; +import org.sonar.api.Properties; +import org.sonar.api.Property; import org.sonar.api.PropertyType; +import org.sonar.api.SonarPlugin; import org.sonar.plugins.cpd.decorators.DuplicationDensityDecorator; import org.sonar.plugins.cpd.decorators.SumDuplicationsDecorator; import org.sonar.plugins.cpd.index.IndexFactory; -import java.util.Arrays; import java.util.List; @Properties({ @@ -92,12 +96,15 @@ import java.util.List; }) public final class CpdPlugin extends SonarPlugin { - public List getExtensions() { - return Arrays.asList(CpdSensor.class, SumDuplicationsDecorator.class, DuplicationDensityDecorator.class, - IndexFactory.class, - SonarEngine.class, - PmdEngine.class, - SonarBridgeEngine.class); + public List<Class<? extends BatchExtension>> getExtensions() { + return ImmutableList.of( + CpdSensor.class, + SumDuplicationsDecorator.class, + DuplicationDensityDecorator.class, + IndexFactory.class, + SonarEngine.class, + PmdEngine.class, + SonarBridgeEngine.class); } } diff --git a/plugins/sonar-cpd-plugin/src/test/java/org/sonar/plugins/cpd/PmdEngineTest.java b/plugins/sonar-cpd-plugin/src/test/java/org/sonar/plugins/cpd/PmdEngineTest.java index 54a86f56063..3bbedf7f787 100644 --- a/plugins/sonar-cpd-plugin/src/test/java/org/sonar/plugins/cpd/PmdEngineTest.java +++ b/plugins/sonar-cpd-plugin/src/test/java/org/sonar/plugins/cpd/PmdEngineTest.java @@ -56,8 +56,7 @@ public class PmdEngineTest { public void defaultMinimumTokens() { Project project = createJavaProject().setConfiguration(new PropertiesConfiguration()); - PmdEngine engine = new PmdEngine(); - assertEquals(CoreProperties.CPD_MINIMUM_TOKENS_DEFAULT_VALUE, engine.getMinimumTokens(project)); + assertEquals(CoreProperties.CPD_MINIMUM_TOKENS_DEFAULT_VALUE, PmdEngine.getMinimumTokens(project)); } @Test @@ -66,8 +65,7 @@ public class PmdEngineTest { conf.setProperty("sonar.cpd.minimumTokens", "33"); Project project = createJavaProject().setConfiguration(conf); - PmdEngine engine = new PmdEngine(); - assertEquals(33, engine.getMinimumTokens(project)); + assertEquals(33, PmdEngine.getMinimumTokens(project)); } @Test @@ -79,9 +77,8 @@ public class PmdEngineTest { Project phpProject = createPhpProject().setConfiguration(conf); Project javaProject = createJavaProject().setConfiguration(conf); - PmdEngine engine = new PmdEngine(); - assertEquals(100, engine.getMinimumTokens(javaProject)); - assertEquals(33, engine.getMinimumTokens(phpProject)); + assertEquals(100, PmdEngine.getMinimumTokens(javaProject)); + assertEquals(33, PmdEngine.getMinimumTokens(phpProject)); } private Project createJavaProject() { diff --git a/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/DbCleanerPlugin.java b/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/DbCleanerPlugin.java index 4507771468f..6b2921e61a4 100644 --- a/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/DbCleanerPlugin.java +++ b/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/DbCleanerPlugin.java @@ -19,6 +19,8 @@ */ package org.sonar.plugins.dbcleaner; +import com.google.common.collect.ImmutableList; +import org.sonar.api.BatchExtension; import org.sonar.api.Properties; import org.sonar.api.Property; import org.sonar.api.PropertyType; @@ -26,7 +28,6 @@ import org.sonar.api.SonarPlugin; import org.sonar.plugins.dbcleaner.api.DbCleanerConstants; import org.sonar.plugins.dbcleaner.period.DefaultPeriodCleaner; -import java.util.Arrays; import java.util.List; @Properties({ @@ -50,11 +51,13 @@ import java.util.List; global = true, project = true, type = PropertyType.INTEGER) -} -) +}) public final class DbCleanerPlugin extends SonarPlugin { - public List getExtensions() { - return Arrays.asList(DefaultPeriodCleaner.class, DefaultPurgeTask.class, ProjectPurgePostJob.class); + public List<Class<? extends BatchExtension>> getExtensions() { + return ImmutableList.of( + DefaultPeriodCleaner.class, + DefaultPurgeTask.class, + ProjectPurgePostJob.class); } } diff --git a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/DbCleanerTestUtils.java b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/DbCleanerTestUtils.java index 9711b383533..3f7f7881077 100644 --- a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/DbCleanerTestUtils.java +++ b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/DbCleanerTestUtils.java @@ -24,9 +24,6 @@ import org.hamcrest.Description; import org.sonar.api.utils.DateUtils; import org.sonar.core.purge.PurgeableSnapshotDto; -import java.util.Date; -import java.util.GregorianCalendar; - public final class DbCleanerTestUtils { private DbCleanerTestUtils() { diff --git a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/api/PurgeUtilsTest.java b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/api/PurgeUtilsTest.java index 17317064d31..bea6ed413b6 100644 --- a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/api/PurgeUtilsTest.java +++ b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/api/PurgeUtilsTest.java @@ -19,30 +19,24 @@ */ package org.sonar.plugins.dbcleaner.api; +import com.google.common.collect.Lists; import org.apache.commons.configuration.PropertiesConfiguration; import org.junit.Test; import org.sonar.api.database.DatabaseSession; -import org.sonar.api.database.model.ResourceModel; -import org.sonar.api.database.model.Snapshot; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.Scopes; import org.sonar.jpa.test.AbstractDbUnitTestCase; -import com.google.common.collect.Lists; +import javax.persistence.Query; -import java.sql.SQLException; import java.util.Arrays; import java.util.List; -import javax.persistence.Query; - import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.*; +import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; public class PurgeUtilsTest extends AbstractDbUnitTestCase { @@ -59,7 +53,7 @@ public class PurgeUtilsTest extends AbstractDbUnitTestCase { } @Test - public void purgeSnapshots() throws SQLException { + public void purgeSnapshots() { setupData("purgeSnapshots"); PurgeUtils.deleteSnapshotsData(getSession(), Arrays.asList(3, 4)); @@ -75,7 +69,7 @@ public class PurgeUtilsTest extends AbstractDbUnitTestCase { when(session.createNativeQuery(anyString())).thenReturn(query); List<Integer> ids = Lists.newArrayList(); - for (int i = 0; i < PurgeUtils.MAX_IN_ELEMENTS + 1; i++) { + for (int i = 0; i < (PurgeUtils.MAX_IN_ELEMENTS + 1); i++) { ids.add(i); } diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/DesignPlugin.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/DesignPlugin.java index cb643053bfa..50805055b42 100644 --- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/DesignPlugin.java +++ b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/DesignPlugin.java @@ -19,8 +19,8 @@ */ package org.sonar.plugins.design; -import java.util.List; - +import com.google.common.collect.ImmutableList; +import org.sonar.api.Extension; import org.sonar.api.SonarPlugin; import org.sonar.plugins.design.batch.FileTangleIndexDecorator; import org.sonar.plugins.design.batch.MavenDependenciesSensor; @@ -34,29 +34,25 @@ import org.sonar.plugins.design.ui.widgets.ChidamberKemererWidget; import org.sonar.plugins.design.ui.widgets.FileDesignWidget; import org.sonar.plugins.design.ui.widgets.PackageDesignWidget; -import com.google.common.collect.Lists; +import java.util.List; public class DesignPlugin extends SonarPlugin { - @SuppressWarnings({"unchecked", "rawtypes"}) - public List getExtensions() { - List extensions = Lists.newArrayList(); - - // Batch - extensions.add(MavenDependenciesSensor.class); - extensions.add(ProjectDsmDecorator.class); - extensions.add(PackageTangleIndexDecorator.class); - extensions.add(FileTangleIndexDecorator.class); - extensions.add(SuspectLcom4DensityDecorator.class); - extensions.add(GwtLibrariesPage.class); - - // UI - extensions.add(GwtDesignPage.class); - extensions.add(DependenciesViewer.class); - extensions.add(FileDesignWidget.class); - extensions.add(PackageDesignWidget.class); - extensions.add(ChidamberKemererWidget.class); - - return extensions; + public List<Class<? extends Extension>> getExtensions() { + return ImmutableList.of( + // Batch + MavenDependenciesSensor.class, + ProjectDsmDecorator.class, + PackageTangleIndexDecorator.class, + FileTangleIndexDecorator.class, + SuspectLcom4DensityDecorator.class, + GwtLibrariesPage.class, + + // UI + GwtDesignPage.class, + DependenciesViewer.class, + FileDesignWidget.class, + PackageDesignWidget.class, + ChidamberKemererWidget.class); } } diff --git a/plugins/sonar-design-plugin/src/test/java/org/sonar/plugins/design/batch/DsmSerializerTest.java b/plugins/sonar-design-plugin/src/test/java/org/sonar/plugins/design/batch/DsmSerializerTest.java index a0a3b8a28fd..da8a1180289 100644 --- a/plugins/sonar-design-plugin/src/test/java/org/sonar/plugins/design/batch/DsmSerializerTest.java +++ b/plugins/sonar-design-plugin/src/test/java/org/sonar/plugins/design/batch/DsmSerializerTest.java @@ -35,7 +35,7 @@ import static org.junit.Assert.assertThat; public class DsmSerializerTest { @Test - public void serializeEmptyDsm() throws IOException { + public void serializeEmptyDsm() { Dsm dsm = new Dsm(new DirectedGraph()); assertThat(DsmSerializer.serialize(dsm), is("[]")); } @@ -51,7 +51,6 @@ public class DsmSerializerTest { graph.addVertex(bar); graph.addEdge(dep); - Dsm<Resource> dsm = new Dsm<Resource>(graph); DsmManualSorter.sort(dsm, bar, foo); // for test reproductibility String json = IOUtils.toString(getClass().getResourceAsStream("/org/sonar/plugins/design/batch/DsmSerializerTest/dsm.json")); diff --git a/plugins/sonar-email-notifications-plugin/src/main/java/org/sonar/plugins/emailnotifications/EmailNotificationsPlugin.java b/plugins/sonar-email-notifications-plugin/src/main/java/org/sonar/plugins/emailnotifications/EmailNotificationsPlugin.java index 9c8965c2366..49e7befdf79 100644 --- a/plugins/sonar-email-notifications-plugin/src/main/java/org/sonar/plugins/emailnotifications/EmailNotificationsPlugin.java +++ b/plugins/sonar-email-notifications-plugin/src/main/java/org/sonar/plugins/emailnotifications/EmailNotificationsPlugin.java @@ -19,20 +19,20 @@ */ package org.sonar.plugins.emailnotifications; -import java.util.Arrays; -import java.util.List; - +import com.google.common.collect.ImmutableList; +import org.sonar.api.ServerExtension; import org.sonar.api.SonarPlugin; import org.sonar.plugins.emailnotifications.newviolations.NewViolationsEmailTemplate; import org.sonar.plugins.emailnotifications.newviolations.NewViolationsOnMyFavouriteProject; import org.sonar.plugins.emailnotifications.reviews.ChangesInReviewAssignedToMeOrCreatedByMe; import org.sonar.plugins.emailnotifications.reviews.ReviewEmailTemplate; +import java.util.List; + public class EmailNotificationsPlugin extends SonarPlugin { - @SuppressWarnings({"rawtypes", "unchecked"}) - public List getExtensions() { - return Arrays.asList( + public List<Class<? extends ServerExtension>> getExtensions() { + return ImmutableList.of( EmailConfiguration.class, EmailNotificationChannel.class, diff --git a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsPlugin.java b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsPlugin.java index 070dfbee8bd..cb2da99ec37 100644 --- a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsPlugin.java +++ b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsPlugin.java @@ -19,10 +19,14 @@ */ package org.sonar.plugins.findbugs; -import org.sonar.api.*; +import com.google.common.collect.ImmutableList; +import org.sonar.api.CoreProperties; +import org.sonar.api.Extension; +import org.sonar.api.Properties; +import org.sonar.api.Property; import org.sonar.api.PropertyType; +import org.sonar.api.SonarPlugin; -import java.util.ArrayList; import java.util.List; @Properties({ @@ -53,15 +57,14 @@ import java.util.List; public class FindbugsPlugin extends SonarPlugin { public List<Class<? extends Extension>> getExtensions() { - List<Class<? extends Extension>> list = new ArrayList<Class<? extends Extension>>(); - list.add(FindbugsSensor.class); - list.add(FindbugsConfiguration.class); - list.add(FindbugsExecutor.class); - list.add(FindbugsRuleRepository.class); - list.add(FindbugsProfileExporter.class); - list.add(FindbugsProfileImporter.class); - list.add(SonarWayWithFindbugsProfile.class); - list.add(FindbugsMavenInitializer.class); - return list; + return ImmutableList.of( + FindbugsSensor.class, + FindbugsConfiguration.class, + FindbugsExecutor.class, + FindbugsRuleRepository.class, + FindbugsProfileExporter.class, + FindbugsProfileImporter.class, + SonarWayWithFindbugsProfile.class, + FindbugsMavenInitializer.class); } } diff --git a/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsProfileImporterTest.java b/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsProfileImporterTest.java index 90f9f121a9c..84d233f1e16 100644 --- a/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsProfileImporterTest.java +++ b/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsProfileImporterTest.java @@ -41,10 +41,10 @@ import static org.junit.Assert.assertThat; public class FindbugsProfileImporterTest { - private FindbugsProfileImporter importer = new FindbugsProfileImporter(new FakeRuleFinder()); + private final FindbugsProfileImporter importer = new FindbugsProfileImporter(new FakeRuleFinder()); @Test - public void shouldImportPatterns() throws IOException { + public void shouldImportPatterns() { String findbugsConf = TestUtils.getResourceContent("/org/sonar/plugins/findbugs/shouldImportPatterns.xml"); RulesProfile profile = importer.importProfile(new StringReader(findbugsConf), ValidationMessages.create()); @@ -54,7 +54,7 @@ public class FindbugsProfileImporterTest { } @Test - public void shouldImportCodes() throws IOException { + public void shouldImportCodes() { InputStream input = getClass().getResourceAsStream("/org/sonar/plugins/findbugs/shouldImportCodes.xml"); RulesProfile profile = importer.importProfile(new InputStreamReader(input), ValidationMessages.create()); List<ActiveRule> results = profile.getActiveRules(); @@ -65,7 +65,7 @@ public class FindbugsProfileImporterTest { } @Test - public void shouldImportCategories() throws IOException { + public void shouldImportCategories() { InputStream input = getClass().getResourceAsStream("/org/sonar/plugins/findbugs/shouldImportCategories.xml"); RulesProfile profile = importer.importProfile(new InputStreamReader(input), ValidationMessages.create()); List<ActiveRule> results = profile.getActiveRules(); @@ -75,7 +75,7 @@ public class FindbugsProfileImporterTest { } @Test - public void shouldImportConfigurationBugInclude() throws IOException { + public void shouldImportConfigurationBugInclude() { InputStream input = getClass().getResourceAsStream("/org/sonar/plugins/findbugs/findbugs-include.xml"); RulesProfile profile = importer.importProfile(new InputStreamReader(input), ValidationMessages.create()); List<ActiveRule> results = profile.getActiveRules(); @@ -98,7 +98,7 @@ public class FindbugsProfileImporterTest { } @Test - public void testImportingUncorrectXmlFile() throws IOException { + public void testImportingUncorrectXmlFile() { String uncorrectFindbugsXml = TestUtils.getResourceContent("/org/sonar/plugins/findbugs/uncorrectFindbugsXml.xml"); ValidationMessages messages = ValidationMessages.create(); RulesProfile profile = importer.importProfile(new StringReader(uncorrectFindbugsXml), messages); @@ -109,7 +109,7 @@ public class FindbugsProfileImporterTest { } @Test - public void testImportingXmlFileWithUnknownRule() throws IOException { + public void testImportingXmlFileWithUnknownRule() { String uncorrectFindbugsXml = TestUtils.getResourceContent("/org/sonar/plugins/findbugs/findbugsXmlWithUnknownRule.xml"); ValidationMessages messages = ValidationMessages.create(); RulesProfile profile = importer.importProfile(new StringReader(uncorrectFindbugsXml), messages); @@ -120,7 +120,7 @@ public class FindbugsProfileImporterTest { } @Test - public void testImportingXmlFileWithUnknownCategory() throws IOException { + public void testImportingXmlFileWithUnknownCategory() { String uncorrectFindbugsXml = TestUtils.getResourceContent("/org/sonar/plugins/findbugs/findbugsXmlWithUnknownCategory.xml"); ValidationMessages messages = ValidationMessages.create(); RulesProfile profile = importer.importProfile(new StringReader(uncorrectFindbugsXml), messages); @@ -131,7 +131,7 @@ public class FindbugsProfileImporterTest { } @Test - public void testImportingXmlFileWithUnknownCode() throws IOException { + public void testImportingXmlFileWithUnknownCode() { String uncorrectFindbugsXml = TestUtils.getResourceContent("/org/sonar/plugins/findbugs/findbugsXmlWithUnknownCode.xml"); ValidationMessages messages = ValidationMessages.create(); RulesProfile profile = importer.importProfile(new StringReader(uncorrectFindbugsXml), messages); diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoPlugin.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoPlugin.java index fae29ce55ef..8fd1e6c5cbd 100644 --- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoPlugin.java +++ b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoPlugin.java @@ -19,15 +19,16 @@ */ package org.sonar.plugins.jacoco; +import com.google.common.collect.ImmutableList; +import org.sonar.api.BatchExtension; import org.sonar.api.SonarPlugin; -import java.util.Arrays; import java.util.List; public class JaCoCoPlugin extends SonarPlugin { - public List getExtensions() { - return Arrays.asList( + public List<Class<? extends BatchExtension>> getExtensions() { + return ImmutableList.of( JacocoConfiguration.class, JaCoCoAgentDownloader.class, // Ant diff --git a/plugins/sonar-l10n-en-plugin/src/main/java/org/sonar/plugins/l10n/EnglishPackPlugin.java b/plugins/sonar-l10n-en-plugin/src/main/java/org/sonar/plugins/l10n/EnglishPackPlugin.java index c9040a80feb..19e8bb2262e 100644 --- a/plugins/sonar-l10n-en-plugin/src/main/java/org/sonar/plugins/l10n/EnglishPackPlugin.java +++ b/plugins/sonar-l10n-en-plugin/src/main/java/org/sonar/plugins/l10n/EnglishPackPlugin.java @@ -19,6 +19,8 @@ */ package org.sonar.plugins.l10n; +import org.sonar.api.Extension; + import org.sonar.api.SonarPlugin; import java.util.Collections; @@ -26,7 +28,7 @@ import java.util.List; public final class EnglishPackPlugin extends SonarPlugin { - public List getExtensions() { + public List<Class<? extends Extension>> getExtensions() { return Collections.emptyList(); } } diff --git a/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdExecutor.java b/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdExecutor.java index 1dbc6a4901e..0f485f897ef 100644 --- a/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdExecutor.java +++ b/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdExecutor.java @@ -19,7 +19,13 @@ */ package org.sonar.plugins.pmd; -import net.sourceforge.pmd.*; +import net.sourceforge.pmd.PMD; +import net.sourceforge.pmd.PMDException; +import net.sourceforge.pmd.Report; +import net.sourceforge.pmd.RuleContext; +import net.sourceforge.pmd.RuleSetFactory; +import net.sourceforge.pmd.RuleSets; +import net.sourceforge.pmd.SourceType; import net.sourceforge.pmd.renderers.Renderer; import net.sourceforge.pmd.renderers.XMLRenderer; import org.apache.commons.io.FileUtils; @@ -34,22 +40,30 @@ import org.sonar.api.utils.SonarException; import org.sonar.api.utils.TimeProfiler; import org.sonar.java.api.JavaUtils; -import java.io.*; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.io.StringWriter; +import java.io.Writer; import java.util.List; public class PmdExecutor implements BatchExtension { private static final Logger LOG = LoggerFactory.getLogger(PmdExecutor.class); - private PmdConfiguration configuration; - private Project project; + private final PmdConfiguration configuration; + private final Project project; public PmdExecutor(Project project, PmdConfiguration configuration) { this.project = project; this.configuration = configuration; } - public Report execute() throws IOException, PMDException { + public Report execute() throws IOException { TimeProfiler profiler = new TimeProfiler().start("Execute PMD " + PmdVersion.getVersion()); ClassLoader initialClassLoader = Thread.currentThread().getContextClassLoader(); diff --git a/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdPlugin.java b/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdPlugin.java index abf8dda0442..dff7b9f85bc 100644 --- a/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdPlugin.java +++ b/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdPlugin.java @@ -19,15 +19,16 @@ */ package org.sonar.plugins.pmd; +import com.google.common.collect.ImmutableList; +import org.sonar.api.Extension; import org.sonar.api.SonarPlugin; -import java.util.Arrays; import java.util.List; public class PmdPlugin extends SonarPlugin { - public List getExtensions() { - return Arrays.asList( + public List<Class<? extends Extension>> getExtensions() { + return ImmutableList.of( PmdSensor.class, PmdConfiguration.class, PmdExecutor.class, @@ -38,6 +39,6 @@ public class PmdPlugin extends SonarPlugin { SonarWayWithFindbugsProfile.class, SunConventionsProfile.class, JavaCpdMapping.class - ); + ); } } diff --git a/plugins/sonar-pmd-plugin/src/test/java/org/sonar/plugins/pmd/PmdExecutorTest.java b/plugins/sonar-pmd-plugin/src/test/java/org/sonar/plugins/pmd/PmdExecutorTest.java index dd9feab2cd9..a45a7426075 100644 --- a/plugins/sonar-pmd-plugin/src/test/java/org/sonar/plugins/pmd/PmdExecutorTest.java +++ b/plugins/sonar-pmd-plugin/src/test/java/org/sonar/plugins/pmd/PmdExecutorTest.java @@ -19,7 +19,7 @@ */ package org.sonar.plugins.pmd; -import net.sourceforge.pmd.PMDException; +import com.google.common.base.Charsets; import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; import org.junit.Rule; @@ -31,8 +31,6 @@ import org.sonar.api.resources.ProjectFileSystem; import java.io.File; import java.io.IOException; -import java.net.URISyntaxException; -import java.nio.charset.Charset; import java.util.Arrays; import static org.hamcrest.Matchers.nullValue; @@ -48,14 +46,14 @@ public class PmdExecutorTest { public TemporaryFolder temp = new TemporaryFolder(); @Test - public void executeOnManySourceDirs() throws URISyntaxException, IOException, PMDException { - final File workDir = temp.getRoot(); + public void executeOnManySourceDirs() throws IOException { + File workDir = temp.getRoot(); Project project = new Project("two-source-dirs"); ProjectFileSystem fs = mock(ProjectFileSystem.class); File root = new File(getClass().getResource("/org/sonar/plugins/pmd/PmdExecutorTest/executeOnManySourceDirs/").toURI()); when(fs.getSourceFiles(Java.INSTANCE)).thenReturn(Arrays.asList(new File(root, "src1/FirstClass.java"), new File(root, "src2/SecondClass.java"))); - when(fs.getSourceCharset()).thenReturn(Charset.forName("UTF-8")); + when(fs.getSourceCharset()).thenReturn(Charsets.UTF_8); when(fs.getSonarWorkingDirectory()).thenReturn(workDir); project.setFileSystem(fs); @@ -77,13 +75,13 @@ public class PmdExecutorTest { } @Test - public void ignorePmdFailures() throws URISyntaxException, IOException, PMDException { + public void ignorePmdFailures() throws IOException { final File workDir = temp.getRoot(); Project project = new Project("ignorePmdFailures"); ProjectFileSystem fs = mock(ProjectFileSystem.class); when(fs.getSourceFiles(Java.INSTANCE)).thenReturn(Arrays.asList(new File("test-resources/ignorePmdFailures/DoesNotCompile.java"))); - when(fs.getSourceCharset()).thenReturn(Charset.forName("UTF-8")); + when(fs.getSourceCharset()).thenReturn(Charsets.UTF_8); when(fs.getSonarWorkingDirectory()).thenReturn(workDir); project.setFileSystem(fs); diff --git a/plugins/sonar-pmd-plugin/src/test/java/org/sonar/plugins/pmd/PmdProfileExporterTest.java b/plugins/sonar-pmd-plugin/src/test/java/org/sonar/plugins/pmd/PmdProfileExporterTest.java index fcbbc68033d..7dac4cc592e 100644 --- a/plugins/sonar-pmd-plugin/src/test/java/org/sonar/plugins/pmd/PmdProfileExporterTest.java +++ b/plugins/sonar-pmd-plugin/src/test/java/org/sonar/plugins/pmd/PmdProfileExporterTest.java @@ -19,11 +19,6 @@ */ package org.sonar.plugins.pmd; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.mock; - import org.apache.commons.io.IOUtils; import org.apache.commons.io.input.CharSequenceReader; import org.apache.commons.lang.StringUtils; @@ -32,27 +27,34 @@ import org.hamcrest.TypeSafeMatcher; import org.junit.Test; import org.sonar.api.platform.ServerFileSystem; import org.sonar.api.profiles.RulesProfile; -import org.sonar.api.rules.*; +import org.sonar.api.rules.ActiveRule; +import org.sonar.api.rules.Rule; +import org.sonar.api.rules.RuleFinder; +import org.sonar.api.rules.RuleQuery; +import org.sonar.api.rules.XMLRuleParser; import org.sonar.api.utils.SonarException; import org.sonar.api.utils.ValidationMessages; import org.sonar.plugins.pmd.xml.PmdProperty; import org.sonar.plugins.pmd.xml.PmdRule; import org.sonar.test.TestUtils; -import org.xml.sax.SAXException; -import java.io.IOException; import java.io.Reader; import java.io.StringReader; import java.io.StringWriter; import java.util.Collection; import java.util.List; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.nullValue; +import static org.junit.Assert.assertThat; +import static org.mockito.Mockito.mock; + public class PmdProfileExporterTest { - private PmdProfileExporter exporter = new PmdProfileExporter(); + private final PmdProfileExporter exporter = new PmdProfileExporter(); @Test - public void testExportProfile() throws IOException, SAXException { + public void testExportProfile() { ServerFileSystem fileSystem = mock(ServerFileSystem.class); PmdRuleRepository repository = new PmdRuleRepository(fileSystem, new XMLRuleParser()); List<Rule> rules = repository.createRules(); @@ -84,7 +86,7 @@ public class PmdProfileExporterTest { } private static class IsEqualIgnoringEOL extends TypeSafeMatcher<CharSequence> { - private String expected; + private final String expected; public IsEqualIgnoringEOL(CharSequence expected) { this.expected = normalize(expected); @@ -148,7 +150,7 @@ public class PmdProfileExporterTest { private static class FakeRuleFinder implements RuleFinder { - private List<Rule> rules; + private final List<Rule> rules; public FakeRuleFinder(List<Rule> rules) { this.rules = rules; diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/SquidPlugin.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/SquidPlugin.java index 789c0c0d1cf..e67b02d531e 100644 --- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/SquidPlugin.java +++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/SquidPlugin.java @@ -19,10 +19,19 @@ */ package org.sonar.plugins.squid; -import org.sonar.api.*; -import org.sonar.plugins.squid.decorators.*; +import com.google.common.collect.ImmutableList; +import org.sonar.api.CoreProperties; +import org.sonar.api.Extension; +import org.sonar.api.Properties; +import org.sonar.api.Property; +import org.sonar.api.PropertyType; +import org.sonar.api.SonarPlugin; +import org.sonar.plugins.squid.decorators.ChidamberKemererDistributionBuilder; +import org.sonar.plugins.squid.decorators.ClassesDecorator; +import org.sonar.plugins.squid.decorators.FileComplexityDistributionDecorator; +import org.sonar.plugins.squid.decorators.FunctionComplexityDistributionBuilder; +import org.sonar.plugins.squid.decorators.FunctionsDecorator; -import java.util.Arrays; import java.util.List; @Properties({ @@ -56,8 +65,8 @@ import java.util.List; }) public final class SquidPlugin extends SonarPlugin { - public List getExtensions() { - return Arrays.asList( + public List<Class<? extends Extension>> getExtensions() { + return ImmutableList.of( SquidSensor.class, SquidRuleRepository.class, JavaSourceImporter.class, diff --git a/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/ast/JavaAstScannerTest.java b/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/ast/JavaAstScannerTest.java index 9022282aeba..4acbe703fe6 100644 --- a/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/ast/JavaAstScannerTest.java +++ b/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/ast/JavaAstScannerTest.java @@ -19,14 +19,7 @@ */ package org.sonar.java.ast; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -import java.io.UnsupportedEncodingException; -import java.nio.charset.Charset; - -import org.apache.commons.lang.CharEncoding; +import com.google.common.base.Charsets; import org.junit.Before; import org.junit.Test; import org.sonar.java.squid.JavaSquidConfiguration; @@ -35,12 +28,18 @@ import org.sonar.squid.api.AnalysisException; import org.sonar.squid.api.SourceProject; import org.sonar.squid.measures.Metric; +import java.nio.charset.Charset; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + public class JavaAstScannerTest { private Squid squid; @Before - public void setup() throws UnsupportedEncodingException { + public void setup() { squid = new Squid(new JavaSquidConfiguration(false, Charset.defaultCharset(), 0.9)); } @@ -96,8 +95,8 @@ public class JavaAstScannerTest { assertEquals(1, prj.getInt(Metric.FILES)); assertEquals(1, prj.getInt(Metric.COMMENT_LINES)); - assertNotNull(squid.search("ClassWithOnlyComment.java"));//file - assertNull(squid.search("ClassWithOnlyComment"));//class + assertNotNull(squid.search("ClassWithOnlyComment.java"));// file + assertNull(squid.search("ClassWithOnlyComment"));// class } @Test @@ -125,7 +124,7 @@ public class JavaAstScannerTest { try { System.setProperty("file.encoding", "UTF-16"); Charset defaultEncoding = Charset.defaultCharset(); - if ( !defaultEncoding.displayName().equals("UTF-16")) { + if (!defaultEncoding.displayName().equals("UTF-16")) { return; } System.setProperty("file.encoding", "MacRoman"); @@ -153,7 +152,7 @@ public class JavaAstScannerTest { @Test public void testUTF8Encoding() { - squid = new Squid(new JavaSquidConfiguration(false, Charset.forName(CharEncoding.UTF_8))); + squid = new Squid(new JavaSquidConfiguration(false, Charsets.UTF_8)); squid.register(JavaAstScanner.class).scanFile(SquidTestUtils.getInputFile("/special_cases/encoding/Utf8Encoding.java")); SourceProject prj = squid.aggregate(); assertEquals(4, prj.getInt(Metric.METHODS)); diff --git a/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/ast/visitor/FileVisitorTest.java b/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/ast/visitor/FileVisitorTest.java index 08f7e4086f5..3ae79a74757 100644 --- a/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/ast/visitor/FileVisitorTest.java +++ b/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/ast/visitor/FileVisitorTest.java @@ -22,8 +22,6 @@ package org.sonar.java.ast.visitor; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import java.io.File; -import java.util.ArrayList; import java.util.List; import com.google.common.collect.Lists; diff --git a/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/ast/visitor/PackageVisitorTest.java b/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/ast/visitor/PackageVisitorTest.java index cf02869229d..f6c156a508d 100644 --- a/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/ast/visitor/PackageVisitorTest.java +++ b/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/ast/visitor/PackageVisitorTest.java @@ -20,7 +20,6 @@ package org.sonar.java.ast.visitor; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.sonar.java.ast.JavaAstScanner; import org.sonar.java.ast.SquidTestUtils; diff --git a/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/plugins/squid/JavaSourceImporterTest.java b/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/plugins/squid/JavaSourceImporterTest.java index 0cd45d4e473..ecc445843b0 100644 --- a/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/plugins/squid/JavaSourceImporterTest.java +++ b/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/plugins/squid/JavaSourceImporterTest.java @@ -19,17 +19,6 @@ */ package org.sonar.plugins.squid; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.io.File; -import java.io.IOException; -import java.nio.charset.Charset; - import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -40,6 +29,16 @@ import org.sonar.api.resources.InputFile; import org.sonar.api.resources.JavaFile; import org.sonar.api.utils.SonarException; +import java.io.File; +import java.nio.charset.Charset; + +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + public class JavaSourceImporterTest { @Rule @@ -61,7 +60,7 @@ public class JavaSourceImporterTest { } @Test - public void shouldSetSource() throws IOException { + public void shouldSetSource() { JavaFile javaFile = JavaFile.fromRelativePath("UndocumentedApi.java", true); when(context.isIndexed(javaFile, true)).thenReturn(true); importer.importSource(context, javaFile, inputFile, Charset.defaultCharset()); diff --git a/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/plugins/squid/SquidExecutorTest.java b/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/plugins/squid/SquidExecutorTest.java index 2bbbf210a66..0430ebf4c53 100644 --- a/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/plugins/squid/SquidExecutorTest.java +++ b/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/plugins/squid/SquidExecutorTest.java @@ -19,18 +19,6 @@ */ package org.sonar.plugins.squid; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.number.OrderingComparisons.greaterThan; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.anyDouble; -import static org.mockito.Matchers.anyObject; -import static org.mockito.Mockito.atLeast; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; - import org.junit.Test; import org.sonar.api.batch.SensorContext; import org.sonar.api.checks.AnnotationCheckFactory; @@ -39,7 +27,6 @@ import org.sonar.api.profiles.RulesProfile; import org.sonar.api.resources.InputFile; import org.sonar.api.resources.Project; import org.sonar.api.resources.Resource; -import org.sonar.squid.Squid; import org.sonar.squid.measures.Metric; import java.io.File; @@ -49,6 +36,18 @@ import java.nio.charset.Charset; import java.util.Arrays; import java.util.Collections; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.number.OrderingComparisons.greaterThan; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; +import static org.mockito.Matchers.anyDouble; +import static org.mockito.Matchers.anyObject; +import static org.mockito.Mockito.atLeast; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyZeroInteractions; + public class SquidExecutorTest { @Test @@ -61,7 +60,7 @@ public class SquidExecutorTest { } @Test - public void doNotScanBytecodeIfNoSources() throws IOException, URISyntaxException { + public void doNotScanBytecodeIfNoSources() throws URISyntaxException { SquidExecutor executor = new SquidExecutor(true, "LOG, logger", createCheckFactory(), Charset.defaultCharset()); executor.scan(Collections.<InputFile> emptyList(), Arrays.asList(SquidTestUtils.getStrutsCoreJar())); @@ -106,7 +105,7 @@ public class SquidExecutorTest { @Test public void shouldNotHaveBytecode() { - assertFalse(SquidExecutor.hasBytecode(Collections.<File>emptyList())); + assertFalse(SquidExecutor.hasBytecode(Collections.<File> emptyList())); assertFalse(SquidExecutor.hasBytecode(Arrays.asList(new File("unknown")))); } diff --git a/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/plugins/squid/SquidTestUtils.java b/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/plugins/squid/SquidTestUtils.java index a2c6072c4a3..06279dd4d83 100644 --- a/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/plugins/squid/SquidTestUtils.java +++ b/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/plugins/squid/SquidTestUtils.java @@ -39,11 +39,11 @@ public final class SquidTestUtils { */ public static Collection<InputFile> getStrutsCoreSources() throws IOException, URISyntaxException { File sourceDir = new File("target/struts-core-1.3.9-sources"); - if (!sourceDir.exists() || sourceDir.list().length==0) { + if (!sourceDir.exists() || (sourceDir.list().length == 0)) { FileUtils.forceMkdir(sourceDir); ZipUtils.unzip(new File(SquidTestUtils.class.getResource("/struts-core-1.3.9-sources.jar").toURI()), sourceDir); } - Collection<File> javaFiles = FileUtils.listFiles(sourceDir, new String[]{"java"}, true); + Collection<File> javaFiles = FileUtils.listFiles(sourceDir, new String[] {"java"}, true); return InputFileUtils.create(sourceDir, javaFiles); } @@ -51,7 +51,7 @@ public final class SquidTestUtils { /** * See http://svn.apache.org/repos/asf/struts/struts1/tags/STRUTS_1_3_9/core */ - public static File getStrutsCoreJar() throws IOException, URISyntaxException { + public static File getStrutsCoreJar() throws URISyntaxException { return new File(SquidTestUtils.class.getResource("/struts-core-1.3.9.jar").toURI()); } } diff --git a/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/plugins/squid/bridges/BridgeTestCase.java b/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/plugins/squid/bridges/BridgeTestCase.java index 0820183a79a..6c8957cb287 100644 --- a/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/plugins/squid/bridges/BridgeTestCase.java +++ b/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/plugins/squid/bridges/BridgeTestCase.java @@ -19,10 +19,7 @@ */ package org.sonar.plugins.squid.bridges; -import static org.mockito.Matchers.anyObject; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - +import com.google.common.base.Charsets; import org.junit.Before; import org.junit.BeforeClass; import org.mockito.invocation.InvocationOnMock; @@ -38,10 +35,13 @@ import org.sonar.plugins.squid.SquidTestUtils; import java.io.IOException; import java.net.URISyntaxException; -import java.nio.charset.Charset; import java.util.Arrays; import java.util.Collections; +import static org.mockito.Matchers.anyObject; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + public abstract class BridgeTestCase { protected SensorContext context; @@ -52,7 +52,7 @@ public abstract class BridgeTestCase { public static void scanStruts() throws IOException, URISyntaxException { RulesProfile profile = RulesProfile.create(); CheckFactory checkFactory = AnnotationCheckFactory.create(profile, "repo", Collections.<Class> emptyList()); - executor = new SquidExecutor(true, "LOG, logger", checkFactory, Charset.forName("UTF8")); + executor = new SquidExecutor(true, "LOG, logger", checkFactory, Charsets.UTF_8); executor.scan(SquidTestUtils.getStrutsCoreSources(), Arrays.asList(SquidTestUtils.getStrutsCoreJar())); project = new Project("project"); } diff --git a/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/plugins/squid/bridges/ChidamberKemererBridgeTest.java b/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/plugins/squid/bridges/ChidamberKemererBridgeTest.java index 966ba8391a3..dd7fb7fc54f 100644 --- a/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/plugins/squid/bridges/ChidamberKemererBridgeTest.java +++ b/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/plugins/squid/bridges/ChidamberKemererBridgeTest.java @@ -31,7 +31,6 @@ import org.sonar.api.resources.JavaFile; import org.sonar.api.resources.JavaPackage; import org.sonar.squid.api.SourceFile; import org.sonar.squid.measures.Metric; -import org.sonar.squid.measures.MetricDef; public class ChidamberKemererBridgeTest extends BridgeTestCase { diff --git a/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/plugins/squid/bridges/DsmSerializerTest.java b/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/plugins/squid/bridges/DsmSerializerTest.java index 9c1c1f8f2b1..f6d2d102b74 100644 --- a/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/plugins/squid/bridges/DsmSerializerTest.java +++ b/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/plugins/squid/bridges/DsmSerializerTest.java @@ -24,13 +24,13 @@ import org.junit.Test; import org.sonar.api.design.Dependency; import org.sonar.api.resources.JavaPackage; import org.sonar.api.resources.Resource; +import org.sonar.graph.DirectedGraph; +import org.sonar.graph.Dsm; +import org.sonar.graph.DsmManualSorter; import org.sonar.squid.api.SourceCode; import org.sonar.squid.api.SourceCodeEdge; import org.sonar.squid.api.SourceCodeEdgeUsage; import org.sonar.squid.api.SourcePackage; -import org.sonar.graph.DirectedGraph; -import org.sonar.graph.Dsm; -import org.sonar.graph.DsmManualSorter; import java.io.IOException; @@ -40,7 +40,7 @@ import static org.junit.Assert.assertThat; public class DsmSerializerTest { @Test - public void serializeEmptyDsm() throws IOException { + public void serializeEmptyDsm() { Dsm dsm = new Dsm(new DirectedGraph()); assertThat(DsmSerializer.serialize(dsm, new DependencyIndex(), new ResourceIndex()), is("[]")); } @@ -76,7 +76,6 @@ public class DsmSerializerTest { resourceIndex.put(foo, fooSonar); resourceIndex.put(bar, barSonar); - Dsm<SourceCode> dsm = new Dsm<SourceCode>(graph); DsmManualSorter.sort(dsm, bar, foo); // for test reproductibility String json = IOUtils.toString(getClass().getResourceAsStream("/org/sonar/plugins/squid/bridges/DsmSerializerTest/dsm.json")); diff --git a/plugins/sonar-surefire-plugin/src/main/java/org/sonar/plugins/surefire/SurefirePlugin.java b/plugins/sonar-surefire-plugin/src/main/java/org/sonar/plugins/surefire/SurefirePlugin.java index c076e954fb0..b4eb8cc5e5d 100644 --- a/plugins/sonar-surefire-plugin/src/main/java/org/sonar/plugins/surefire/SurefirePlugin.java +++ b/plugins/sonar-surefire-plugin/src/main/java/org/sonar/plugins/surefire/SurefirePlugin.java @@ -19,26 +19,26 @@ */ package org.sonar.plugins.surefire; +import com.google.common.collect.ImmutableList; import org.sonar.api.CoreProperties; import org.sonar.api.Properties; import org.sonar.api.Property; import org.sonar.api.SonarPlugin; -import java.util.Arrays; import java.util.List; @Properties({ - @Property( - key = CoreProperties.SUREFIRE_REPORTS_PATH_PROPERTY, - name = "Report path", - description = "Path (absolute or relative) to XML report files.", - project = true, - global = false) + @Property( + key = CoreProperties.SUREFIRE_REPORTS_PATH_PROPERTY, + name = "Report path", + description = "Path (absolute or relative) to XML report files.", + project = true, + global = false) }) public final class SurefirePlugin extends SonarPlugin { - public List getExtensions() { - return Arrays.asList(SurefireSensor.class); + public List<Class<SurefireSensor>> getExtensions() { + return ImmutableList.of(SurefireSensor.class); } } diff --git a/plugins/sonar-surefire-plugin/src/test/java/org/sonar/plugins/surefire/data/SurefireStaxHandlerTest.java b/plugins/sonar-surefire-plugin/src/test/java/org/sonar/plugins/surefire/data/SurefireStaxHandlerTest.java index 8cdbe6cf062..e99590d2712 100644 --- a/plugins/sonar-surefire-plugin/src/test/java/org/sonar/plugins/surefire/data/SurefireStaxHandlerTest.java +++ b/plugins/sonar-surefire-plugin/src/test/java/org/sonar/plugins/surefire/data/SurefireStaxHandlerTest.java @@ -21,8 +21,6 @@ package org.sonar.plugins.surefire.data; import org.junit.Before; import org.junit.Test; -import org.sonar.api.measures.CoreMetrics; -import org.sonar.api.resources.JavaFile; import org.sonar.api.utils.StaxParser; import org.sonar.test.TestUtils; @@ -32,8 +30,6 @@ import java.io.File; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.Matchers.startsWith; import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.verify; public class SurefireStaxHandlerTest { |