vendredi 18 septembre 2020

How to avoid "Change this condition so that it does not always evaluate to "false""

Hello iam analyzing my code using sonarqube and am running into a bug for the following method

    final Boolean active = this.fromApiJsonHelper.extractBooleanNamed(GroupingTypesApiConstants.activeParamName, element);
        if (active != null) {
            if (active.booleanValue()) {
                final LocalDate joinedDate = this.fromApiJsonHelper.extractLocalDateNamed(
                        GroupingTypesApiConstants.activationDateParamName, element);
                baseDataValidator.reset().parameter(GroupingTypesApiConstants.activationDateParamName).value(joinedDate).notNull();
            } else {
                // TODO - KW - not using config for now - just supporting move
                // to pending or active out of box.
                final boolean isPendingApprovalEnabled = true;
                if (!isPendingApprovalEnabled) {
                    baseDataValidator.reset().parameter(GroupingTypesApiConstants.activeParamName)
                            .failWithCode(".pending.status.not.allowed");
                }
            }
        } else {
            baseDataValidator.reset().parameter(ClientApiConstants.activeParamName).value(active).trueOrFalseRequired(false);
        }

sonarqube saying that "Change this condition so that it does not always evaluate to "false" , in statement "if (!isPendingApprovalEnabled)"

Aucun commentaire:

Enregistrer un commentaire