OpenSRP/opensrp-client-anc

View on GitHub

Showing 436 of 436 total issues

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;

    Method updateDefaultValues has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private void updateDefaultValues(JSONArray stepArray, int i, JSONObject fieldObject) throws JSONException {
            if (defaultValueFields.contains(fieldObject.getString(JsonFormConstants.KEY))) {
    
                if (!fieldObject.has(JsonFormConstants.VALUE) ||
                        TextUtils.isEmpty(fieldObject.getString(JsonFormConstants.VALUE))) {

      Method returnTranslatedStringJoinedValue has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          @SuppressLint({"NewApi"})
          public static String returnTranslatedStringJoinedValue(String value) {
              try {
                  if (StringUtils.isNotBlank(value) && value.startsWith("[")) {
                      if (Utils.checkJsonArrayString(value)) {

        Method saveRegistration has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

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

          Method processViewCustomizations has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              @Override
              public void processViewCustomizations() {
                  try {
                      String jsonString =
                              getJsonViewFromPreference(ConstantsUtils.VIEW_CONFIGURATION_PREFIX + ConstantsUtils.ConfigurationUtils.LOGIN);

            Method populatePatientColumn has 40 lines of code (exceeds 25 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);

              Method createSecondaryFormObject has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static JSONObject createSecondaryFormObject(JSONObject parentObject, JSONObject jsonSubForm, String encounterType)
                          throws JSONException {
                      Map<String, String> vMap = new HashMap<>();
                      JSONObject resultJsonObject = new JSONObject();
                      JSONObject stepJsonObject = new JSONObject();

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

                  protected static void processPopulatableFields(Map<String, String> womanClient, JSONObject jsonObject)
                          throws JSONException {
              
                      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 getImmediatePreviousContact has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  @Override
                  public Facts getImmediatePreviousContact(Map<String, String> clientDetails, String baseEntityId, String contactNo) {
                      Facts facts = new Facts();
                      try {
                          facts = AncLibrary.getInstance().getPreviousContactRepository().getPreviousContactFacts(baseEntityId, contactNo, 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 onBindViewHolder has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  @Override
                  public void onBindViewHolder(@NonNull ViewHolder viewHolder, int position) {
                      if (lastContactDetailsList.size() > 0) {
                          LastContactDetailsWrapper lastContactDetails = lastContactDetailsList.get(position);
                          Facts facts = lastContactDetails.getFacts();

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

                  private void populateLocationSpinner(JSONObject jsonObject, String parentLocationId, String spinnerKey,
                                                       List<String> controlsToHide) {
                      List<Location> locations = Utils.getLocationsByParentId(parentLocationId);
                      String selectedLocation = Utils.getCurrentLocation(spinnerKey, jsonFormView);
              
              

              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

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                  @Override
                  public void getFooterView(RecyclerView.ViewHolder viewHolder, int currentPageCount, int totalPageCount, boolean hasNext,
                                            boolean hasPrevious) {
                      FooterViewHolder footerViewHolder = (FooterViewHolder) viewHolder;
                      footerViewHolder.pageInfoView
              opensrp-anc/src/main/java/org/smartregister/anc/library/provider/RegisterProvider.java on lines 74..86

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 104.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                  @Override
                  public void getFooterView(RecyclerView.ViewHolder viewHolder, int currentPageCount, int totalPageCount, boolean hasNext,
                                            boolean hasPrevious) {
                      FooterViewHolder footerViewHolder = (FooterViewHolder) viewHolder;
                      footerViewHolder.pageInfoView
              opensrp-anc/src/main/java/org/smartregister/anc/library/provider/AdvancedSearchProvider.java on lines 102..114

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 104.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Severity
              Category
              Status
              Source
              Language