Skip to content

Commit

Permalink
[MNG-6829] Replace any StringUtils#isEmpty(String) and #isNotEmpty(St…
Browse files Browse the repository at this point in the history
…ring) (#124)

* [MNG-6829] Replace any StringUtils#isEmpty(String) and #isNotEmpty(String)

### [Replace any StringUtils#isEmpty(String) and #isNotEmpty(String)](https://public.moderne.io/recipes/org.openrewrite.java.migrate.apache.commons.lang.IsNotEmptyToJdk)
  • Loading branch information
timtebeek authored Apr 19, 2023
1 parent 690dcbe commit 40fe444
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ protected String constructXRefLocation(boolean test) {

String relativePath =
PathTool.getRelativePath(outputDirectory.getAbsolutePath(), xrefLoc.getAbsolutePath());
if (StringUtils.isEmpty(relativePath)) {
if (relativePath == null || relativePath.isEmpty()) {
relativePath = ".";
}
relativePath = relativePath + "/" + xrefLoc.getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

import net.sourceforge.pmd.cpd.Mark;
import net.sourceforge.pmd.cpd.Match;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.pmd.model.CpdFile;
import org.apache.maven.plugins.pmd.model.Duplication;
Expand Down Expand Up @@ -99,7 +98,7 @@ private boolean fileExcludedByGroup(final String path, final Set<String> singleE

@Override
public void loadExcludeFromFailuresData(final String excludeFromFailureFile) throws MojoExecutionException {
if (StringUtils.isEmpty(excludeFromFailureFile)) {
if (excludeFromFailureFile == null || excludeFromFailureFile.isEmpty()) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.util.Set;

import net.sourceforge.pmd.RuleViolation;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.pmd.model.Violation;

Expand All @@ -45,7 +44,7 @@ public class ExcludeViolationsFromFile implements ExcludeFromFile<Violation> {

@Override
public void loadExcludeFromFailuresData(final String excludeFromFailureFile) throws MojoExecutionException {
if (StringUtils.isEmpty(excludeFromFailureFile)) {
if (excludeFromFailureFile == null || excludeFromFailureFile.isEmpty()) {
return;
}

Expand Down Expand Up @@ -107,9 +106,9 @@ private boolean isExcludedFromFailure(String className, String ruleName) {
private String extractClassName(String packageName, String className, String fullPath) {
// for some reason, some violations don't contain the package name, so we have to guess the full class name
// this looks like a bug in PMD - at least for UnusedImport rule.
if (StringUtils.isNotEmpty(packageName) && StringUtils.isNotEmpty(className)) {
if (packageName != null && !packageName.isEmpty() && className != null && !className.isEmpty()) {
return packageName + "." + className;
} else if (StringUtils.isNotEmpty(packageName)) {
} else if (packageName != null && !packageName.isEmpty()) {
String fileName = fullPath;
fileName = fileName.substring(fileName.lastIndexOf(File.separatorChar) + 1);
fileName = fileName.substring(0, fileName.length() - 5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.apache.maven.plugins.pmd.model.PmdFile;
import org.apache.maven.plugins.pmd.model.Violation;
import org.apache.maven.plugins.pmd.model.io.xpp3.PmdXpp3Reader;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;

/**
Expand Down Expand Up @@ -143,7 +142,7 @@ protected ViolationDetails<Violation> newViolationDetailsInstance() {
private String getFilename(String fullpath, String pkg) {
int index = fullpath.lastIndexOf(File.separatorChar);

while (StringUtils.isNotEmpty(pkg)) {
while (pkg != null && !pkg.isEmpty()) {
index = fullpath.substring(0, index).lastIndexOf(File.separatorChar);

int dot = pkg.indexOf('.');
Expand Down

0 comments on commit 40fe444

Please sign in to comment.