OpenSRP/opensrp-client-anc

View on GitHub

Showing 436 of 436 total issues

File Utils.java has 888 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package org.smartregister.anc.library.util;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;

    File ANCJsonFormUtils.java has 830 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    package org.smartregister.anc.library.util;
    
    import android.app.Activity;
    import android.content.Context;
    import android.content.Intent;

      File MainContactActivity.java has 664 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      package org.smartregister.anc.library.activity;
      
      import android.annotation.SuppressLint;
      import android.content.Intent;
      import android.text.TextUtils;

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

        package org.smartregister.anc.library.util;
        
        
        
        import android.annotation.SuppressLint;

          Utils has 64 methods (exceeds 20 allowed). Consider refactoring.
          Open

          public class Utils extends org.smartregister.util.Utils {
              public static final SimpleDateFormat DB_DF = new SimpleDateFormat(ConstantsUtils.SQLITE_DATE_TIME_FORMAT);
              public static final SimpleDateFormat CONTACT_DF = new SimpleDateFormat(ConstantsUtils.CONTACT_DATE_FORMAT);
              public static final SimpleDateFormat CONTACT_SUMMARY_DF = new SimpleDateFormat(ConstantsUtils.CONTACT_SUMMARY_DATE_FORMAT);
              public static final ArrayList<String> ALLOWED_LEVELS;

            File AdvancedSearchFragment.java has 474 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            package org.smartregister.anc.library.fragment;
            
            import android.content.BroadcastReceiver;
            import android.content.Context;
            import android.content.Intent;

              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

              ANCJsonFormUtils has 45 methods (exceeds 20 allowed). Consider refactoring.
              Open

              public class ANCJsonFormUtils extends org.smartregister.util.JsonFormUtils {
                  public static final String METADATA = "metadata";
                  public static final String ENCOUNTER_TYPE = "encounter_type";
                  public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd-MM-yyyy");
                  public static final SimpleDateFormat EDD_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");

                File BaseHomeRegisterActivity.java has 414 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                package org.smartregister.anc.library.activity;
                
                import android.app.Activity;
                import android.content.Intent;
                import android.os.Bundle;

                  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++) {

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

                    public class MainContactActivity extends BaseContactActivity implements ContactContract.View {
                        private TextView patientNameView;
                        private final Map<String, Integer> requiredFieldsMap = new HashMap<>();
                        private final Map<String, String> eventToFileMap = new HashMap<>();
                        private final Yaml yaml = new Yaml();

                      Method returnTranslatedStringJoinedValue has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
                      Open

                          @SuppressLint({"NewApi"})
                          public static String returnTranslatedStringJoinedValue(String value) {
                              try {
                                  if (StringUtils.isNotBlank(value) && value.startsWith("[")) {
                                      if (Utils.checkJsonArrayString(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 saveOrDeleteTasks has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private void saveOrDeleteTasks(@NotNull JSONArray stepFields) throws JSONException {
                              for (int i = 0; i < stepFields.length(); i++) {
                                  JSONObject field = stepFields.getJSONObject(i);
                                  if (field != null && field.has(JsonFormConstants.IS_VISIBLE) && field.getBoolean(JsonFormConstants.IS_VISIBLE)) {
                                      JSONArray jsonArray = field.optJSONArray(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

                      BaseHomeRegisterActivity has 41 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                      public class BaseHomeRegisterActivity extends BaseRegisterActivity implements RegisterContract.View {
                          private static final SimpleDateFormat dateFormatter = new SimpleDateFormat("dd/MM/yyyy");
                      
                          private AlertDialog recordBirthAlertDialog;
                          private AlertDialog attentionFlagAlertDialog;

                        AdvancedSearchFragment has 40 methods (exceeds 20 allowed). Consider refactoring.
                        Open

                        public class AdvancedSearchFragment extends HomeRegisterFragment
                                implements AdvancedSearchContract.View, RegisterFragmentContract.View {
                        
                            private View listViewLayout;
                            private View advancedSearchForm;

                          Method updateDefaultValues has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
                          Open

                              private void updateDefaultValues(JSONArray stepArray, int i, JSONObject fieldObject) throws JSONException {
                                  if (defaultValueFields.contains(fieldObject.getString(JsonFormConstants.KEY))) {
                          
                                      if (!fieldObject.has(JsonFormConstants.VALUE) ||
                                              TextUtils.isEmpty(fieldObject.getString(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

                          ProfileActivity has 38 methods (exceeds 20 allowed). Consider refactoring.
                          Open

                          public class ProfileActivity extends BaseProfileActivity implements ProfileContract.View {
                              public static final String CLOSE_ANC_RECORD = "Close ANC Record";
                              private TextView nameView;
                              private TextView ageView;
                              private TextView gestationAgeView;

                            Method processFormFieldKeyValues has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
                            Open

                                private void processFormFieldKeyValues(String baseEntityId, JSONObject object, String contactNo) throws Exception {
                                    if (object != null) {
                                        persistRequiredInvisibleFields(baseEntityId, contactNo, object);
                                        Iterator<String> keys = object.keys();
                            
                            

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

                                @Override
                                public void loadPreviousContactsDetails(Map<String, List<Facts>> allContactFacts) throws IOException, ParseException {
                                    List<LastContactDetailsWrapper> lastContactDetailsWrapperList = new ArrayList<>();
                                    if (!allContactFacts.isEmpty()) {
                                        for (Map.Entry<String, List<Facts>> entry : allContactFacts.entrySet()) {

                            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

                            AncLibrary has 36 methods (exceeds 20 allowed). Consider refactoring.
                            Open

                            public class AncLibrary {
                                private static AncLibrary instance;
                                private final Context context;
                                private final JsonSpecHelper jsonSpecHelper;
                                private PartialContactRepository partialContactRepository;
                              Severity
                              Category
                              Status
                              Source
                              Language