OpenSRP/opensrp-client-anc

View on GitHub

Showing 436 of 436 total issues

Method processAttentionFlags has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    private void processAttentionFlags(WomanDetail patientDetail, Facts facts) throws IOException {
        Iterable<Object> ruleObjects = AncLibrary.getInstance().readYaml(FilePathUtils.FileUtils.ATTENTION_FLAGS);
        int redCount = 0;
        int yellowCount = 0;

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

    private String getCurrentContactState(String baseEntityId) throws JSONException {
        List<PreviousContact> previousContactList = getPreviousContactRepository().getPreviousContacts(baseEntityId, null);
        JSONObject stateObject = null;
        if (previousContactList != null) {
            stateObject = 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 onBindViewHolder has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

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

    Method getPreviousContacts has 31 lines of code (exceeds 25 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;

      Method getTasks has 31 lines of code (exceeds 25 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[]{};

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

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

              public class FooterViewHolder extends RecyclerView.ViewHolder {
                  private TextView pageInfoView;
                  private Button nextPageView;
                  private Button previousPageView;
          
          
          opensrp-anc/src/main/java/org/smartregister/anc/library/provider/RegisterProvider.java on lines 269..281

          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 84.

          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

              public class FooterViewHolder extends RecyclerView.ViewHolder {
                  private TextView pageInfoView;
                  private Button nextPageView;
                  private Button previousPageView;
          
          
          opensrp-anc/src/main/java/org/smartregister/anc/library/provider/AdvancedSearchProvider.java on lines 276..288

          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 84.

          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

          Method search has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public void search(String firstName, String lastName, String ancId, String edd, String dob, String phoneNumber,
                                 String alternateContact, boolean isLocal) {
                  String searchCriteria =
                          model.createSearchString(firstName, lastName, ancId, edd, dob, phoneNumber, alternateContact);
                  if (StringUtils.isBlank(searchCriteria)) {

            Method processPopulatableFields has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected static void processPopulatableFields(Map<String, String> womanClient, JSONObject jsonObject)
                        throws JSONException {
            
                    AncMetadata ancMetadata = AncLibrary.getInstance().getAncMetadata();
            
            

              Method createPreviousVisitFromGroup has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static void createPreviousVisitFromGroup(@NonNull String strGroup, @NonNull String
                          baseEntityId) throws JSONException {
                      JSONObject jsonObject = new JSONObject(strGroup);
                      Iterator<String> repeatingGroupKeys = jsonObject.keys();
                      List<String> currentFormSubmissionIds = new ArrayList<>();

                Method getWomanProfileDetails has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static Map<String, String> getWomanProfileDetails(String baseEntityId) {
                        Cursor cursor = null;
                
                        Map<String, String> detailsMap = null;
                        try {

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

                    Method getAllTestResultsForIndividualTest has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public Facts getAllTestResultsForIndividualTest(String baseEntityId, String indicator, String dateKey) {
                            String orderBy = ID + " DESC ";
                            String[] selectionArgs = null;
                            String selection = "";
                    
                    

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

                          private void addAttentionFlagsRuleObjects(Facts facts) throws IOException {
                              Iterable<Object> ruleObjects = loadFile(FilePathUtils.FileUtils.ATTENTION_FLAGS);
                      
                              for (Object ruleObject : ruleObjects) {
                                  YamlConfig attentionFlagConfig = (YamlConfig) ruleObject;
                      opensrp-anc/src/main/java/org/smartregister/anc/library/adapter/PreviousContactsAdapter.java on lines 123..139

                      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 82.

                      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

                          private void addAttentionFlagsRuleObjects(Facts facts) throws IOException {
                              Iterable<Object> attentionFlagsRuleObjects = loadFile(FilePathUtils.FileUtils.ATTENTION_FLAGS);
                      
                              for (Object ruleObject : attentionFlagsRuleObjects) {
                                  YamlConfig attentionFlagConfig = (YamlConfig) ruleObject;
                      opensrp-anc/src/main/java/org/smartregister/anc/library/activity/PreviousContactsDetailsActivity.java on lines 215..227

                      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 82.

                      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

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

                          public static final class PrescriptionUtils{
                              public static final String VITA = "vita";
                              public static final String MAG_CALC = "mag_calc";
                              public static final String NAUSEA_PHARMA = "nausea_pharma";
                              public static final String ALBEN_MEBEN = "alben_meben";
                      opensrp-anc/src/main/java/org/smartregister/anc/library/util/ConstantsUtils.java on lines 170..184

                      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 80.

                      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

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

                          public static final class KeyUtils {
                              public static final String KEY = "key";
                              public static final String VALUE = "value";
                              public static final String TYPE = "type";
                              public static final String TREE = "tree";
                      opensrp-anc/src/main/java/org/smartregister/anc/library/util/ConstantsUtils.java on lines 216..230

                      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 80.

                      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

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

                        Method onClick has 29 lines of code (exceeds 25 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);
                          Severity
                          Category
                          Status
                          Source
                          Language