OpenSRP/opensrp-client-anc

View on GitHub

Showing 306 of 436 total issues

Method search has a Cognitive Complexity of 12 (exceeds 5 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)) {

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

    private static String cleanValueResult(String result) {
        List<String> nonEmptyItems = new ArrayList<>();
        for (String item : result.split(",")) {
            if (item.length() > 0 && StringUtils.isNotBlank(item)) {
                nonEmptyItems.add(item);

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

    @Override
    public void saveSiteCharacteristics(Map<String, String> siteCharacteristicsSettingsMap) throws JSONException {

        JSONArray localSettings;
        JSONObject settingObject;

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

    @Override
    public void onBindViewHolder(@NonNull PreviousContactsAdapter.ViewHolder viewHolder, int position) {
        if (factsList.size() > 0) {
            try {
                String contactNo = String.valueOf(factsList.size() - position);

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

    private void savePreviousTaskDetails(String contactNo, Task task) {
        try {
            JSONObject taskValue = new JSONObject(task.getValue());
            if (taskValue.has(JsonFormConstants.VALUE)) {
                JSONArray value = taskValue.getJSONArray(JsonFormConstants.VALUE);

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

    private Response<String> globalSearch(Map<String, String> map) {
        String baseUrl = getDristhiConfiguration().dristhiBaseURL();
        String paramString = "";
        if (!map.isEmpty()) {
            for (Map.Entry<String, String> entry : map.entrySet()) {

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

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getViewLayoutId());
        actionBar = getSupportActionBar();

    Method process has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private void process(String[] mainContactForms) {
            //Fetch and load previously saved values
            try {
                if (contactNo > 1 && !PatientRepository.isFirstVisit(baseEntityId)) {
                    for (String formEventType : new ArrayList<>(Arrays.asList(mainContactForms))) {

      Method saveSiteCharacteristics has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          @Override
          public void saveSiteCharacteristics(Map<String, String> siteCharacteristicsSettingsMap) throws JSONException {
      
              JSONArray localSettings;
              JSONObject settingObject;

        Method init has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            @Override
            public void init(String json) {
                try {
                    setmJSONObject(new JSONObject(json));
                    if (!getmJSONObject().has(ConstantsUtils.JsonFormKeyUtils.ENCOUNTER_TYPE)) {

          Method processFormFieldKeyValues has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private void processFormFieldKeyValues(String baseEntityId, JSONObject object, String contactNo) throws Exception {
                  if (object != null) {
                      persistRequiredInvisibleFields(baseEntityId, contactNo, object);
                      Iterator<String> keys = object.keys();
          
          

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

                public static String keyToValueConverter(String keys) {
                    if (keys != null) {
                        String cleanKey = "";
                        String value = cleanValue(keys);
                        if (!value.contains(JsonFormConstants.TEXT) || !value.contains(".") && StringUtils.isNotBlank(value)) {

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

                private void initializeLastContactDetails(HashMap<String, String> clientDetails) {
                    if (clientDetails != null) {
                        try {
                            List<LastContactDetailsWrapper> lastContactDetailsWrapperList = new ArrayList<>();
                            List<LastContactDetailsWrapper> lastContactDetailsTestsWrapperList = 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 getDefaultLocation has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                private static String getDefaultLocation(String level, String villageId) {
                    Location village = Utils.getLocationById(villageId);
                    Location facility = Utils.getLocationById(village != null ? village.getProperties().getParentId() : "");
                    Location subDistrict = Utils.getLocationById(facility != null ? facility.getProperties().getParentId() : "");
                    Location district = Utils.getLocationById(subDistrict != null ? subDistrict.getProperties().getParentId() : "");

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

                @Override
                public void loadPreviousContacts(String baseEntityId, String contactNo) {
                    List<PreviousContactsSummaryModel> allContactsFacts = getPreviousContactRepository()
                            .getPreviousContactsFacts(baseEntityId);
                    LinkedHashMap<String, List<Facts>> filteredContacts = new LinkedHashMap<>();

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

                private void populateLocationSpinner(String parentLocationId, String spinnerKey, List<String> controlsToHide) {
                    List<Location> locations = Utils.getLocationsByParentId(parentLocationId);
                    String selectedLocation = Utils.getCurrentLocation(spinnerKey, jsonFormView);
            
                    MaterialSpinner spinner = (MaterialSpinner) jsonFormView.getFormDataView(STEP1 + ":" + spinnerKey);

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

                public void createSavePdf(Context context, List<YamlConfig> yamlConfigList, Facts facts,String womanName) throws FileNotFoundException {
            
                    String FILENAME = womanName+"_"+context.getResources().getString(R.string.contact_summary_data_file);
                    String filePath = getAppPath(context) + FILENAME;
            
            

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

                public static void processCheckboxFilteredItems(JSONObject mainJsonObject) throws JSONException {
            
                    if (!mainJsonObject.has(ConstantsUtils.FILTERED_ITEMS) || mainJsonObject.getJSONArray(ConstantsUtils.FILTERED_ITEMS).length() < 1) {
                        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 updateFormGlobalValuesFromExpansionPanel has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                private void updateFormGlobalValuesFromExpansionPanel(JSONObject fieldObject) throws JSONException {
                    if (fieldObject.has(JsonFormConstants.VALUE) && fieldObject.has(JsonFormConstants.TYPE)
                            && TextUtils.equals(JsonFormConstants.EXPANSION_PANEL, fieldObject.getString(JsonFormConstants.TYPE))) {
            
                        JSONArray accordionValue = fieldObject.getJSONArray(JsonFormConstants.VALUE);

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

            Severity
            Category
            Status
            Source
            Language