Skip to content
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

[MNG-6829] Replace StringUtils#isEmpty(String) & #isNotEmpty(String) #3

Conversation

timtebeek
Copy link
Contributor

Last batch of is(Not)Empty for https://issues.apache.org/jira/browse/MNG-6829
These are the smallest change sets, hence why I opened more at the same time.
After this we can target the next most often used method from the StringUtils classes.


Use this link to re-run the recipe: https://public.moderne.io/recipes/org.openrewrite.java.migrate.apache.commons.lang.IsNotEmptyToJdk?organizationId=QXBhY2hlIE1hdmVu

Co-authored-by: Moderne <team@moderne.io>
{
cli.createArg().setValue( "-providerName" );
cli.createArg().setValue( providerName );
}

String providerClass = request.getProviderClass();
if ( !StringUtils.isEmpty( providerClass ) )
if ( !(providerClass == null || providerClass.isEmpty()) )
Copy link

Choose a reason for hiding this comment

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

I guess the recipe doesn't pick up the ! in StringUtils.isEmpty( providerClass )? This isn't the same replacement as StringUtils.isNotEmpty.

Copy link
Contributor Author

@timtebeek timtebeek May 23, 2023

Choose a reason for hiding this comment

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

No it's a bit unfortunate; would have required a separate recipe (or targeted manual change) to first replace the !StringUtils.isEmpty with StringUtils.isNotEmpty. But then since we are phasing these out we decided against it on an earlier pull request.

In this specific case we can fix these manually here if you'd like, as I imagine checkstyle will have its complaints as well.

@elharo elharo merged commit 15c9bf9 into apache:master May 23, 2023
@timtebeek timtebeek deleted the refactor/replace-any-string-utils-is-empty-string-and-is-not-empty-string branch May 23, 2023 13:08
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