]> source.dussan.org Git - sonarqube.git/commitdiff
Fix quality flaw
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 7 Mar 2014 07:25:05 +0000 (08:25 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 7 Mar 2014 08:12:24 +0000 (09:12 +0100)
sonar-core/src/main/java/org/sonar/core/technicaldebt/CharacteristicsXMLImporter.java
sonar-core/src/main/java/org/sonar/core/technicaldebt/RuleDebtXMLImporter.java
sonar-server/src/main/java/org/sonar/server/rule/RuleRegistration.java

index 9595f961143df521eac187f972bc96c3e974ccf0..b04c9b715cccc46efddc5f28d3ceba0c2be24d95 100644 (file)
@@ -81,7 +81,8 @@ public class CharacteristicsXMLImporter implements ServerExtension {
     return new SMInputFactory(xmlFactory);
   }
 
-  private DefaultCharacteristic processCharacteristic(DefaultTechnicalDebtModel model, DefaultCharacteristic parent, SMInputCursor chcCursor, ValidationMessages messages) throws XMLStreamException {
+  private DefaultCharacteristic processCharacteristic(DefaultTechnicalDebtModel model, DefaultCharacteristic parent, SMInputCursor chcCursor,
+                                                      ValidationMessages messages) throws XMLStreamException {
     DefaultCharacteristic characteristic = new DefaultCharacteristic();
     SMInputCursor cursor = chcCursor.childElementCursor();
     while (cursor.getNext() != null) {
index 8ffb8e643a87fc842577944e63031d2d3074f920..86085581c9d0e70fcb5d7a2818147b04fa967ee0 100644 (file)
@@ -84,11 +84,7 @@ public class RuleDebtXMLImporter implements ServerExtension {
       }
 
       cursor.getStreamReader().closeCompletely();
-    } catch (
-      XMLStreamException e
-      )
-
-    {
+    } catch (XMLStreamException e) {
       LOG.error("XML is not valid", e);
     }
 
index 8a6bf727407c70b5b6302fedbffef2ae25f7e3b6..057b61bd598ef30ac7b8642b03463cab72cd743d 100644 (file)
@@ -539,13 +539,15 @@ public class RuleRegistration implements Startable {
   private CharacteristicDto findCharacteristic(List<CharacteristicDto> characteristicDtos, RuleDefinitions.Rule ruleDef) {
     final String key = ruleDef.characteristicKey();
     if (key == null) {
+      // Rule is not linked to a characteristic, nothing to do
       return null;
     }
     CharacteristicDto characteristicDto = Iterables.find(characteristicDtos, new Predicate<CharacteristicDto>() {
       @Override
       public boolean apply(CharacteristicDto input) {
+        String characteristicKey = input.getKey();
         // TODO remove check on null rule id when only characteristics without requirements will be returned
-        return input.getRuleId() == null && input.getKey().equals(key);
+        return input.getRuleId() == null && characteristicKey != null && characteristicKey.equals(key);
       }
     }, null);
     // TODO check not root characteristic