Skip to content

Commit 40fe444

Browse files
authored
[MNG-6829] Replace any StringUtils#isEmpty(String) and #isNotEmpty(String) (#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)
1 parent 690dcbe commit 40fe444

File tree

4 files changed

+6
-9
lines changed

4 files changed

+6
-9
lines changed

src/main/java/org/apache/maven/plugins/pmd/AbstractPmdReport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ protected String constructXRefLocation(boolean test) {
275275

276276
String relativePath =
277277
PathTool.getRelativePath(outputDirectory.getAbsolutePath(), xrefLoc.getAbsolutePath());
278-
if (StringUtils.isEmpty(relativePath)) {
278+
if (relativePath == null || relativePath.isEmpty()) {
279279
relativePath = ".";
280280
}
281281
relativePath = relativePath + "/" + xrefLoc.getName();

src/main/java/org/apache/maven/plugins/pmd/ExcludeDuplicationsFromFile.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
import net.sourceforge.pmd.cpd.Mark;
3030
import net.sourceforge.pmd.cpd.Match;
31-
import org.apache.commons.lang3.StringUtils;
3231
import org.apache.maven.plugin.MojoExecutionException;
3332
import org.apache.maven.plugins.pmd.model.CpdFile;
3433
import org.apache.maven.plugins.pmd.model.Duplication;
@@ -99,7 +98,7 @@ private boolean fileExcludedByGroup(final String path, final Set<String> singleE
9998

10099
@Override
101100
public void loadExcludeFromFailuresData(final String excludeFromFailureFile) throws MojoExecutionException {
102-
if (StringUtils.isEmpty(excludeFromFailureFile)) {
101+
if (excludeFromFailureFile == null || excludeFromFailureFile.isEmpty()) {
103102
return;
104103
}
105104

src/main/java/org/apache/maven/plugins/pmd/ExcludeViolationsFromFile.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import java.util.Set;
3030

3131
import net.sourceforge.pmd.RuleViolation;
32-
import org.apache.commons.lang3.StringUtils;
3332
import org.apache.maven.plugin.MojoExecutionException;
3433
import org.apache.maven.plugins.pmd.model.Violation;
3534

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

4645
@Override
4746
public void loadExcludeFromFailuresData(final String excludeFromFailureFile) throws MojoExecutionException {
48-
if (StringUtils.isEmpty(excludeFromFailureFile)) {
47+
if (excludeFromFailureFile == null || excludeFromFailureFile.isEmpty()) {
4948
return;
5049
}
5150

@@ -107,9 +106,9 @@ private boolean isExcludedFromFailure(String className, String ruleName) {
107106
private String extractClassName(String packageName, String className, String fullPath) {
108107
// for some reason, some violations don't contain the package name, so we have to guess the full class name
109108
// this looks like a bug in PMD - at least for UnusedImport rule.
110-
if (StringUtils.isNotEmpty(packageName) && StringUtils.isNotEmpty(className)) {
109+
if (packageName != null && !packageName.isEmpty() && className != null && !className.isEmpty()) {
111110
return packageName + "." + className;
112-
} else if (StringUtils.isNotEmpty(packageName)) {
111+
} else if (packageName != null && !packageName.isEmpty()) {
113112
String fileName = fullPath;
114113
fileName = fileName.substring(fileName.lastIndexOf(File.separatorChar) + 1);
115114
fileName = fileName.substring(0, fileName.length() - 5);

src/main/java/org/apache/maven/plugins/pmd/PmdViolationCheckMojo.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import org.apache.maven.plugins.pmd.model.PmdFile;
3636
import org.apache.maven.plugins.pmd.model.Violation;
3737
import org.apache.maven.plugins.pmd.model.io.xpp3.PmdXpp3Reader;
38-
import org.codehaus.plexus.util.StringUtils;
3938
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
4039

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

146-
while (StringUtils.isNotEmpty(pkg)) {
145+
while (pkg != null && !pkg.isEmpty()) {
147146
index = fullpath.substring(0, index).lastIndexOf(File.separatorChar);
148147

149148
int dot = pkg.indexOf('.');

0 commit comments

Comments
 (0)