OpenSRP/opensrp-client-anc

View on GitHub

Showing 306 of 436 total issues

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

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {

        if (!TextUtils.isEmpty(mData.get(position).getGroup())) {

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

    private void updateFormGlobalValues(JSONObject fieldObject) throws Exception {
        if (globalKeys.contains(fieldObject.getString(JsonFormConstants.KEY)) &&
                fieldObject.has(JsonFormConstants.VALUE)) {

            formGlobalValues.put(fieldObject.getString(JsonFormConstants.KEY),

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

    public boolean saveOrUpdateTasks(Task task) {
        if (task == null) return false;
        if (StringUtils.isNoneBlank(task.getBaseEntityId())) {
            if (task.getId() != null) {
                String sqlQuery = ID + " = ? " + BaseRepository.COLLATE_NOCASE;

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

    private void finishAdapterOnPostExecute() {
        HashMap<String, String> clientDetails;
        try {
            clientDetails = (HashMap<String, String>) intent.getSerializableExtra(ConstantsUtils.IntentKeyUtils.CLIENT_MAP);
        } catch (NullPointerException e) {

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

    @Override
    protected void onActivityResultExtended(int requestCode, int resultCode, Intent data) {
        if (requestCode == ANCJsonFormUtils.REQUEST_CODE_GET_JSON && resultCode == Activity.RESULT_OK) {
            try {
                String jsonString = data.getStringExtra(ConstantsUtils.JsonFormExtraUtils.JSON);

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

    @Override
    public void onBackPressed() {
        Fragment fragment = findFragmentByPosition(currentPage);
        if (fragment instanceof AdvancedSearchFragment) {
            ((AdvancedSearchFragment) fragment).onBackPressed();

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

    public PartialContacts invoke() {
        partialContactRepository = AncLibrary.getInstance().getPartialContactRepository();

        if (partialContactRepository != null) {
            if (isFirst) {

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

    public List<Task> getTasks(String baseEntityId, List<String> keysList) {
        String orderBy = ID + " DESC ";
        Cursor mCursor = null;
        String selection = "";
        String[] selectionArgs = new String[]{};

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

    @Override
    public void onClick(View view) {
        try {
            //To show current date in the datepicker
            Calendar mcurrentDate = Calendar.getInstance();

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

    public List<PreviousContact> getPreviousContacts(String baseEntityId, List<String> keysList) {
        String orderBy = ID + " DESC ";
        Cursor mCursor = null;
        String selection = "";
        String[] selectionArgs = 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 createSearchString has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

        String createSearchString(String firstName, String lastName, String ancId, String edd, String dob,
                                  String phoneNumber, String alternateContact);

    Method createSearchString has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public String createSearchString(String firstName, String lastName, String ancId, String edd, String dob,
                                         String phoneNumber, String alternateContact) {

      Method writeValue has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public void writeValue(String stepName, String key, String value, String openMrsEntityParent, String openMrsEntity,
                                 String openMrsEntityId, boolean popup) throws JSONException {

        Method callSuperWriteValue has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            protected void callSuperWriteValue(String stepName, String key, String value, String openMrsEntityParent,
                                               String openMrsEntity, String openMrsEntityId, Boolean popup) throws JSONException {

          Avoid deeply nested control flow statements.
          Open

                                  if (isRequiredField && ((fieldObject.has(JsonFormConstants.VALUE) && TextUtils.isEmpty(
                                          fieldObject.getString(JsonFormConstants.VALUE))) || !fieldObject.has(JsonFormConstants.VALUE))) {
                                      //TO DO Remove/ Alter logical condition
                                      return true;
                                  }
          Severity: Major
          Found in opensrp-anc/src/main/java/org/smartregister/anc/library/util/Utils.java - About 45 mins to fix

            Method getRemoteLocalMatrixCursor has a Cognitive Complexity of 8 (exceeds 5 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(

            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 init has 6 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, @Nullable AncMetadata metadata) {
            Severity: Minor
            Found in opensrp-anc/src/main/java/org/smartregister/anc/library/AncLibrary.java - About 45 mins to fix

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

                  private void addOtherRuleObjects(Facts facts) throws IOException {
                      Iterable<Object> ruleObjects = utils.loadRulesFiles(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 startForm has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  @Override
                  public void startForm(Object tag) {
                      try {
                          if (!(tag instanceof Contact) && getView() == null) {
                              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 (fieldKey != null && fieldObject.has(JsonFormConstants.VALUE) && fieldObject.has(JsonFormConstants.TYPE)
                                              && !JsonFormConstants.EXPANSION_PANEL.equals(fieldObject.getString(JsonFormConstants.TYPE))) {
                                          if (JsonFormConstants.CHECK_BOX.equals(fieldObject.optString(JsonFormConstants.TYPE, ""))) {
                                              String value = Utils.getProperties(context).getProperty(ConstantsUtils.Properties.WIDGET_VALUE_TRANSLATED, "false");
                                              if (StringUtils.isNotBlank(value) && Boolean.parseBoolean(value)) {
                Severity
                Category
                Status
                Source
                Language