Skip to content

Suggest replacing size() == 0 with isEmpty() for collection check #16428

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

2-say
Copy link
Contributor

@2-say 2-say commented Jan 16, 2025

Suggestion: Consider using isEmpty() instead of size() == 0

I hope this doesn’t cause any inconvenience, but I was wondering if there’s a specific reason why size() == 0 is used instead of isEmpty(). Using isEmpty() can make the code more readable and aligns with modern Java practices. It conveys the intent more clearly, improving overall clarity.

I apologize for taking your time and appreciate your consideration.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 16, 2025
Consider using isEmpty() instead of size() == 0 to improve code readability
and follow modern Java practices.

Signed-off-by: 2-say <dev2say@gmail.com>
@2-say 2-say force-pushed the refactor-replace-size-check-with-isEmpty branch from f09f74f to 5af136e Compare January 16, 2025 19:46
@jzheaux jzheaux self-assigned this Jan 16, 2025
@jzheaux jzheaux added in: core An issue in spring-security-core type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Jan 16, 2025
@jzheaux jzheaux added this to the 6.5.0-M1 milestone Jan 16, 2025
@jzheaux jzheaux merged commit 33ecb44 into spring-projects:main Jan 16, 2025
6 checks passed
@jzheaux
Copy link
Contributor

jzheaux commented Jan 16, 2025

Thanks for this PR, @2-say!

I apologize for taking your time and appreciate your consideration.

You don't need to apologize. Your PR made a good point and, anyway, supporting contributors is one of the best parts of open source! I hope you submit more PRs in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core An issue in spring-security-core type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants