Skip to content

Commit 6d8f485

Browse files
committed
Fix PMD UnnecessaryFullyQualifiedName and friends
- Fix PMD 7.1.0 issues
1 parent a61015c commit 6d8f485

12 files changed

Lines changed: 21 additions & 16 deletions

src/changes/changes.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ The <action> type attribute can be add,update,fix,remove.
5555
<action dev="ggregory" type="fix" due-to="Gary Gregory">FileUtils.lastModifiedFileTime(File) calls Objects.requireNonNull() on the wrong object.</action>
5656
<action dev="ggregory" type="fix" due-to="Gary Gregory">PathUtils.deleteOnExit(Path) calls Objects.requireNonNull() on the wrong object.</action>
5757
<action dev="ggregory" type="fix" due-to="Gary Gregory">Deprecate LineIterator.nextLine() in favor of next().</action>
58+
<action dev="ggregory" type="fix" due-to="Gary Gregory">Fix PMD UnnecessaryFullyQualifiedName.</action>
5859
<!-- UPDATE -->
5960
<action dev="ggregory" type="update" due-to="Dependabot">Bump tests commons.bytebuddy.version from 1.14.13 to 1.14.15 #615, #621.</action>
6061
<action dev="ggregory" type="update" due-to="Dependabot">Bump tests commons-codec:commons-codec from 1.16.1 to 1.17.0.</action>

src/conf/maven-pmd-plugin.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,12 @@ under the License.
6565
<rule ref="category/java/errorprone.xml/CheckSkipResult" />
6666
<rule ref="category/java/errorprone.xml/ClassCastExceptionWithToArray" />
6767
<rule ref="category/java/errorprone.xml/DontUseFloatTypeForLoopIndices" />
68-
<rule ref="category/java/errorprone.xml/EmptyCatchBlock" />
68+
<rule ref="category/java/errorprone.xml/EmptyCatchBlock">
69+
<properties>
70+
<property name="allowCommentedBlocks" value="true" />
71+
<property name="allowExceptionNameRegex" value="^(ignored|expected)$" />
72+
</properties>
73+
</rule>
6974
<rule ref="category/java/errorprone.xml/JumbledIncrementer" />
7075
<rule ref="category/java/errorprone.xml/MisplacedNullCheck" />
7176
<rule ref="category/java/errorprone.xml/OverrideBothEqualsAndHashcode" />

src/main/java/org/apache/commons/io/FileCleaningTracker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ private final class Reaper extends Thread {
5454
/** Constructs a new Reaper */
5555
Reaper() {
5656
super("File Reaper");
57-
setPriority(Thread.MAX_PRIORITY);
57+
setPriority(MAX_PRIORITY);
5858
setDaemon(true);
5959
}
6060

src/main/java/org/apache/commons/io/FileUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2485,7 +2485,7 @@ public static void moveFile(final File srcFile, final File destFile, final CopyO
24852485
// Don't interfere with file date on move, handled by StandardCopyOption.COPY_ATTRIBUTES
24862486
copyFile(srcFile, destFile, false, copyOptions);
24872487
if (!srcFile.delete()) {
2488-
FileUtils.deleteQuietly(destFile);
2488+
deleteQuietly(destFile);
24892489
throw new IOException("Failed to delete original file '" + srcFile + "' after copy to '" + destFile + "'");
24902490
}
24912491
}

src/main/java/org/apache/commons/io/IOCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public enum IOCase {
7676
* @throws IllegalArgumentException if the name is invalid
7777
*/
7878
public static IOCase forName(final String name) {
79-
return Stream.of(IOCase.values()).filter(ioCase -> ioCase.getName().equals(name)).findFirst()
79+
return Stream.of(values()).filter(ioCase -> ioCase.getName().equals(name)).findFirst()
8080
.orElseThrow(() -> new IllegalArgumentException("Illegal IOCase name: " + name));
8181
}
8282

src/main/java/org/apache/commons/io/IOUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,7 @@ public static int copy(final InputStream inputStream, final OutputStream outputS
11041104
*/
11051105
public static long copy(final InputStream inputStream, final OutputStream outputStream, final int bufferSize)
11061106
throws IOException {
1107-
return copyLarge(inputStream, outputStream, IOUtils.byteArray(bufferSize));
1107+
return copyLarge(inputStream, outputStream, byteArray(bufferSize));
11081108
}
11091109

11101110
/**

src/main/java/org/apache/commons/io/ThreadMonitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public void run() {
102102
try {
103103
ThreadUtils.sleep(timeout);
104104
thread.interrupt();
105-
} catch (final InterruptedException e) {
105+
} catch (final InterruptedException ignored) {
106106
// timeout not reached
107107
}
108108
}

src/main/java/org/apache/commons/io/file/Counters.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ private final static class BigIntegerPathCounters extends AbstractPathCounters {
173173
* Constructs a new initialized instance.
174174
*/
175175
protected BigIntegerPathCounters() {
176-
super(Counters.bigIntegerCounter(), Counters.bigIntegerCounter(), Counters.bigIntegerCounter());
176+
super(bigIntegerCounter(), bigIntegerCounter(), bigIntegerCounter());
177177
}
178178

179179
}
@@ -295,7 +295,7 @@ private final static class LongPathCounters extends AbstractPathCounters {
295295
* Constructs a new initialized instance.
296296
*/
297297
protected LongPathCounters() {
298-
super(Counters.longCounter(), Counters.longCounter(), Counters.longCounter());
298+
super(longCounter(), longCounter(), longCounter());
299299
}
300300

301301
}
@@ -356,7 +356,7 @@ private static final class NoopPathCounters extends AbstractPathCounters {
356356
* Constructs a new initialized instance.
357357
*/
358358
private NoopPathCounters() {
359-
super(Counters.noopCounter(), Counters.noopCounter(), Counters.noopCounter());
359+
super(noopCounter(), noopCounter(), noopCounter());
360360
}
361361

362362
}

src/main/java/org/apache/commons/io/file/PathUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ public static PathCounters deleteDirectory(final Path directory) throws IOExcept
498498
* @since 2.8.0
499499
*/
500500
public static PathCounters deleteDirectory(final Path directory, final DeleteOption... deleteOptions) throws IOException {
501-
final LinkOption[] linkOptions = PathUtils.noFollowLinkOptionArray();
501+
final LinkOption[] linkOptions = noFollowLinkOptionArray();
502502
// POSIX ops will noop on non-POSIX.
503503
return withPosixFileAttributes(getParent(directory), linkOptions, overrideReadOnly(deleteOptions),
504504
pfa -> visitFileTree(new DeletingPathVisitor(Counters.longPathCounters(), linkOptions, deleteOptions), directory).getPathCounters());

src/main/java/org/apache/commons/io/file/StandardDeleteOption.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static boolean overrideReadOnly(final DeleteOption[] options) {
4545
if (IOUtils.length(options) == 0) {
4646
return false;
4747
}
48-
return Stream.of(options).anyMatch(e -> StandardDeleteOption.OVERRIDE_READ_ONLY == e);
48+
return Stream.of(options).anyMatch(e -> OVERRIDE_READ_ONLY == e);
4949
}
5050

5151
}

0 commit comments

Comments
 (0)