]> source.dussan.org Git - sonarqube.git/commitdiff
fix SONAR-1802 : Can't import FindBugs profile when some rules are duplicated in...
authorfmallet <freddy.mallet@gmail.com>
Thu, 23 Sep 2010 19:54:10 +0000 (19:54 +0000)
committerfmallet <freddy.mallet@gmail.com>
Thu, 23 Sep 2010 19:54:10 +0000 (19:54 +0000)
plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/xml/FindBugsFilter.java
plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsProfileImporterTest.java
plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/shouldImportPatterns.xml

index 9790f185d229083944e4d09270d1dbd63e3c617b..31d721deca1a688f393d8dcedfc13fac2c9078f8 100644 (file)
@@ -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);
       }
index b829ce9abf1a2dbb9421ebe3eccdaea890f23477..b8ccd2e4b5ab8d71eddb254074723564e2fea704 100644 (file)
@@ -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");
index b454f431b9314a92af90846bb08d2c953b146e2c..a07b9ca42951365ca8299175928676f6f3ceeae6 100644 (file)
@@ -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