OpenSRP/opensrp-client-anc

View on GitHub

Showing 306 of 436 total issues

Method getImmediatePreviousSchedule has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public Facts getImmediatePreviousSchedule(String baseEntityId, String contactNo) {
        Cursor scheduleCursor = null;
        String selection = "";
        String orderBy = "created_at DESC";
        String[] selectionArgs = null;

    Method getPreviousContactTestsFacts has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public Facts getPreviousContactTestsFacts(String baseEntityId) {
            Cursor mCursor = null;
            Facts previousContactsTestsFacts = new Facts();
            try {
                SQLiteDatabase db = getWritableDatabase();

      Method getPartialContacts has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public List<PartialContact> getPartialContacts(String baseEntityId, Integer contactNumber) {
              Cursor mCursor = null;
              String selection = "";
              String[] selectionArgs = null;
              List<PartialContact> partialContactList = null;

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

            public static JSONObject getFormAsJson(JSONObject form, String formName, String id, String currentLocationId)
                    throws Exception {
                if (form == null) {
                    return 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

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

            private void populatePatientColumn(CommonPersonObjectClient pc, SmartRegisterClient client,
                                               RegisterViewHolder viewHolder) {
        
                String firstName = Utils.getValue(pc.getColumnmaps(), DBConstantsUtils.KeyUtils.FIRST_NAME, true);
                String lastName = Utils.getValue(pc.getColumnmaps(), DBConstantsUtils.KeyUtils.LAST_NAME, true);

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

            private static String initializeFirstContactValues(@NonNull JSONArray fields) throws JSONException {
                String strGroup = null;
        
                int nextContact = 1;
        
        

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

            public static void saveImage(String providerId, String entityId, String imageLocation) {
                OutputStream outputStream = null;
                try {
                    if (StringUtils.isBlank(imageLocation)) {
                        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 getButtonAlertStatus has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public static ButtonAlertStatus getButtonAlertStatus
                    (Map<String, String> details, Context context, boolean isProfile) {
                String contactStatus = details.get(DBConstantsUtils.KeyUtils.CONTACT_STATUS);
        
                String nextContactDate = details.get(DBConstantsUtils.KeyUtils.NEXT_CONTACT_DATE);

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

            @Override
            protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(getViewLayoutId());
                actionBar = getSupportActionBar();

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

            public void savePartialContact(PartialContact partialContact) {
                if (partialContact == null) return;
                else if (partialContact.getUpdatedAt() == null) {
                    partialContact.setUpdatedAt(Calendar.getInstance().getTimeInMillis());
                }

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

            private void processTasks(JSONObject formObject) {
                try {
                    String encounterType = formObject.getString(ConstantsUtils.JsonFormKeyUtils.ENCOUNTER_TYPE);
                    if (formObject.has(ConstantsUtils.JsonFormKeyUtils.ENCOUNTER_TYPE) && StringUtils.isNotBlank(encounterType) && ConstantsUtils.JsonFormUtils.ANC_TEST_ENCOUNTER_TYPE.equals(encounterType)) {
                        JSONObject dueStep = formObject.optJSONObject(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 updateEventAndRequiredStepsField has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            private void updateEventAndRequiredStepsField(String baseEntityId, PartialContactRepository partialContactRepository,
                                                          List<PartialContact> partialContactList, Facts facts, List<String> formSubmissionIDs) throws Exception {
                if (partialContactList != null) {
                    Collections.sort(partialContactList, (firstPartialContact, secondPartialContact) -> firstPartialContact.getSortOrder().compareTo(secondPartialContact.getSortOrder()));
        
        

        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 27 lines of code (exceeds 25 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) {

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

              public static Pair<Client, Event> processRegistrationForm(AllSharedPreferences allSharedPreferences, String jsonString) {
                  try {
                      Triple<Boolean, JSONObject, JSONArray> registrationFormParams = validateParameters(jsonString);
          
                      if (!registrationFormParams.getLeft()) {

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

                  public static String getAutoPopulatedJsonEditRegisterFormString(Context context, Map<String, String> womanClient) {
                      try {
                          JSONObject form = FormUtils.getInstance(context).getFormJson(ConstantsUtils.JsonFormUtils.ANC_REGISTER);
                          LocationPickerView lpv = createLocationPickerView(context);
                          if (lpv != null) {

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

                    private static String getDisplayTemplate(Context context, String alertStatus,
                                                             boolean isProfile) {
                        String displayTemplate;
                        if (StringUtils.isNotBlank(alertStatus) && !isProfile) {
                            switch (alertStatus) {

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

                      public static RegisterConfiguration defaultRegisterConfiguration(Context context) {
                          if (context == null) {
                              return null;
                          }
                  
                  
                    Severity
                    Category
                    Status
                    Source
                    Language