aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/sonar-findbugs-plugin/src
diff options
context:
space:
mode:
authorGodin <mandrikov@gmail.com>2010-10-19 21:04:10 +0000
committerGodin <mandrikov@gmail.com>2010-10-19 21:04:10 +0000
commit2d84946fcb932ab54a7394d716ca20d156ffc8b5 (patch)
tree61a0c4c5052b187f8a1b890f4a425493021efec3 /plugins/sonar-findbugs-plugin/src
parent2a800be6f83fc3a1366c3a5e8d34c8725dbf24e8 (diff)
downloadsonarqube-2d84946fcb932ab54a7394d716ca20d156ffc8b5.tar.gz
sonarqube-2d84946fcb932ab54a7394d716ca20d156ffc8b5.zip
SONAR-1772:
* Don't use existing rules config * Add more tests
Diffstat (limited to 'plugins/sonar-findbugs-plugin/src')
-rw-r--r--plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsNativeSensor.java2
-rw-r--r--plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsNativeSensorTest.java28
2 files changed, 29 insertions, 1 deletions
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..6bf24b8f0e9 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
@@ -33,7 +33,7 @@ public class FindbugsNativeSensor implements Sensor {
public boolean shouldExecuteOnProject(Project project) {
return project.getFileSystem().hasJavaSourceFiles()
- && ( !profile.getActiveRulesByRepository(FindbugsConstants.REPOSITORY_KEY).isEmpty() || project.getReuseExistingRulesConfig())
+ && !profile.getActiveRulesByRepository(FindbugsConstants.REPOSITORY_KEY).isEmpty()
&& project.getPom() != null && !StringUtils.equalsIgnoreCase(project.getPom().getPackaging(), "ear");
}
diff --git a/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsNativeSensorTest.java b/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsNativeSensorTest.java
index 8c5c37a8c17..e07429aa93e 100644
--- a/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsNativeSensorTest.java
+++ b/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsNativeSensorTest.java
@@ -50,6 +50,34 @@ public class FindbugsNativeSensorTest extends FindbugsTests {
}
@Test
+ public void shouldExecuteFindbugsWhenNoReportProvided() throws Exception {
+ Project project = createProject();
+ FindbugsExecutor executor = mock(FindbugsExecutor.class);
+ SensorContext context = mock(SensorContext.class);
+ Configuration conf = mock(Configuration.class);
+ File xmlFile = new File(getClass().getResource("/org/sonar/plugins/findbugs/findbugsXml.xml").toURI());
+ when(project.getConfiguration()).thenReturn(conf);
+ when(executor.execute()).thenReturn(xmlFile);
+ when(context.getResource(any(Resource.class))).thenReturn(new JavaFile("org.sonar.MyClass"));
+
+ FindbugsNativeSensor analyser = new FindbugsNativeSensor(createRulesProfileWithActiveRules(), new FindbugsRuleFinder(), executor);
+ analyser.analyse(project, context);
+
+ verify(executor).execute();
+ verify(context, times(3)).saveViolation(any(Violation.class));
+
+ Violation wanted = new Violation(null, new JavaFile("org.sonar.commons.ZipUtils")).setMessage(
+ "Empty zip file entry created in org.sonar.commons.ZipUtils._zip(String, File, ZipOutputStream)").setLineId(107);
+
+ verify(context).saveViolation(argThat(new IsViolation(wanted)));
+
+ wanted = new Violation(null, new JavaFile("org.sonar.commons.resources.MeasuresDao")).setMessage(
+ "The class org.sonar.commons.resources.MeasuresDao$1 could be refactored into a named _static_ inner class").setLineId(56);
+
+ verify(context).saveViolation(argThat(new IsViolation(wanted)));
+ }
+
+ @Test
public void shouldReuseReport() throws Exception {
Project project = createProject();
FindbugsExecutor executor = mock(FindbugsExecutor.class);