OpenSRP/opensrp-client-anc

View on GitHub

Showing 436 of 436 total issues

Avoid deeply nested control flow statements.
Open

                            if (keys.containsKey(fieldKey) && ANCJsonFormUtils.checkIfTaskIsComplete(keys.get(fieldKey))) {
                                fields.remove(i);
                            }

    Avoid deeply nested control flow statements.
    Open

                            if (item != null && item.getBoolean(JsonFormConstants.VALUE)) {
                                if (item.getString(JsonFormConstants.KEY).equals(ConstantsUtils.DANGER_NONE)) {
                                    none = true;
                                }
    
    

      Method onBindViewHolder has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          @Override
          public void onBindViewHolder(ViewHolder holder, int position) {
              holder.sectionHeader.setText(processUnderscores(mData.get(position).getGroup()));
              List<YamlConfigItem> fields = mData.get(position).getFields();
              StringBuilder outputBuilder = new StringBuilder();

      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 removeWomanFromANCRegister has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          @Override
          public void removeWomanFromANCRegister(final String closeFormJsonString, final String providerId) {
              Runnable runnable = () -> {
                  try {
                      Triple<Boolean, Event, Event> triple = ANCJsonFormUtils

      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 addMapValuesCheckingLocals has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          private void addMapValuesCheckingLocals(String field, boolean isLocal, Map<String, String> editMap, String key, String globalField, String keyToMapTo) {

        Method addGlobalsToAMap has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            private void addGlobalsToAMap(List<String> contactGlobals, Map<String, String> map) {
                for (String contactGlobal : contactGlobals) {
                    if (formGlobalValues.containsKey(contactGlobal)) {
                        String some = map.get(contactGlobal);
        
        

        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

        Avoid deeply nested control flow statements.
        Open

                                    if (StringUtils.isNotBlank(formName) && formName.equals(ConstantsUtils.JsonFormUtils.ANC_QUICK_CHECK)) {
                                        quickCheckDangerSignsSelectionHandler(fields);
                                    }

          Avoid deeply nested control flow statements.
          Open

                                  if (values.contains(fieldObject.getJSONArray(JsonFormConstants.OPTIONS_FIELD_NAME).getJSONObject(m)
                                          .getString(JsonFormConstants.KEY))) {
                                      stepArray.getJSONObject(i).getJSONArray(JsonFormConstants.OPTIONS_FIELD_NAME).getJSONObject(m)
                                              .put(JsonFormConstants.VALUE, true);
                                      fieldObject.put(JsonFormConstants.EDITABLE,

            Avoid deeply nested control flow statements.
            Open

                                    for (Map.Entry<String, Object> stringObjectEntry : factObject.entrySet()) {
                                        factsToUpdate.put(stringObjectEntry.getKey(), stringObjectEntry.getValue());
                                    }

              Method updateSubFormRequiredCount has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  private void updateSubFormRequiredCount(JSONArray requiredAccordionFields, HashMap<String, JSONArray> accordionValuesMap,
                                                          JSONObject encounterObject) throws JSONException {
              
                      if (requiredAccordionFields.length() == 0) {
                          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

              Avoid deeply nested control flow statements.
              Open

                                      if (ConstantsUtils.BooleanUtils.TRUE.equals(optionValue)) {
                                          addDefaults = false;
                                          break;
                                      }

                Method addOtherRuleObjects has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    private void addOtherRuleObjects(Facts facts) throws IOException {
                        Iterable<Object> ruleObjects = loadFile(FilePathUtils.FileUtils.PROFILE_LAST_CONTACT);
                
                        for (Object ruleObject : ruleObjects) {
                            List<YamlConfigWrapper> yamlConfigList = new ArrayList<>();

                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 getViewsFromJson has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    @Override
                    public List<View> getViewsFromJson(String stepName, Context context, JsonFormFragment formFragment,
                                                       JSONObject jsonObject, CommonListener listener, boolean popup) throws Exception {
                        this.formFragment = formFragment;
                        jsonFormView = (JsonFormActivity) formFragment.getActivity();

                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

                Avoid deeply nested control flow statements.
                Open

                                        if (fieldObject.getString(JsonFormConstants.TYPE).equals(JsonFormConstants.EXPANSION_PANEL)) {
                                            saveExpansionPanelPreviousValues(baseEntityId, fieldObject, contactNo);
                                            continue;
                                        }

                  Method addOtherRuleObjects has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private void addOtherRuleObjects(Facts facts) throws IOException {
                          Iterable<Object> ruleObjects = loadFile(FilePathUtils.FileUtils.PROFILE_LAST_CONTACT);
                  
                          for (Object ruleObject : ruleObjects) {
                              List<YamlConfigWrapper> yamlConfigList = new ArrayList<>();

                  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

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

                  package org.smartregister.anc.library.interactor;
                  
                  import org.smartregister.anc.library.contract.BaseCharacteristicsContract;
                  import org.smartregister.anc.library.contract.PopulationCharacteristicsContract;
                  import org.smartregister.anc.library.task.FetchSiteCharacteristicsTask;
                  opensrp-anc/src/main/java/org/smartregister/anc/library/interactor/PopulationCharacteristicsInteractor.java on lines 1..30

                  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 54.

                  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

                  package org.smartregister.anc.library.interactor;
                  
                  import org.smartregister.anc.library.contract.BaseCharacteristicsContract;
                  import org.smartregister.anc.library.contract.PopulationCharacteristicsContract;
                  import org.smartregister.anc.library.task.FetchPopulationCharacteristicsTask;
                  opensrp-anc/src/main/java/org/smartregister/anc/library/interactor/SiteCharacteristicsInteractor.java on lines 1..30

                  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 54.

                  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

                          outsideInside.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                              @Override
                              public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                                  if (!Utils.isConnectedToNetwork(getActivity())) {
                                      myCatchment.setChecked(true);
                  opensrp-anc/src/main/java/org/smartregister/anc/library/fragment/AdvancedSearchFragment.java on lines 465..475

                  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 53.

                  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

                      public void execute() {
                          appExecutors = new AppExecutors();
                          appExecutors.mainThread().execute(this::showDialog);
                          appExecutors.diskIO().execute(() -> {
                              this.onProcess();
                  opensrp-anc/src/main/java/org/smartregister/anc/library/task/FinalizeContactTask.java on lines 35..48

                  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 53.

                  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

                          myCatchment.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                              @Override
                              public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                                  if (!Utils.isConnectedToNetwork(getActivity())) {
                                      myCatchment.setChecked(true);
                  opensrp-anc/src/main/java/org/smartregister/anc/library/fragment/AdvancedSearchFragment.java on lines 453..463

                  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 53.

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language