This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-io.git
commit 6d6096f9b12887e89de4414bb5d5432cf3834d47 Author: Gary Gregory <gardgreg...@gmail.com> AuthorDate: Tue Jun 14 19:13:35 2022 -0400 PMD: Remove unnecessary parentheses --- .../java/org/apache/commons/io/EndianUtils.java | 100 ++++++++++----------- .../java/org/apache/commons/io/FilenameUtils.java | 8 +- .../commons/io/file/attribute/FileTimes.java | 2 +- .../org/apache/commons/io/input/BoundedReader.java | 2 +- .../apache/commons/io/input/ReaderInputStream.java | 2 +- .../UnsynchronizedByteArrayOutputStream.java | 2 +- 6 files changed, 58 insertions(+), 58 deletions(-) diff --git a/src/main/java/org/apache/commons/io/EndianUtils.java b/src/main/java/org/apache/commons/io/EndianUtils.java index e2e8e12b..f7e21915 100644 --- a/src/main/java/org/apache/commons/io/EndianUtils.java +++ b/src/main/java/org/apache/commons/io/EndianUtils.java @@ -109,10 +109,10 @@ public class EndianUtils { * @return the value read */ public static int readSwappedInteger(final byte[] data, final int offset) { - return ( ( ( data[ offset + 0 ] & 0xff ) << 0 ) + + return ( ( data[ offset + 0 ] & 0xff ) << 0 ) + ( ( data[ offset + 1 ] & 0xff ) << 8 ) + ( ( data[ offset + 2 ] & 0xff ) << 16 ) + - ( ( data[ offset + 3 ] & 0xff ) << 24 ) ); + ( ( data[ offset + 3 ] & 0xff ) << 24 ); } // ========================================== Swapping read/write routines @@ -193,9 +193,9 @@ public class EndianUtils { * @return the value read */ public static long readSwappedUnsignedInteger(final byte[] data, final int offset) { - final long low = ( ( ( data[ offset + 0 ] & 0xff ) << 0 ) + + final long low = ( ( data[ offset + 0 ] & 0xff ) << 0 ) + ( ( data[ offset + 1 ] & 0xff ) << 8 ) + - ( ( data[ offset + 2 ] & 0xff ) << 16 ) ); + ( ( data[ offset + 2 ] & 0xff ) << 16 ); final long high = data[ offset + 3 ] & 0xff; @@ -215,7 +215,7 @@ public class EndianUtils { final int value3 = read(input); final int value4 = read(input); - final long low = (((value1 & 0xff) << 0) + ((value2 & 0xff) << 8) + ((value3 & 0xff) << 16)); + final long low = ((value1 & 0xff) << 0) + ((value2 & 0xff) << 8) + ((value3 & 0xff) << 16); final long high = value4 & 0xff; @@ -231,8 +231,8 @@ public class EndianUtils { * @return the value read */ public static int readSwappedUnsignedShort(final byte[] data, final int offset) { - return ( ( ( data[ offset + 0 ] & 0xff ) << 0 ) + - ( ( data[ offset + 1 ] & 0xff ) << 8 ) ); + return ( ( data[ offset + 0 ] & 0xff ) << 0 ) + + ( ( data[ offset + 1 ] & 0xff ) << 8 ); } /** @@ -246,7 +246,7 @@ public class EndianUtils { final int value1 = read(input); final int value2 = read(input); - return (((value1 & 0xff) << 0) + ((value2 & 0xff) << 8)); + return ((value1 & 0xff) << 0) + ((value2 & 0xff) << 8); } /** @@ -274,10 +274,10 @@ public class EndianUtils { */ public static int swapInteger(final int value) { return - ( ( ( value >> 0 ) & 0xff ) << 24 ) + - ( ( ( value >> 8 ) & 0xff ) << 16 ) + - ( ( ( value >> 16 ) & 0xff ) << 8 ) + - ( ( ( value >> 24 ) & 0xff ) << 0 ); + ( ( value >> 0 & 0xff ) << 24 ) + + ( ( value >> 8 & 0xff ) << 16 ) + + ( ( value >> 16 & 0xff ) << 8 ) + + ( ( value >> 24 & 0xff ) << 0 ); } /** @@ -287,14 +287,14 @@ public class EndianUtils { */ public static long swapLong(final long value) { return - ( ( ( value >> 0 ) & 0xff ) << 56 ) + - ( ( ( value >> 8 ) & 0xff ) << 48 ) + - ( ( ( value >> 16 ) & 0xff ) << 40 ) + - ( ( ( value >> 24 ) & 0xff ) << 32 ) + - ( ( ( value >> 32 ) & 0xff ) << 24 ) + - ( ( ( value >> 40 ) & 0xff ) << 16 ) + - ( ( ( value >> 48 ) & 0xff ) << 8 ) + - ( ( ( value >> 56 ) & 0xff ) << 0 ); + ( ( value >> 0 & 0xff ) << 56 ) + + ( ( value >> 8 & 0xff ) << 48 ) + + ( ( value >> 16 & 0xff ) << 40 ) + + ( ( value >> 24 & 0xff ) << 32 ) + + ( ( value >> 32 & 0xff ) << 24 ) + + ( ( value >> 40 & 0xff ) << 16 ) + + ( ( value >> 48 & 0xff ) << 8 ) + + ( ( value >> 56 & 0xff ) << 0 ); } /** @@ -303,8 +303,8 @@ public class EndianUtils { * @return the converted value */ public static short swapShort(final short value) { - return (short) ( ( ( ( value >> 0 ) & 0xff ) << 8 ) + - ( ( ( value >> 8 ) & 0xff ) << 0 ) ); + return (short) ( ( ( value >> 0 & 0xff ) << 8 ) + + ( ( value >> 8 & 0xff ) << 0 ) ); } /** @@ -359,10 +359,10 @@ public class EndianUtils { * @param value value to write */ public static void writeSwappedInteger(final byte[] data, final int offset, final int value) { - data[ offset + 0 ] = (byte)( ( value >> 0 ) & 0xff ); - data[ offset + 1 ] = (byte)( ( value >> 8 ) & 0xff ); - data[ offset + 2 ] = (byte)( ( value >> 16 ) & 0xff ); - data[ offset + 3 ] = (byte)( ( value >> 24 ) & 0xff ); + data[ offset + 0 ] = (byte)( value >> 0 & 0xff ); + data[ offset + 1 ] = (byte)( value >> 8 & 0xff ); + data[ offset + 2 ] = (byte)( value >> 16 & 0xff ); + data[ offset + 3 ] = (byte)( value >> 24 & 0xff ); } /** @@ -373,10 +373,10 @@ public class EndianUtils { * @throws IOException in case of an I/O problem */ public static void writeSwappedInteger(final OutputStream output, final int value) throws IOException { - output.write((byte) ((value >> 0) & 0xff)); - output.write((byte) ((value >> 8) & 0xff)); - output.write((byte) ((value >> 16) & 0xff)); - output.write((byte) ((value >> 24) & 0xff)); + output.write((byte) (value >> 0 & 0xff)); + output.write((byte) (value >> 8 & 0xff)); + output.write((byte) (value >> 16 & 0xff)); + output.write((byte) (value >> 24 & 0xff)); } /** @@ -387,14 +387,14 @@ public class EndianUtils { * @param value value to write */ public static void writeSwappedLong(final byte[] data, final int offset, final long value) { - data[ offset + 0 ] = (byte)( ( value >> 0 ) & 0xff ); - data[ offset + 1 ] = (byte)( ( value >> 8 ) & 0xff ); - data[ offset + 2 ] = (byte)( ( value >> 16 ) & 0xff ); - data[ offset + 3 ] = (byte)( ( value >> 24 ) & 0xff ); - data[ offset + 4 ] = (byte)( ( value >> 32 ) & 0xff ); - data[ offset + 5 ] = (byte)( ( value >> 40 ) & 0xff ); - data[ offset + 6 ] = (byte)( ( value >> 48 ) & 0xff ); - data[ offset + 7 ] = (byte)( ( value >> 56 ) & 0xff ); + data[ offset + 0 ] = (byte)( value >> 0 & 0xff ); + data[ offset + 1 ] = (byte)( value >> 8 & 0xff ); + data[ offset + 2 ] = (byte)( value >> 16 & 0xff ); + data[ offset + 3 ] = (byte)( value >> 24 & 0xff ); + data[ offset + 4 ] = (byte)( value >> 32 & 0xff ); + data[ offset + 5 ] = (byte)( value >> 40 & 0xff ); + data[ offset + 6 ] = (byte)( value >> 48 & 0xff ); + data[ offset + 7 ] = (byte)( value >> 56 & 0xff ); } /** @@ -405,14 +405,14 @@ public class EndianUtils { * @throws IOException in case of an I/O problem */ public static void writeSwappedLong(final OutputStream output, final long value) throws IOException { - output.write((byte) ((value >> 0) & 0xff)); - output.write((byte) ((value >> 8) & 0xff)); - output.write((byte) ((value >> 16) & 0xff)); - output.write((byte) ((value >> 24) & 0xff)); - output.write((byte) ((value >> 32) & 0xff)); - output.write((byte) ((value >> 40) & 0xff)); - output.write((byte) ((value >> 48) & 0xff)); - output.write((byte) ((value >> 56) & 0xff)); + output.write((byte) (value >> 0 & 0xff)); + output.write((byte) (value >> 8 & 0xff)); + output.write((byte) (value >> 16 & 0xff)); + output.write((byte) (value >> 24 & 0xff)); + output.write((byte) (value >> 32 & 0xff)); + output.write((byte) (value >> 40 & 0xff)); + output.write((byte) (value >> 48 & 0xff)); + output.write((byte) (value >> 56 & 0xff)); } /** @@ -423,8 +423,8 @@ public class EndianUtils { * @param value value to write */ public static void writeSwappedShort(final byte[] data, final int offset, final short value) { - data[ offset + 0 ] = (byte)( ( value >> 0 ) & 0xff ); - data[ offset + 1 ] = (byte)( ( value >> 8 ) & 0xff ); + data[ offset + 0 ] = (byte)( value >> 0 & 0xff ); + data[ offset + 1 ] = (byte)( value >> 8 & 0xff ); } /** @@ -435,8 +435,8 @@ public class EndianUtils { * @throws IOException in case of an I/O problem */ public static void writeSwappedShort(final OutputStream output, final short value) throws IOException { - output.write((byte) ((value >> 0) & 0xff)); - output.write((byte) ((value >> 8) & 0xff)); + output.write((byte) (value >> 0 & 0xff)); + output.write((byte) (value >> 8 & 0xff)); } /** diff --git a/src/main/java/org/apache/commons/io/FilenameUtils.java b/src/main/java/org/apache/commons/io/FilenameUtils.java index f8a5dbad..83fecf2b 100644 --- a/src/main/java/org/apache/commons/io/FilenameUtils.java +++ b/src/main/java/org/apache/commons/io/FilenameUtils.java @@ -358,7 +358,7 @@ public class FilenameUtils { // adjoining slashes // If we get here, prefix can only be 0 or greater, size 1 or greater // If prefix is 0, set loop start to 1 to prevent index errors - for (int i = (prefix != 0) ? prefix : 1; i < size; i++) { + for (int i = prefix != 0 ? prefix : 1; i < size; i++) { if (array[i] == separator && array[i - 1] == separator) { System.arraycopy(array, i, array, i - 1, size - i); size--; @@ -1107,11 +1107,11 @@ public class FilenameUtils { */ private static boolean isIPv6Address(final String inet6Address) { final boolean containsCompressedZeroes = inet6Address.contains("::"); - if (containsCompressedZeroes && (inet6Address.indexOf("::") != inet6Address.lastIndexOf("::"))) { + if (containsCompressedZeroes && inet6Address.indexOf("::") != inet6Address.lastIndexOf("::")) { return false; } - if ((inet6Address.startsWith(":") && !inet6Address.startsWith("::")) - || (inet6Address.endsWith(":") && !inet6Address.endsWith("::"))) { + if (inet6Address.startsWith(":") && !inet6Address.startsWith("::") + || inet6Address.endsWith(":") && !inet6Address.endsWith("::")) { return false; } String[] octets = inet6Address.split(":"); diff --git a/src/main/java/org/apache/commons/io/file/attribute/FileTimes.java b/src/main/java/org/apache/commons/io/file/attribute/FileTimes.java index ab84211f..75b85a9d 100644 --- a/src/main/java/org/apache/commons/io/file/attribute/FileTimes.java +++ b/src/main/java/org/apache/commons/io/file/attribute/FileTimes.java @@ -216,7 +216,7 @@ public class FileTimes { */ public static long toNtfsTime(final FileTime fileTime) { final Instant instant = fileTime.toInstant(); - final long javaHundredNanos = (instant.getEpochSecond() * HUNDRED_NANOS_PER_SECOND) + (instant.getNano() / 100); + final long javaHundredNanos = instant.getEpochSecond() * HUNDRED_NANOS_PER_SECOND + instant.getNano() / 100; return Math.subtractExact(javaHundredNanos, WINDOWS_EPOCH_OFFSET); } diff --git a/src/main/java/org/apache/commons/io/input/BoundedReader.java b/src/main/java/org/apache/commons/io/input/BoundedReader.java index 6bb59a50..6a226e22 100644 --- a/src/main/java/org/apache/commons/io/input/BoundedReader.java +++ b/src/main/java/org/apache/commons/io/input/BoundedReader.java @@ -102,7 +102,7 @@ public class BoundedReader extends Reader { return EOF; } - if (markedAt >= 0 && (charsRead - markedAt) >= readAheadLimit) { + if (markedAt >= 0 && charsRead - markedAt >= readAheadLimit) { return EOF; } charsRead++; diff --git a/src/main/java/org/apache/commons/io/input/ReaderInputStream.java b/src/main/java/org/apache/commons/io/input/ReaderInputStream.java index a69182db..c4f6fbfb 100644 --- a/src/main/java/org/apache/commons/io/input/ReaderInputStream.java +++ b/src/main/java/org/apache/commons/io/input/ReaderInputStream.java @@ -328,7 +328,7 @@ public class ReaderInputStream extends InputStream { @Override public int read(final byte[] array, int off, int len) throws IOException { Objects.requireNonNull(array, "array"); - if (len < 0 || off < 0 || (off + len) > array.length) { + if (len < 0 || off < 0 || off + len > array.length) { throw new IndexOutOfBoundsException("Array size=" + array.length + ", offset=" + off + ", length=" + len); } int read = 0; diff --git a/src/main/java/org/apache/commons/io/output/UnsynchronizedByteArrayOutputStream.java b/src/main/java/org/apache/commons/io/output/UnsynchronizedByteArrayOutputStream.java index d69ce858..8d77f2f8 100644 --- a/src/main/java/org/apache/commons/io/output/UnsynchronizedByteArrayOutputStream.java +++ b/src/main/java/org/apache/commons/io/output/UnsynchronizedByteArrayOutputStream.java @@ -123,7 +123,7 @@ public final class UnsynchronizedByteArrayOutputStream extends AbstractByteArray @Override public void write(final byte[] b, final int off, final int len) { - if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0)) { + if (off < 0 || off > b.length || len < 0 || off + len > b.length || off + len < 0) { throw new IndexOutOfBoundsException(String.format("offset=%,d, length=%,d", off, len)); } if (len == 0) {