OpenSRP/opensrp-client-anc

View on GitHub

Showing 306 of 436 total issues

Method processEventClient has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    @Override
    public void processEventClient(@NonNull EventClient eventClient, @NonNull List<Event> unsyncEvents, @Nullable ClientClassification clientClassification) throws Exception {
        Event event = eventClient.getEvent();
        if (event == 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 too many return statements within this method.
Open

            return "";
Severity: Major
Found in opensrp-anc/src/main/java/org/smartregister/anc/library/util/Utils.java - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

                    return NativeFormLangUtils.translateDatabaseString(value.trim(), AncLibrary.getInstance().getApplicationContext());
    Severity: Major
    Found in opensrp-anc/src/main/java/org/smartregister/anc/library/util/Utils.java - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                  return value;
      Severity: Major
      Found in opensrp-anc/src/main/java/org/smartregister/anc/library/util/Utils.java - About 30 mins to fix

        Method filterAndSortQuery has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            private String filterAndSortQuery() {
                SmartRegisterQueryBuilder registerQueryBuilder = new SmartRegisterQueryBuilder(mainSelect);
        
                String query = "";
                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 registerLanguageSwitcher has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            private void registerLanguageSwitcher() {
                if (getActivity() != null) {
                    addLanguages();
        
                    languages = new String[locales.size()];

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

            private static void setSecondaryValues(JSONObject itemField, JSONArray secondaryValues) throws JSONException {
                for (int j = 0; j < secondaryValues.length(); j++) {
                    JSONObject secValue = secondaryValues.getJSONObject(j);
        
                    if (secValue.length() > 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 getFieldJSONObject has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public static JSONObject getFieldJSONObject(JSONArray jsonArray, String key) {
                if (jsonArray == null || jsonArray.length() == 0) {
                    return 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 onResumption has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            @Override
            protected void onResumption() {
                lastContactDetails = new ArrayList<>();
                lastContactTests = new ArrayList<>();
                if (testsDisplayLayout != 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 getCurrentLocation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public static String getCurrentLocation(String level, JsonFormActivity jsonFormView) {
                String villageId = CoreLibrary.getInstance().context().allSharedPreferences().fetchUserLocalityId(CoreLibrary.getInstance().context().allSharedPreferences().fetchRegisteredANM());
                String currentLocation = "";
        
                try {
        Severity: Minor
        Found in opensrp-anc/src/main/java/org/smartregister/anc/library/util/Utils.java - About 25 mins to fix

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

            @Override
            public void switchViews(boolean showList) {
                if (showList) {
                    Utils.hideKeyboard(getActivity());
        
        

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

            @Override
            public Loader<Cursor> onCreateLoader(int id, Bundle args) {
                if (id == RecyclerViewFragment.LOADER_ID) {// Returns a new CursorLoader
                    return new CursorLoader(getActivity()) {
                        @Override

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

            public static void finalizeForm(Activity context, HashMap<String, String> womanDetails, boolean isRefferal) {
                try {
        
                    Intent contactSummaryFinishIntent = new Intent(context, ContactSummaryFinishActivity.class);
                    contactSummaryFinishIntent
        Severity: Minor
        Found in opensrp-anc/src/main/java/org/smartregister/anc/library/util/Utils.java - About 25 mins to fix

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

            @Override
            public boolean isServerSettingsSet() {
        
                try {
                    Setting setting = AncLibrary.getInstance().getContext().allSettings()

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

            private void addAttentionFlagsRuleObjects(Facts facts) throws IOException {
                Iterable<Object> attentionFlagsRuleObjects = AncLibrary.getInstance().readYaml(FilePathUtils.FileUtils.ATTENTION_FLAGS);
        
                for (Object ruleObject : attentionFlagsRuleObjects) {
                    YamlConfig attentionFlagConfig = (YamlConfig) ruleObject;

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

            private void saveLanguage(String selectedLanguage) {
                if (MeFragment.this.getActivity() != null && StringUtils.isNotBlank(selectedLanguage)) {
                    Locale selectedLanguageLocale = locales.get(selectedLanguage);
                    if (selectedLanguageLocale != null) {
                        LangUtils.saveLanguage(MeFragment.this.getActivity().getApplication(), getFullLanguage(selectedLanguageLocale));

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

            private void updateSearchLimits() {
                if (Utils.isConnectedToNetwork(getActivity())) {
                    outsideInside.setChecked(true);
                    myCatchment.setChecked(false);
                } else {

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

            private static void processAbnormalValues(Facts facts, JSONObject jsonObject) throws Exception {
        
                //Expansion panel widgets have "values" attribute with no "value" do not process them
                //We will handle the processing somewhere else.
                if (jsonObject.has(JsonFormConstants.VALUES) && !jsonObject.has(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 processFormDetailsSave has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            @Override
            public void processFormDetailsSave(Intent data, AllSharedPreferences allSharedPreferences) {
                try {
                    String jsonString = data.getStringExtra(ConstantsUtils.IntentKeyUtils.JSON);
                    Timber.d(jsonString);

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

            @Override
            public void onUpcomingContactsFetched(List<ContactSummaryModel> upcomingContacts, Integer lastContact) {
                if ((upcomingContacts == null || upcomingContacts.isEmpty()) && lastContact >= 0) {
                    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

        Severity
        Category
        Status
        Source
        Language