diff options
author | Godin <mandrikov@gmail.com> | 2010-12-06 16:23:59 +0000 |
---|---|---|
committer | Godin <mandrikov@gmail.com> | 2010-12-06 16:23:59 +0000 |
commit | 826316807d7bb114d8b6399986e276cfc77c6514 (patch) | |
tree | 5a8de056d5377c766973cb5c4ba2a5c12fbe8fd7 /plugins/sonar-checkstyle-plugin | |
parent | 2728a4dacdd779e797ef4ef0f26d17db7c0adb0a (diff) | |
download | sonarqube-826316807d7bb114d8b6399986e276cfc77c6514.tar.gz sonarqube-826316807d7bb114d8b6399986e276cfc77c6514.zip |
SONAR-2031: Remove the feature "reuse configuration" of the plugins Checkstyle and PMD
Diffstat (limited to 'plugins/sonar-checkstyle-plugin')
4 files changed, 9 insertions, 55 deletions
diff --git a/plugins/sonar-checkstyle-plugin/pom.xml b/plugins/sonar-checkstyle-plugin/pom.xml index 26cb84c0fb4..519b7cf5e88 100644 --- a/plugins/sonar-checkstyle-plugin/pom.xml +++ b/plugins/sonar-checkstyle-plugin/pom.xml @@ -47,12 +47,14 @@ </dependency> <!-- TODO http://jira.codehaus.org/browse/SONAR-2011 - We need following dependency, otherwise we will receive compilation error + We need following dependency, otherwise we will receive + java.lang.NoClassDefFoundError: org/apache/maven/project/MavenProject + during call mock(org.sonar.api.resources.Project.class) --> <dependency> <groupId>org.apache.maven</groupId> <artifactId>maven-project</artifactId> - <scope>provided</scope> + <scope>test</scope> </dependency> <dependency> 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 62a111bd082..b33b0be8ece 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 @@ -29,8 +29,6 @@ import org.apache.commons.lang.CharEncoding; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sonar.api.BatchExtension; -import org.sonar.api.batch.maven.MavenPlugin; -import org.sonar.api.batch.maven.MavenUtils; import org.sonar.api.profiles.RulesProfile; import org.sonar.api.resources.Java; import org.sonar.api.resources.Project; @@ -56,11 +54,6 @@ public class CheckstyleConfiguration implements BatchExtension { } public File getXMLDefinitionFile() { - if (project.getReuseExistingRulesConfig()) { - LOG.warn("Reusing existing Checkstyle configuration is deprecated as it's unstable and can not provide meaningful results. This feature will be removed soon."); - return findExistingXML(); - } - Writer writer = null; File xmlFile = new File(project.getFileSystem().getSonarWorkingDirectory(), "checkstyle.xml"); try { @@ -77,24 +70,6 @@ public class CheckstyleConfiguration implements BatchExtension { } } - private File findExistingXML() { - File file = null; - MavenPlugin mavenPlugin = MavenPlugin.getPlugin(project.getPom(), MavenUtils.GROUP_ID_APACHE_MAVEN, "maven-checkstyle-plugin"); - if (mavenPlugin != null) { - String location = mavenPlugin.getParameter("configLocation"); - if (location != null) { - file = new File(location); - if (!file.exists()) { - file = new File(project.getFileSystem().getBasedir(), location); - } - } - } - if (file == null || !file.isFile() || !file.exists()) { - throw new SonarException("The checkstyle configuration file does not exist: " + file); - } - return file; - } - public List<File> getSourceFiles() { return project.getFileSystem().getSourceFiles(Java.INSTANCE); } @@ -119,7 +94,6 @@ public class CheckstyleConfiguration implements BatchExtension { return ConfigurationLoader.loadConfiguration(xmlConfig.getAbsolutePath(), new PropertiesExpander(new Properties())); } - private void defineCharset(Configuration configuration) { Configuration[] modules = configuration.getChildren(); for (Configuration module : modules) { diff --git a/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleSensor.java b/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleSensor.java index d3d15d98615..3cd042564eb 100644 --- a/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleSensor.java +++ b/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleSensor.java @@ -23,6 +23,7 @@ import org.sonar.api.batch.Sensor; import org.sonar.api.batch.SensorContext; import org.sonar.api.profiles.RulesProfile; import org.sonar.api.resources.Project; +import org.sonar.api.utils.Logs; public class CheckstyleSensor implements Sensor { @@ -40,6 +41,9 @@ public class CheckstyleSensor implements Sensor { } public void analyse(Project project, SensorContext context) { + if (project.getReuseExistingRulesConfig()) { + Logs.INFO.warn("Reusing existing Checkstyle configuration is not supported any more."); + } executor.execute(); } @@ -47,4 +51,4 @@ public class CheckstyleSensor implements Sensor { public String toString() { return getClass().getSimpleName(); } -}
\ No newline at end of file +} 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 85b74b46631..4bd33ebd1b2 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.mockito.Mockito; import org.sonar.api.profiles.RulesProfile; import org.sonar.api.resources.Project; import org.sonar.api.test.MavenTestUtils; @@ -32,8 +31,6 @@ import java.io.Writer; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.anyObject; -import static org.mockito.Mockito.mock; public class CheckstyleConfigurationTest { @@ -49,29 +46,6 @@ public class CheckstyleConfigurationTest { assertThat(FileUtils.readFileToString(xmlFile), is("<conf/>")); } - @Test - public void findConfigurationToReuse() throws IOException { - Project project = MavenTestUtils.loadProjectFromPom(getClass(), "findConfigurationToReuse/pom.xml"); - - CheckstyleProfileExporter exporter = mock(CheckstyleProfileExporter.class); - Mockito.doThrow(new RuntimeException()).when(exporter).exportProfile((RulesProfile)anyObject(), (Writer)anyObject()); - CheckstyleConfiguration configuration = new CheckstyleConfiguration(exporter, null, project); - - File xmlFile = configuration.getXMLDefinitionFile(); - assertThat(xmlFile.exists(), is(true)); - assertThat(FileUtils.readFileToString(xmlFile), is("<ondisk/>")); - } - - @Test(expected=RuntimeException.class) - public void failIfConfigurationToReuseDoesNotExist() throws IOException { - Project project = MavenTestUtils.loadProjectFromPom(getClass(), "failIfConfigurationToReuseDoesNotExist/pom.xml"); - - CheckstyleProfileExporter exporter = mock(CheckstyleProfileExporter.class); - Mockito.doThrow(new RuntimeException()).when(exporter).exportProfile((RulesProfile)anyObject(), (Writer)anyObject()); - CheckstyleConfiguration configuration = new CheckstyleConfiguration(exporter, null, project); - configuration.getXMLDefinitionFile(); - } - public class FakeExporter extends CheckstyleProfileExporter { @Override public void exportProfile(RulesProfile profile, Writer writer) { |