aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorfmallet <freddy.mallet@gmail.com>2010-09-23 19:54:10 +0000
committerfmallet <freddy.mallet@gmail.com>2010-09-23 19:54:10 +0000
commitfe2910fa2ce3a47ba4c2a254f1d3c2f479dae177 (patch)
tree35789853d203df118f72b00f7ef00dc3c973a0f2 /plugins
parent1dfd7034c4cb735683949cef50a8e3809bab6a35 (diff)
downloadsonarqube-fe2910fa2ce3a47ba4c2a254f1d3c2f479dae177.tar.gz
sonarqube-fe2910fa2ce3a47ba4c2a254f1d3c2f479dae177.zip
fix SONAR-1802 : Can't import FindBugs profile when some rules are duplicated in the findbugs.xml configuration file
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/xml/FindBugsFilter.java2
-rw-r--r--plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsProfileImporterTest.java6
-rw-r--r--plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/shouldImportPatterns.xml16
3 files changed, 13 insertions, 11 deletions
diff --git a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/xml/FindBugsFilter.java b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/xml/FindBugsFilter.java
index 9790f185d22..31d721deca1 100644
--- a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/xml/FindBugsFilter.java
+++ b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/xml/FindBugsFilter.java
@@ -151,7 +151,7 @@ public class FindBugsFilter {
}
private void mapRulePriority(Map<String, RulePriority> prioritiesByRule, RulePriority priority, String key) {
- if (prioritiesByRule.containsKey(key)) {
+ if (prioritiesByRule.containsKey(key) && prioritiesByRule.get(key) != null) {
if (prioritiesByRule.get(key).compareTo(priority) < 0) {
prioritiesByRule.put(key, priority);
}
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 b829ce9abf1..b8ccd2e4b5a 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
@@ -108,7 +108,7 @@ public class FindbugsProfileImporterTest {
assertThat(results.size(), is(0));
assertThat(messages.getErrors().size(), is(1));
}
-
+
@Test
public void testImportingXmlFileWithUnknownRule() throws IOException {
String uncorrectFindbugsXml = TestUtils.getResourceContent("/org/sonar/plugins/findbugs/findbugsXmlWithUnknownRule.xml");
@@ -119,7 +119,7 @@ public class FindbugsProfileImporterTest {
assertThat(results.size(), is(1));
assertThat(messages.getWarnings().size(), is(1));
}
-
+
@Test
public void testImportingXmlFileWithUnknownCategory() throws IOException {
String uncorrectFindbugsXml = TestUtils.getResourceContent("/org/sonar/plugins/findbugs/findbugsXmlWithUnknownCategory.xml");
@@ -130,7 +130,7 @@ public class FindbugsProfileImporterTest {
assertThat(results.size(), is(142));
assertThat(messages.getWarnings().size(), is(1));
}
-
+
@Test
public void testImportingXmlFileWithUnknownCode() throws IOException {
String uncorrectFindbugsXml = TestUtils.getResourceContent("/org/sonar/plugins/findbugs/findbugsXmlWithUnknownCode.xml");
diff --git a/plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/shouldImportPatterns.xml b/plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/shouldImportPatterns.xml
index b454f431b93..a07b9ca4295 100644
--- a/plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/shouldImportPatterns.xml
+++ b/plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/shouldImportPatterns.xml
@@ -1,9 +1,11 @@
<FindBugsFilter>
- <Match>
- <Or>
- <Bug pattern="NP_CLOSING_NULL"/>
- <Bug pattern="RC_REF_COMPARISON_BAD_PRACTICE"/>
- </Or>
- <Priority value="2"/>
- </Match>
+ <Match>
+ <Bug pattern="NP_CLOSING_NULL" />
+ </Match>
+ <Match>
+ <Bug pattern="RC_REF_COMPARISON_BAD_PRACTICE" />
+ </Match>
+ <Match>
+ <Bug pattern="RC_REF_COMPARISON_BAD_PRACTICE" />
+ </Match>
</FindBugsFilter> \ No newline at end of file