OpenSRP/opensrp-client-anc

View on GitHub
opensrp-anc/src/main/java/org/smartregister/anc/library/util/ANCFormUtils.java

Summary

Maintainability
F
1 wk
Test Coverage

File ANCFormUtils.java has 645 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package org.smartregister.anc.library.util;



import android.annotation.SuppressLint;

    Method processRequiredStepsField has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
    Open

        public static void processRequiredStepsField(Facts facts, JSONObject object) throws Exception {
            if (object != null) {
                Iterator<String> keys = object.keys();
                while (keys.hasNext()) {
                    String key = keys.next();

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    ANCFormUtils has 43 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class ANCFormUtils extends FormUtils {
    
        public static String obtainValue(String key, JSONArray value) throws JSONException {
            String result = "";
            for (int j = 0; j < value.length(); j++) {

      Method processCheckBoxSpecialWidget has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

          private static void processCheckBoxSpecialWidget(JSONObject widget, List<String> keyList, List<String> valueList)
                  throws Exception {
              //Clear previous selected values from the widget first
              if (widget.has(JsonFormConstants.VALUE)) {
                  widget.remove(JsonFormConstants.VALUE);

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method getFilteredItemsWithoutFilteredSource has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

          private static boolean getFilteredItemsWithoutFilteredSource(JSONObject mainJsonObject, JSONObject checkBoxField, ArrayList<JSONObject> newOptionsList, Map<String, JSONObject> optionsMap) throws JSONException {
              if (checkBoxField.has(ConstantsUtils.FILTER_OPTIONS)) {
                  JSONArray filterOptions = checkBoxField.getJSONArray(ConstantsUtils.FILTER_OPTIONS);
                  if (filterOptions.length() > 0) {
                      for (int count = 0; count < filterOptions.length(); count++) {

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method cleanValue has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          @SuppressLint("NewApi")
          static String cleanValue(String value) {
              String returnValue = "";
              try {
                  if (value.trim().length() > 0 && value.trim().charAt(0) == '[') {

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method compareItemAndValueGlobal has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          private static boolean compareItemAndValueGlobal(String itemValue, String globalValue) {
              if (!TextUtils.isEmpty(itemValue) && !TextUtils.isEmpty(globalValue)) {
                  List<String> globalValuesList = new ArrayList<>();
                  if (globalValue.startsWith("[")) {
                      String[] globalValuesArray = globalValue.substring(1, globalValue.length() - 1).split(", ");

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method processRadioButtonsSpecialWidget has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          private static void processRadioButtonsSpecialWidget(JSONObject widget, List<String> valueList) throws Exception {
              //Value already good for radio buttons so no keylist
              JSONArray jsonArray = widget.getJSONArray(JsonFormConstants.OPTIONS_FIELD_NAME);
      
              for (int i = 0; i < jsonArray.length(); i++) {

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method createSecondaryFormObject has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          public static JSONObject createSecondaryFormObject(JSONObject parentObject, JSONObject jsonSubForm, String encounterType)
                  throws JSONException {
              Map<String, String> vMap = new HashMap<>();
              JSONObject resultJsonObject = new JSONObject();
              JSONObject stepJsonObject = new JSONObject();

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method processRequiredStepsField has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static void processRequiredStepsField(Facts facts, JSONObject object) throws Exception {
              if (object != null) {
                  Iterator<String> keys = object.keys();
                  while (keys.hasNext()) {
                      String key = keys.next();

        Method processCheckBoxSpecialWidget has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private static void processCheckBoxSpecialWidget(JSONObject widget, List<String> keyList, List<String> valueList)
                    throws Exception {
                //Clear previous selected values from the widget first
                if (widget.has(JsonFormConstants.VALUE)) {
                    widget.remove(JsonFormConstants.VALUE);

          Method getListValuesAsString has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              @SuppressLint("NewApi")
              public static String getListValuesAsString(List<String> list) {
                  List<String> returnList = new ArrayList<>();
                  if (list.size() != 0) {
                      for (int i = 0; i < list.size(); i++) {

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Method keyToValueConverter has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public static String keyToValueConverter(String keys) {
                  if (keys != null) {
                      String cleanKey = "";
                      String value = cleanValue(keys);
                      if (!value.contains(JsonFormConstants.TEXT) || !value.contains(".") && StringUtils.isNotBlank(value)) {

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Method processCheckboxFilteredItems has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public static void processCheckboxFilteredItems(JSONObject mainJsonObject) throws JSONException {
          
                  if (!mainJsonObject.has(ConstantsUtils.FILTERED_ITEMS) || mainJsonObject.getJSONArray(ConstantsUtils.FILTERED_ITEMS).length() < 1) {
                      return;
                  }

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Method processRequiredStepsExpansionPanelValues has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              private static void processRequiredStepsExpansionPanelValues(Facts facts, JSONObject fieldObject) throws Exception {
                  if (fieldObject.has(JsonFormConstants.TYPE) &&
                          JsonFormConstants.EXPANSION_PANEL.equals(fieldObject.getString(JsonFormConstants.TYPE)) &&
                          fieldObject.has(JsonFormConstants.VALUE)) {
                      JSONArray expansionPanelValue = fieldObject.getJSONArray(JsonFormConstants.VALUE);

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Method getSecondaryValueKeyPair has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              private static void getSecondaryValueKeyPair(JSONArray values, int valueLength, List<String> keyList, List<String> valueList) throws JSONException {
                  for (int k = 0; k < valueLength; k++) {
                      String valuesString = values.getString(k);
                      String keyString = "";
                      if (TextUtils.isEmpty(keyString) && valuesString.contains(":")) {

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Method getFilteredItemsWithoutFilteredSource has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private static boolean getFilteredItemsWithoutFilteredSource(JSONObject mainJsonObject, JSONObject checkBoxField, ArrayList<JSONObject> newOptionsList, Map<String, JSONObject> optionsMap) throws JSONException {
                  if (checkBoxField.has(ConstantsUtils.FILTER_OPTIONS)) {
                      JSONArray filterOptions = checkBoxField.getJSONArray(ConstantsUtils.FILTER_OPTIONS);
                      if (filterOptions.length() > 0) {
                          for (int count = 0; count < filterOptions.length(); count++) {

            Method cleanValue has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                @SuppressLint("NewApi")
                static String cleanValue(String value) {
                    String returnValue = "";
                    try {
                        if (value.trim().length() > 0 && value.trim().charAt(0) == '[') {

              Avoid deeply nested control flow statements.
              Open

                                      if (fieldKey != null && fieldObject.has(JsonFormConstants.VALUE) && fieldObject.has(JsonFormConstants.TYPE)
                                              && !JsonFormConstants.EXPANSION_PANEL.equals(fieldObject.getString(JsonFormConstants.TYPE))) {
                                          if (JsonFormConstants.CHECK_BOX.equals(fieldObject.optString(JsonFormConstants.TYPE, ""))) {
                                              String value = Utils.getProperties(context).getProperty(ConstantsUtils.Properties.WIDGET_VALUE_TRANSLATED, "false");
                                              if (StringUtils.isNotBlank(value) && Boolean.parseBoolean(value)) {

                Avoid deeply nested control flow statements.
                Open

                                        if (optionsToFilter == null) {
                                            String itemKey = removeKeyPrefix(keyGlobal, ConstantsUtils.PREVIOUS);
                                            newOptionsList.add(optionsMap.get(itemKey));
                                        } else {
                                            for (int itemIndex = 0; itemIndex < optionsToFilter.length(); itemIndex++) {

                  Avoid deeply nested control flow statements.
                  Open

                                          if (fieldObject.has(JsonFormConstants.CONTENT_FORM)) {
                                              processRequiredStepsExpansionPanelValues(facts, fieldObject);
                                          }

                    Method setSecondaryValues has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private static void setSecondaryValues(JSONObject itemField, JSONArray secondaryValues) throws JSONException {
                            for (int j = 0; j < secondaryValues.length(); j++) {
                                JSONObject secValue = secondaryValues.getJSONObject(j);
                    
                                if (secValue.length() > 0) {

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Method processAbnormalValues has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private static void processAbnormalValues(Facts facts, JSONObject jsonObject) throws Exception {
                    
                            //Expansion panel widgets have "values" attribute with no "value" do not process them
                            //We will handle the processing somewhere else.
                            if (jsonObject.has(JsonFormConstants.VALUES) && !jsonObject.has(JsonFormConstants.VALUE)) {

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Method sortSecondaryValues has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public static JSONArray sortSecondaryValues(JSONObject fieldObject) throws JSONException {
                            JSONObject otherValue = null;
                            JSONArray newJsonArray = new JSONArray();
                    
                            JSONArray secondaryValues = fieldObject.getJSONArray(ConstantsUtils.KeyUtils.SECONDARY_VALUES);

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Identical blocks of code found in 2 locations. Consider refactoring.
                    Open

                            if (fieldObject.has(JsonFormConstants.VALUE) && !TextUtils.isEmpty(fieldObject.getString(JsonFormConstants.VALUE)) &&
                                    fieldObject.getString(ConstantsUtils.KeyUtils.KEY).endsWith(ConstantsUtils.SuffixUtils.OTHER) && facts.get(
                                    fieldObject.getString(ConstantsUtils.KeyUtils.KEY).replace(ConstantsUtils.SuffixUtils.OTHER, ConstantsUtils.SuffixUtils.VALUE)) != null) {
                    opensrp-anc/src/main/java/org/smartregister/anc/library/activity/MainContactActivity.java on lines 426..429

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 78.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Identical blocks of code found in 2 locations. Consider refactoring.
                    Open

                            String fieldKeySecondary = fieldKey.contains(ConstantsUtils.SuffixUtils.OTHER) ?
                                    fieldKey.substring(0, fieldKey.indexOf(ConstantsUtils.SuffixUtils.OTHER)) + ConstantsUtils.SuffixUtils.VALUE : "";
                    opensrp-anc/src/main/java/org/smartregister/anc/library/activity/MainContactActivity.java on lines 406..407

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 44.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                            if (valueItem.has(JsonFormConstants.TYPE) && valueItem.has(JsonFormConstants.VALUES)) {
                                String type = valueItem.optString(JsonFormConstants.TYPE);
                                JSONArray values = valueItem.optJSONArray(JsonFormConstants.VALUES);
                                result = extractItemValue(type, values);
                            }
                    opensrp-anc/src/main/java/org/smartregister/anc/library/util/ANCJsonFormUtils.java on lines 90..94

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 42.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 3 locations. Consider refactoring.
                    Open

                                for (int j = 0; j < secondaryValues.length(); j++) {
                                    JSONObject jsonObject = secondaryValues.getJSONObject(j);
                                    processAbnormalValues(facts, jsonObject);
                                }
                    opensrp-anc/src/main/java/org/smartregister/anc/library/activity/MainContactActivity.java on lines 382..385
                    opensrp-anc/src/main/java/org/smartregister/anc/library/util/ANCJsonFormUtils.java on lines 504..509

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 42.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Identical blocks of code found in 2 locations. Consider refactoring.
                    Open

                            if (fieldKey.endsWith(ConstantsUtils.SuffixUtils.OTHER) && !fieldKeySecondary.isEmpty() &&
                                    facts.get(fieldKeySecondary) != null && facts.get(fieldKeyOtherValue) != null) {
                    opensrp-anc/src/main/java/org/smartregister/anc/library/activity/MainContactActivity.java on lines 410..411

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 42.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    There are no issues that match your filters.

                    Category
                    Status