OpenSRP/opensrp-client-anc

View on GitHub

Showing 306 of 436 total issues

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;
                        }

    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

                              if (fieldObject.has(ConstantsUtils.KeyUtils.SECONDARY_VALUES) &&
                                      fieldObject.getJSONArray(ConstantsUtils.KeyUtils.SECONDARY_VALUES).length() > 0) {
                                  JSONArray secondaryValues = fieldObject.getJSONArray(ConstantsUtils.KeyUtils.SECONDARY_VALUES);
                                  for (int count = 0; count < secondaryValues.length(); count++) {
                                      JSONObject secondaryValuesJSONObject = secondaryValues.getJSONObject(count);

        Method checkBoxWriteValue has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            protected void checkBoxWriteValue(String stepName, String parentKey, String childObjectKey, String childKey,
                                              String value, boolean popup) throws JSONException {

          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

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

              private Map<String, JSONArray> loadSubFormFields(JSONObject taskValue, Context context) {
                  JSONArray fields = new JSONArray();
                  String mlsPropertyFile = "";
                  Map<String, JSONArray> stringJSONArrayMap = new HashMap<>();
                  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

          Consider simplifying this complex logical expression.
          Open

                      if (StringUtils.isNotBlank(value) && value.contains(".") && !value.contains(",") && value.charAt(0) != '[' && !value.contains("{") && value.contains(JsonFormConstants.TEXT)) {
                          return NativeFormLangUtils.translateDatabaseString(value.trim(), AncLibrary.getInstance().getApplicationContext());
                      }
          Severity: Major
          Found in opensrp-anc/src/main/java/org/smartregister/anc/library/util/Utils.java - About 40 mins to fix

            Method setQuickCheckButtonsVisible has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                private void setQuickCheckButtonsVisible(boolean none, boolean other, LinearLayout buttonLayout, Button referButton, Button proceedButton) {

              Method init has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public static void init(@NonNull Context context, int dbVersion, @NonNull ActivityConfiguration activityConfiguration, @Nullable SubscriberInfoIndex subscriberInfoIndex, @Nullable RegisterQueryProvider registerQueryProvider) {
              Severity: Minor
              Found in opensrp-anc/src/main/java/org/smartregister/anc/library/AncLibrary.java - About 35 mins to fix

                Method setQuickCheckButtonsInvisible has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    private void setQuickCheckButtonsInvisible(boolean none, boolean other, LinearLayout buttonLayout, Button referButton, Button proceedButton) {

                  Method getFooterView has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      public void getFooterView(RecyclerView.ViewHolder viewHolder, int currentPageCount, int totalPageCount, boolean hasNext,
                                                boolean hasPrevious) {

                    Method getFooterView has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        public void getFooterView(RecyclerView.ViewHolder viewHolder, int currentPageCount, int totalPageCount, boolean hasNext,
                                                  boolean hasPrevious) {

                      Method updateEventAndRequiredStepsField has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          private void updateEventAndRequiredStepsField(String baseEntityId, PartialContactRepository partialContactRepository,
                                                                        List<PartialContact> partialContactList, Facts facts, List<String> formSubmissionIDs) throws Exception {

                        Method addMapValues has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

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

                          Method createEvent has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              private void createEvent(String baseEntityId, String attentionFlagsString, Pair<Event, Event> eventPair,
                                                       String referral, String currentContactState)

                            Method unSync has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                private boolean unSync(ECSyncHelper ecSyncHelper, DetailsRepository detailsRepository, List<Table> bindObjects,
                                                       Event event, String registeredAnm) {

                              Method getAutoPopulatedSiteCharacteristicsEditFormString has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  public static String getAutoPopulatedSiteCharacteristicsEditFormString(Context context,
                                                                                                         Map<String, String> characteristics) {
                                      try {
                                          JSONObject form = FormUtils.getInstance(context).getFormJson(ConstantsUtils.JsonFormUtils.ANC_SITE_CHARACTERISTICS);
                                          Timber.d("Form is %s", form.toString());

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

                                  @Override
                                  protected void onViewClicked(View view) {
                                      if (view.getId() == R.id.search) {
                                          search();
                                      } else if (view.getId() == R.id.undo_button) {

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

                                  private void populateTestDetails(List<YamlConfigWrapper> data, Facts facts) {
                                      if (data != null && data.size() > 0) {
                                          for (int position = 0; position < data.size(); position++) {
                                              if (data.get(position).getYamlConfigItem() != null) {
                                                  ConstraintLayout constraintLayout = formUtils.createListViewItems(data, facts, position, 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

                              Severity
                              Category
                              Status
                              Source
                              Language