]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2230 Refactor to decrease complexity
authorsimonbrandhof <simon.brandhof@gmail.com>
Tue, 15 Mar 2011 15:43:00 +0000 (16:43 +0100)
committersimonbrandhof <simon.brandhof@gmail.com>
Tue, 15 Mar 2011 15:43:00 +0000 (16:43 +0100)
sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ProfileUnmarshaller.java

index 9af6118515c44df71bebcdd0f8275527f6bc9960..00c6030d5ba729298fec19454f8a3084347a10a0 100644 (file)
@@ -35,6 +35,11 @@ public class ProfileUnmarshaller extends AbstractUnmarshaller<Profile> {
         .setParentName(utils.getString(json, "parent"))
         .setProvided(utils.getBoolean(json, "provided"));
 
+    parseRules(utils, profile, json);
+    return profile;
+  }
+
+  private void parseRules(WSUtils utils, Profile profile, Object json) {
     Object rulesJson = utils.getField(json, "rules");
     if (rulesJson != null) {
       for (int i = 0; i < utils.getArraySize(rulesJson); i++) {
@@ -46,18 +51,21 @@ public class ProfileUnmarshaller extends AbstractUnmarshaller<Profile> {
           rule.setSeverity(utils.getString(ruleJson, "severity"));
           rule.setInheritance(utils.getString(ruleJson, "inheritance"));
 
-          Object paramsJson = utils.getField(ruleJson, "params");
-          if (paramsJson != null) {
-            for (int indexParam = 0; indexParam < utils.getArraySize(paramsJson); indexParam++) {
-              Object paramJson = utils.getArrayElement(paramsJson, indexParam);
-              rule.addParameter(utils.getString(paramJson, "key"), utils.getString(paramJson, "value"));
-            }
-          }
+          parseRuleParameters(utils, rule, ruleJson);
           profile.addRule(rule);
         }
       }
     }
-    return profile;
+  }
+
+  private void parseRuleParameters(WSUtils utils, Profile.Rule rule, Object ruleJson) {
+    Object paramsJson = utils.getField(ruleJson, "params");
+    if (paramsJson != null) {
+      for (int indexParam = 0; indexParam < utils.getArraySize(paramsJson); indexParam++) {
+        Object paramJson = utils.getArrayElement(paramsJson, indexParam);
+        rule.addParameter(utils.getString(paramJson, "key"), utils.getString(paramJson, "value"));
+      }
+    }
   }
 
 }