OpenSRP/opensrp-client-anc

View on GitHub

Showing 306 of 436 total issues

Method compareItemAndValueGlobal has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    private static boolean compareItemAndValueGlobal(String itemValue, String globalValue) {
        if (!TextUtils.isEmpty(itemValue) && !TextUtils.isEmpty(globalValue)) {
            List<String> globalValuesList = new ArrayList<>();
            if (globalValue.startsWith("[")) {
                String[] globalValuesArray = globalValue.substring(1, globalValue.length() - 1).split(", ");

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 finalizeContactForm has a Cognitive Complexity of 16 (exceeds 5 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);

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

    @Override
    protected void checkBoxWriteValue(String stepName, String parentKey, String childObjectKey, String childKey,
                                      String value, boolean popup) throws JSONException {
        synchronized (getmJSONObject()) {
            JSONObject jsonObject = getmJSONObject().getJSONObject(stepName);

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

    @Override
    public AdvancedMatrixCursor createMatrixCursor(Response<String> response) {
        String[] columns = new String[]{"_id", "relationalid", DBConstantsUtils.KeyUtils.FIRST_NAME, DBConstantsUtils.KeyUtils.LAST_NAME,
                DBConstantsUtils.KeyUtils.DOB,DBConstantsUtils.KeyUtils.EDD, DBConstantsUtils.KeyUtils.ANC_ID, DBConstantsUtils.KeyUtils.PHONE_NUMBER, DBConstantsUtils.KeyUtils.ALT_NAME,DBConstantsUtils.KeyUtils.NEXT_CONTACT,DBConstantsUtils.KeyUtils.NEXT_CONTACT_DATE};
        AdvancedMatrixCursor matrixCursor = new AdvancedMatrixCursor(columns);

    Method proceedToContact has 49 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static void proceedToContact(String baseEntityId, HashMap<String, String> personObjectClient, Context context) {
            try {
    
                Intent intent = new Intent(context.getApplicationContext(), ContactJsonFormActivity.class);
                Contact quickCheck = new Contact();

      Method fetchUpcomingContacts has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

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

        Method onResumption has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            @Override
            protected void onResumption() {
                try {
                    fetchContactAndAlertStatus();
                    yamlConfigListGlobal = new ArrayList<>(); //This makes sure no data duplication happens

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

            private static void updateLocationTree(@NonNull JSONArray fields,
                                                   @NonNull String defaultLocationString,
                                                   @NonNull String defaultFacilityString,
                                                   @NonNull String entireTreeString) {
                AncMetadata ancMetadata = AncLibrary.getInstance().getAncMetadata();

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

            @Override
            protected void onActivityResult(int requestCode, int resultCode, Intent data) {
                if (requestCode == AllConstants.BARCODE.BARCODE_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
                    if (data != null) {
                        Barcode barcode = data.getParcelableExtra(AllConstants.BARCODE.BARCODE_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 updateStatusIcon has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            private void updateStatusIcon(JSONObject taskValue, ContactTasksViewHolder contactTasksViewHolder) {
                try {
                    if (taskValue.has(JsonFormConstants.VALUE)) {
                        JSONArray values = taskValue.getJSONArray(JsonFormConstants.VALUE);
                        for (int i = 0; i < values.length(); i++) {

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

            public void process() throws Exception {
                //Get actual Data
                JSONObject object;
        
                List<PartialContact> partialContacts = getPartialContactRepository()

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

          Method onViewClicked has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              @Override
              protected void onViewClicked(View view) {
                  if (getActivity() == 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

          Method processRadioButtonsSpecialWidget has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              private static void processRadioButtonsSpecialWidget(JSONObject widget, List<String> valueList) throws Exception {
                  //Value already good for radio buttons so no keylist
                  JSONArray jsonArray = widget.getJSONArray(JsonFormConstants.OPTIONS_FIELD_NAME);
          
                  for (int i = 0; i < jsonArray.length(); i++) {

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

              private void populateGlobalSettingsCore(Setting setting) {
                  try {
                      JSONObject settingObject = setting != null ? new JSONObject(setting.getValue()) : null;
                      if (settingObject != null) {
                          JSONArray settingArray = settingObject.getJSONArray(AllConstants.SETTINGS);

          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 14 (exceeds 5 allowed). Consider refactoring.
          Open

                  @Override
                  public void onClick(View view) {
                      getJsonApi().setPreviousPressed(false);
                      if (view.getId() == com.vijay.jsonwizard.R.id.next || view.getId() == com.vijay.jsonwizard.R.id.next_icon) {
                          Object tag = view.getTag(com.vijay.jsonwizard.R.id.NEXT_STATE);

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

              private boolean checkTestsStatus(JSONArray valueArray) {
                  boolean isTask = false;
                  try {
                      for (int i = 0; i < valueArray.length(); i++) {
                          JSONObject value = valueArray.getJSONObject(i);

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

              public static Map<String, String> getWomanProfileDetails(String baseEntityId) {
                  Cursor cursor = null;
          
                  Map<String, String> detailsMap = null;
                  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 getPreviousContactTestsFacts has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

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

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

              public Facts getPreviousContactFacts(String baseEntityId, String contactNo, boolean checkNegative) {
                  Cursor mCursor = null;
                  String selection = "";
                  String orderBy = "MAX("+ ID + ") DESC";
                  String[] selectionArgs = null;
            Severity
            Category
            Status
            Source
            Language