[MNG-6829] Replace StringUtils#isEmpty(String) and #isNotEmpty(String) (#121)
Continuation of https://issues.apache.org/jira/browse/MNG-6829
Review requested of @elharo
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>
diff --git a/src/main/java/org/apache/maven/plugins/checkstyle/AbstractCheckstyleReport.java b/src/main/java/org/apache/maven/plugins/checkstyle/AbstractCheckstyleReport.java
index 0e39ecf..0c6d2ed 100644
--- a/src/main/java/org/apache/maven/plugins/checkstyle/AbstractCheckstyleReport.java
+++ b/src/main/java/org/apache/maven/plugins/checkstyle/AbstractCheckstyleReport.java
@@ -34,7 +34,6 @@
import com.puppycrawl.tools.checkstyle.api.AuditListener;
import com.puppycrawl.tools.checkstyle.api.AutomaticBean.OutputStreamOptions;
import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
-import org.apache.commons.lang3.StringUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Dependency;
@@ -602,7 +601,7 @@
protected AuditListener getListener() throws MavenReportException {
AuditListener listener = null;
- if (StringUtils.isNotEmpty(outputFileFormat)) {
+ if (outputFileFormat != null && !outputFileFormat.isEmpty()) {
File resultFile = outputFile;
OutputStream out = getOutputStream(resultFile);
diff --git a/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleViolationCheckMojo.java b/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleViolationCheckMojo.java
index 8a2f1be..41dc663 100644
--- a/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleViolationCheckMojo.java
+++ b/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleViolationCheckMojo.java
@@ -37,7 +37,6 @@
import com.puppycrawl.tools.checkstyle.api.AuditListener;
import com.puppycrawl.tools.checkstyle.api.AutomaticBean.OutputStreamOptions;
import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
-import org.apache.commons.lang3.StringUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Plugin;
@@ -772,7 +771,7 @@
private AuditListener getListener() throws MojoFailureException, MojoExecutionException {
AuditListener listener = null;
- if (StringUtils.isNotEmpty(outputFileFormat)) {
+ if (outputFileFormat != null && !outputFileFormat.isEmpty()) {
File resultFile = outputFile;
OutputStream out = getOutputStream(resultFile);
diff --git a/src/main/java/org/apache/maven/plugins/checkstyle/exec/DefaultCheckstyleExecutor.java b/src/main/java/org/apache/maven/plugins/checkstyle/exec/DefaultCheckstyleExecutor.java
index ad3a8c4..4eb28b7 100644
--- a/src/main/java/org/apache/maven/plugins/checkstyle/exec/DefaultCheckstyleExecutor.java
+++ b/src/main/java/org/apache/maven/plugins/checkstyle/exec/DefaultCheckstyleExecutor.java
@@ -402,7 +402,7 @@
getLogger().debug("headerLocation " + headerLocation);
}
- if (StringUtils.isNotEmpty(headerLocation)) {
+ if (headerLocation != null && !headerLocation.isEmpty()) {
try {
File headerFile = licenseLocator.getResourceAsFile(headerLocation, "checkstyle-header.txt");
@@ -551,7 +551,7 @@
if (resourcesDirectory.equals(request.getProject().getBasedir())) {
String resourceIncludes =
StringUtils.join(resource.getIncludes().iterator(), ",");
- if (StringUtils.isEmpty(includes)) {
+ if (includes == null || includes.isEmpty()) {
includes = resourceIncludes;
} else {
includes += "," + resourceIncludes;
@@ -559,7 +559,7 @@
String resourceExcludes =
StringUtils.join(resource.getExcludes().iterator(), ",");
- if (StringUtils.isEmpty(excludes)) {
+ if (excludes == null || excludes.isEmpty()) {
excludes = resourceExcludes;
} else {
excludes += "," + resourceExcludes;
@@ -594,7 +594,7 @@
private String getSuppressionsFilePath(final CheckstyleExecutorRequest request) throws CheckstyleExecutorException {
final String suppressionsLocation = request.getSuppressionsLocation();
- if (StringUtils.isEmpty(suppressionsLocation)) {
+ if (suppressionsLocation == null || suppressionsLocation.isEmpty()) {
return null;
}