summaryrefslogtreecommitdiffstats
path: root/plugins/sonar-findbugs-plugin
diff options
context:
space:
mode:
authorGodin <mandrikov@gmail.com>2010-10-21 17:02:54 +0000
committerGodin <mandrikov@gmail.com>2010-10-21 17:02:54 +0000
commitcedf8b42afe0bd27b125a80624b72f726fdf3df4 (patch)
tree1be8d85dcb32284b00ceb9ba0307efd54d46bfad /plugins/sonar-findbugs-plugin
parentec338d6e49b8aa9b4f53237cbf4d598ca87a8db9 (diff)
downloadsonarqube-cedf8b42afe0bd27b125a80624b72f726fdf3df4.tar.gz
sonarqube-cedf8b42afe0bd27b125a80624b72f726fdf3df4.zip
SONAR-1772: Don't allow to reuse existing rules config for findbugs
Diffstat (limited to 'plugins/sonar-findbugs-plugin')
-rw-r--r--plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsConfiguration.java17
-rw-r--r--plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsNativeSensor.java4
-rw-r--r--plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsConfigurationTest.java34
3 files changed, 4 insertions, 51 deletions
diff --git a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsConfiguration.java b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsConfiguration.java
index 95e30fe637e..dd2321c5fb7 100644
--- a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsConfiguration.java
+++ b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsConfiguration.java
@@ -8,7 +8,6 @@ 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.Project;
-import org.sonar.api.utils.Logs;
import org.sonar.api.utils.SonarException;
import org.sonar.plugins.findbugs.xml.ClassFilter;
import org.sonar.plugins.findbugs.xml.FindBugsFilter;
@@ -43,10 +42,6 @@ public class FindbugsConfiguration implements BatchExtension {
}
public edu.umd.cs.findbugs.Project getFindbugsProject() {
- if (project.getReuseExistingRulesConfig()) {
- Logs.INFO.warn("Reusing existing Findbugs configuration is deprecated as it's unstable and can not provide meaningful results. This feature will be removed soon.");
- }
-
File classesDir = project.getFileSystem().getBuildOutputDir();
if (classesDir == null || !classesDir.exists()) {
throw new SonarException("Findbugs needs sources to be compiled. "
@@ -72,24 +67,12 @@ public class FindbugsConfiguration implements BatchExtension {
}
public File saveIncludeConfigXml() throws IOException {
- if (project.getReuseExistingRulesConfig()) {
- String existingIncludeFilterConfig = getFindbugsMavenPlugin().getParameter("includeFilterFile");
- if ( !StringUtils.isBlank(existingIncludeFilterConfig)) {
- return new File(project.getFileSystem().getBasedir(), existingIncludeFilterConfig);
- }
- }
StringWriter conf = new StringWriter();
exporter.exportProfile(profile, conf);
return project.getFileSystem().writeToWorkingDirectory(conf.toString(), "findbugs-include.xml");
}
public File saveExcludeConfigXml() throws IOException {
- if (project.getReuseExistingRulesConfig()) {
- String existingExcludeFilterConfig = getFindbugsMavenPlugin().getParameter("excludeFilterFile");
- if ( !StringUtils.isBlank(existingExcludeFilterConfig)) {
- return new File(project.getFileSystem().getBasedir(), existingExcludeFilterConfig);
- }
- }
FindBugsFilter findBugsFilter = new FindBugsFilter();
if (project.getExclusionPatterns() != null) {
for (String exclusion : project.getExclusionPatterns()) {
diff --git a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsNativeSensor.java b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsNativeSensor.java
index 08e9dcc865e..b6efd0131da 100644
--- a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsNativeSensor.java
+++ b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsNativeSensor.java
@@ -10,6 +10,7 @@ import org.sonar.api.resources.Project;
import org.sonar.api.rules.Rule;
import org.sonar.api.rules.RuleFinder;
import org.sonar.api.rules.Violation;
+import org.sonar.api.utils.Logs;
import java.io.File;
import java.util.List;
@@ -38,6 +39,9 @@ public class FindbugsNativeSensor implements Sensor {
}
public void analyse(Project project, SensorContext context) {
+ if (project.getReuseExistingRulesConfig()) {
+ Logs.INFO.warn("Reusing existing Findbugs configuration not supported anymore.");
+ }
File report = getFindbugsReportFile(project);
if (report == null) {
report = executor.execute();
diff --git a/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsConfigurationTest.java b/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsConfigurationTest.java
deleted file mode 100644
index b4e84de80bd..00000000000
--- a/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsConfigurationTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.sonar.plugins.findbugs;
-
-import org.junit.Test;
-import org.sonar.api.batch.maven.MavenPlugin;
-import org.sonar.api.batch.maven.MavenUtils;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.ProjectFileSystem;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-public class FindbugsConfigurationTest {
- @Test
- public void shouldReuseExistingRulesConfig() throws Exception {
- Project project = mock(Project.class);
- when(project.getReuseExistingRulesConfig()).thenReturn(true);
- ProjectFileSystem fileSystem = mock(ProjectFileSystem.class);
- // when(fileSystem.getBasedir()).thenReturn(new File("/tmp"));
- when(project.getFileSystem()).thenReturn(fileSystem);
-
- MavenPlugin plugin = new MavenPlugin(MavenUtils.GROUP_ID_CODEHAUS_MOJO, "findbugs-maven-plugin", "2.3.1");
- plugin.setParameter("excludeFilterFile", "rules/exclude.xml");
- plugin.setParameter("includeFilterFile", "rules/include.xml");
-
- FindbugsConfiguration conf = spy(new FindbugsConfiguration(project, null, null, null));
- doReturn(plugin).when(conf).getFindbugsMavenPlugin();
- assertThat(conf.saveExcludeConfigXml(), notNullValue());
- assertThat(conf.saveIncludeConfigXml(), notNullValue());
- }
-}