Skip to content

FINERACT-2555: Refactor string validation by removing redundant length check#5695

Open
tiagosune wants to merge 1 commit intoapache:developfrom
tiagosune:refactor-ip-check
Open

FINERACT-2555: Refactor string validation by removing redundant length check#5695
tiagosune wants to merge 1 commit intoapache:developfrom
tiagosune:refactor-ip-check

Conversation

@tiagosune
Copy link
Copy Markdown

@tiagosune tiagosune commented Mar 25, 2026

Description

This PR simplifies string validation by removing redundant checks.

The previous condition used both length() != 0 and isEmpty(), which is unnecessary.
The updated version uses only !isEmpty(), improving readability and following best practices.

This change also aligns with SonarQube recommendations.

No functional changes are introduced.

Checklist

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Write the commit message as per our guidelines
  • Acknowledge that we will not review PRs that are not passing the build ("green") - it is your responsibility to get a proposed PR to pass the build, not primarily the project's maintainers.
  • Create/update unit or integration tests for verifying the changes made.
  • Follow our coding conventions.
  • Add required Swagger annotation and update API documentation at fineract-provider/src/main/resources/static/legacy-docs/apiLive.htm with details of any API changes
  • This PR must not be a "code dump". Large changes can be made in a branch, with assistance. Ask for help on the developer mailing list.

Your assigned reviewer(s) will follow our guidelines for code reviews.

Copy link
Copy Markdown

@dr-fuch dr-fuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe your change is OK.

I noticed that IP_HEADER_CANDIDATES in the corresponding test is defined but never used. Maybe we can define it in IpAddressUtils and use it in both CallerIpTrackingFilter and IpTrackingFilterTest classes, respectively.

I'm not sure if we should address that last observation within this ticket (changing its scope) or create a new one just for that.

Don't forget to assign the Jira ticket to yourself, since you just created it.

I suggest keeping just one commit for this PR; it seems you included an extra blank commit.

@tiagosune
Copy link
Copy Markdown
Author

I believe your change is OK.

I noticed that IP_HEADER_CANDIDATES in the corresponding test is defined but never used. Maybe we can define it in IpAddressUtils and use it in both CallerIpTrackingFilter and IpTrackingFilterTest classes, respectively.

I'm not sure if we should address that last observation within this ticket (changing its scope) or create a new one just for that.

Don't forget to assign the Jira ticket to yourself, since you just created it.

I suggest keeping just one commit for this PR; it seems you included an extra blank commit.

Thank you for the review and the suggestions!

I agree that extracting IP_HEADER_CANDIDATES into IpAddressUtils would improve code reuse and consistency.

To keep this PR focused, I suggest creating a separate JIRA ticket for that improvement. I can work on it right after this PR.

I also noticed that I don't have permission to assign the JIRA ticket to myself, but I would be happy to take ownership of it.

I will clean up the commits as suggested.

@tiagosune tiagosune requested a review from dr-fuch March 26, 2026 16:32
Copy link
Copy Markdown

@dr-fuch dr-fuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the latest check failures.

@tiagosune
Copy link
Copy Markdown
Author

Please check the latest check failures.

The issue was related to commit signing. I’ve re-signed the commit using GPG and force-pushed the updated commit.

Please let me know if everything looks good now.

@tiagosune
Copy link
Copy Markdown
Author

I’ve re-triggered the CI by amending the commit to verify if the E2E failures were transient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants