OpenSRP/opensrp-client-anc

View on GitHub

Showing 306 of 436 total issues

Method init has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    @Override
    public void init(String json) {
        try {
            setmJSONObject(new JSONObject(json));
            if (!getmJSONObject().has(ConstantsUtils.JsonFormKeyUtils.ENCOUNTER_TYPE)) {

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 populateFormViews has 71 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private void populateFormViews(View view) {
        search = view.findViewById(R.id.search);
        search.setEnabled(false);
        search.setTextColor(getResources().getColor(R.color.contact_complete_grey_border));

    Method removeDueTests has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        private JSONObject removeDueTests(JSONObject formObject, List<Task> taskList) {
            JSONObject form = new JSONObject();
            try {
                Map<String, JSONObject> keys = taskHashMap(taskList);
                if (formObject != null && taskList != null && taskList.size() > 0 && formObject.has(JsonFormConstants.STEP1)) {

    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 saveRemovedFromANCRegister has 68 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static Triple<Boolean, Event, Event> saveRemovedFromANCRegister(AllSharedPreferences allSharedPreferences, String jsonString, String providerId) {
            try {
                boolean isDeath = false;
                Triple<Boolean, JSONObject, JSONArray> registrationFormParams = validateParameters(jsonString);
    
    

      Method finalizeContactForm has 68 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          @Override
          public HashMap<String, String> finalizeContactForm(final Map<String, String> details, Context context) {
              if (details != null) {
                  try {
                      String referral = details.get(ConstantsUtils.REFERRAL);

        Method checkIfTaskIsComplete has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            public static boolean checkIfTaskIsComplete(JSONObject field) {
                boolean isComplete = true;
                try {
                    if (field != null && field.has(JsonFormConstants.VALUE)) {
                        JSONArray value = field.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 processValue has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            private static String processValue(String key, Facts facts) {
                String value = "";
                if (facts.get(key) instanceof String) {
                    value = facts.get(key);
                    if ((key.equals(ConstantsUtils.PrescriptionUtils.NAUSEA_PHARMA) || key.equals(ConstantsUtils.PrescriptionUtils.ANTACID) || key.equals(ConstantsUtils.PrescriptionUtils.PENICILLIN) || key.equals(ConstantsUtils.PrescriptionUtils.ANTIBIOTIC) || key.equals(ConstantsUtils.PrescriptionUtils.IFA_MEDICATION) || key.equals(ConstantsUtils.PrescriptionUtils.VITA)

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

            @Override
            public void fetchUpcomingContacts(final String entityId, final String referralContactNo,
                                              final ContactSummarySendContract.InteractorCallback callback) {
        
                Runnable runnable = () -> {

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

            public static HashMap<String, HashMap<String, String>> buildRepeatingGroupValues(@NonNull JSONArray fields, @NonNull String fieldName) throws JSONException {
                ArrayList<String> keysArrayList = new ArrayList<>();
                JSONObject jsonObject = JsonFormUtils.getFieldJSONObject(fields, fieldName);
                HashMap<String, HashMap<String, String>> repeatingGroupMap = new LinkedHashMap<>();
                if (jsonObject != null) {

        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

        WomanDetail has 22 methods (exceeds 20 allowed). Consider refactoring.
        Open

        public class WomanDetail {
            private Integer nextContact;
        
            private String baseEntityId;
            private String nextContactDate;

          Method processButtonAlertStatus has 58 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static void processButtonAlertStatus(Context context, Button dueButton, TextView
                      contactTextView,
                                                          ButtonAlertStatus buttonAlertStatus) {
                  if (dueButton != null) {
                      dueButton.setVisibility(View.VISIBLE);

            Method getRemoteLocalMatrixCursor has 57 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private AdvancedMatrixCursor getRemoteLocalMatrixCursor(AdvancedMatrixCursor matrixCursor) {
                    String query = getView().filterAndSortQuery();
                    Cursor cursor = getView().getRawCustomQueryForAdapter(query);
                    if (cursor != null && cursor.getCount() > 0) {
                        AdvancedMatrixCursor remoteLocalCursor = new AdvancedMatrixCursor(

              File ConstantsUtils.java has 261 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              package org.smartregister.anc.library.util;
              
              /**
               * Created by ndegwamartin on 14/03/2018.
               */

                Method processButtonAlertStatus has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static void processButtonAlertStatus(Context context, Button dueButton, TextView
                            contactTextView,
                                                                ButtonAlertStatus buttonAlertStatus) {
                        if (dueButton != null) {
                            dueButton.setVisibility(View.VISIBLE);

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

                    protected static void processLocationFields(@NonNull JSONArray fields) throws JSONException {
                        for (int i = 0; i < fields.length(); i++) {
                            if (fields.optJSONObject(i).has(JsonFormConstants.TYPE) &&
                                    fields.optJSONObject(i).optString(JsonFormConstants.TYPE).equals(JsonFormConstants.TREE))
                                try {

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

                    private void preProcessDefaultValues(JSONObject object) {
                        try {
                            if (object != null) {
                                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 addAttentionFlagsService has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected void addAttentionFlagsService() {
                        try {
                            JSONObject jsonObject = new JSONObject(AncLibrary.getInstance().getDetailsRepository().getAllDetailsForClient(pc.getCaseId()).get(ConstantsUtils.DetailsKeyUtils.ATTENTION_FLAG_FACTS));
                
                            Facts facts = new Facts();

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

                    private void saveRegistration(Pair<Client, Event> pair, String jsonString, boolean isEditMode) {
                        try {
                            Client baseClient = pair.first;
                            Event baseEvent = pair.second;
                
                

                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

                ContactWizardJsonFormFragment has 21 methods (exceeds 20 allowed). Consider refactoring.
                Open

                public class ContactWizardJsonFormFragment extends JsonWizardFormFragment {
                    public static final String TAG = ContactWizardJsonFormFragment.class.getName();
                    private static final int MENU_NAVIGATION = 100001;
                    private boolean savePartial = false;
                    private TextView contactTitle;

                  ProfileTasksFragment has 21 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  public class ProfileTasksFragment extends BaseProfileFragment implements ProfileFragmentContract.View {
                      private final ANCFormUtils formUtils = new ANCFormUtils();
                      private Button dueButton;
                      private ButtonAlertStatus buttonAlertStatus;
                      private ProfileFragmentContract.Presenter presenter;
                    Severity
                    Category
                    Status
                    Source
                    Language