Skip to content

Commit 6d6096f

Browse files
author
Gary Gregory
committed
PMD: Remove unnecessary parentheses
1 parent 62ff893 commit 6d6096f

6 files changed

Lines changed: 58 additions & 58 deletions

File tree

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

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ public static float readSwappedFloat(final InputStream input) throws IOException
109109
* @return the value read
110110
*/
111111
public static int readSwappedInteger(final byte[] data, final int offset) {
112-
return ( ( ( data[ offset + 0 ] & 0xff ) << 0 ) +
112+
return ( ( data[ offset + 0 ] & 0xff ) << 0 ) +
113113
( ( data[ offset + 1 ] & 0xff ) << 8 ) +
114114
( ( data[ offset + 2 ] & 0xff ) << 16 ) +
115-
( ( data[ offset + 3 ] & 0xff ) << 24 ) );
115+
( ( data[ offset + 3 ] & 0xff ) << 24 );
116116
}
117117

118118
// ========================================== Swapping read/write routines
@@ -193,9 +193,9 @@ public static short readSwappedShort(final InputStream input) throws IOException
193193
* @return the value read
194194
*/
195195
public static long readSwappedUnsignedInteger(final byte[] data, final int offset) {
196-
final long low = ( ( ( data[ offset + 0 ] & 0xff ) << 0 ) +
196+
final long low = ( ( data[ offset + 0 ] & 0xff ) << 0 ) +
197197
( ( data[ offset + 1 ] & 0xff ) << 8 ) +
198-
( ( data[ offset + 2 ] & 0xff ) << 16 ) );
198+
( ( data[ offset + 2 ] & 0xff ) << 16 );
199199

200200
final long high = data[ offset + 3 ] & 0xff;
201201

@@ -215,7 +215,7 @@ public static long readSwappedUnsignedInteger(final InputStream input) throws IO
215215
final int value3 = read(input);
216216
final int value4 = read(input);
217217

218-
final long low = (((value1 & 0xff) << 0) + ((value2 & 0xff) << 8) + ((value3 & 0xff) << 16));
218+
final long low = ((value1 & 0xff) << 0) + ((value2 & 0xff) << 8) + ((value3 & 0xff) << 16);
219219

220220
final long high = value4 & 0xff;
221221

@@ -231,8 +231,8 @@ public static long readSwappedUnsignedInteger(final InputStream input) throws IO
231231
* @return the value read
232232
*/
233233
public static int readSwappedUnsignedShort(final byte[] data, final int offset) {
234-
return ( ( ( data[ offset + 0 ] & 0xff ) << 0 ) +
235-
( ( data[ offset + 1 ] & 0xff ) << 8 ) );
234+
return ( ( data[ offset + 0 ] & 0xff ) << 0 ) +
235+
( ( data[ offset + 1 ] & 0xff ) << 8 );
236236
}
237237

238238
/**
@@ -246,7 +246,7 @@ public static int readSwappedUnsignedShort(final InputStream input) throws IOExc
246246
final int value1 = read(input);
247247
final int value2 = read(input);
248248

249-
return (((value1 & 0xff) << 0) + ((value2 & 0xff) << 8));
249+
return ((value1 & 0xff) << 0) + ((value2 & 0xff) << 8);
250250
}
251251

252252
/**
@@ -274,10 +274,10 @@ public static float swapFloat(final float value) {
274274
*/
275275
public static int swapInteger(final int value) {
276276
return
277-
( ( ( value >> 0 ) & 0xff ) << 24 ) +
278-
( ( ( value >> 8 ) & 0xff ) << 16 ) +
279-
( ( ( value >> 16 ) & 0xff ) << 8 ) +
280-
( ( ( value >> 24 ) & 0xff ) << 0 );
277+
( ( value >> 0 & 0xff ) << 24 ) +
278+
( ( value >> 8 & 0xff ) << 16 ) +
279+
( ( value >> 16 & 0xff ) << 8 ) +
280+
( ( value >> 24 & 0xff ) << 0 );
281281
}
282282

283283
/**
@@ -287,14 +287,14 @@ public static int swapInteger(final int value) {
287287
*/
288288
public static long swapLong(final long value) {
289289
return
290-
( ( ( value >> 0 ) & 0xff ) << 56 ) +
291-
( ( ( value >> 8 ) & 0xff ) << 48 ) +
292-
( ( ( value >> 16 ) & 0xff ) << 40 ) +
293-
( ( ( value >> 24 ) & 0xff ) << 32 ) +
294-
( ( ( value >> 32 ) & 0xff ) << 24 ) +
295-
( ( ( value >> 40 ) & 0xff ) << 16 ) +
296-
( ( ( value >> 48 ) & 0xff ) << 8 ) +
297-
( ( ( value >> 56 ) & 0xff ) << 0 );
290+
( ( value >> 0 & 0xff ) << 56 ) +
291+
( ( value >> 8 & 0xff ) << 48 ) +
292+
( ( value >> 16 & 0xff ) << 40 ) +
293+
( ( value >> 24 & 0xff ) << 32 ) +
294+
( ( value >> 32 & 0xff ) << 24 ) +
295+
( ( value >> 40 & 0xff ) << 16 ) +
296+
( ( value >> 48 & 0xff ) << 8 ) +
297+
( ( value >> 56 & 0xff ) << 0 );
298298
}
299299

300300
/**
@@ -303,8 +303,8 @@ public static long swapLong(final long value) {
303303
* @return the converted value
304304
*/
305305
public static short swapShort(final short value) {
306-
return (short) ( ( ( ( value >> 0 ) & 0xff ) << 8 ) +
307-
( ( ( value >> 8 ) & 0xff ) << 0 ) );
306+
return (short) ( ( ( value >> 0 & 0xff ) << 8 ) +
307+
( ( value >> 8 & 0xff ) << 0 ) );
308308
}
309309

310310
/**
@@ -359,10 +359,10 @@ public static void writeSwappedFloat(final OutputStream output, final float valu
359359
* @param value value to write
360360
*/
361361
public static void writeSwappedInteger(final byte[] data, final int offset, final int value) {
362-
data[ offset + 0 ] = (byte)( ( value >> 0 ) & 0xff );
363-
data[ offset + 1 ] = (byte)( ( value >> 8 ) & 0xff );
364-
data[ offset + 2 ] = (byte)( ( value >> 16 ) & 0xff );
365-
data[ offset + 3 ] = (byte)( ( value >> 24 ) & 0xff );
362+
data[ offset + 0 ] = (byte)( value >> 0 & 0xff );
363+
data[ offset + 1 ] = (byte)( value >> 8 & 0xff );
364+
data[ offset + 2 ] = (byte)( value >> 16 & 0xff );
365+
data[ offset + 3 ] = (byte)( value >> 24 & 0xff );
366366
}
367367

368368
/**
@@ -373,10 +373,10 @@ public static void writeSwappedInteger(final byte[] data, final int offset, fina
373373
* @throws IOException in case of an I/O problem
374374
*/
375375
public static void writeSwappedInteger(final OutputStream output, final int value) throws IOException {
376-
output.write((byte) ((value >> 0) & 0xff));
377-
output.write((byte) ((value >> 8) & 0xff));
378-
output.write((byte) ((value >> 16) & 0xff));
379-
output.write((byte) ((value >> 24) & 0xff));
376+
output.write((byte) (value >> 0 & 0xff));
377+
output.write((byte) (value >> 8 & 0xff));
378+
output.write((byte) (value >> 16 & 0xff));
379+
output.write((byte) (value >> 24 & 0xff));
380380
}
381381

382382
/**
@@ -387,14 +387,14 @@ public static void writeSwappedInteger(final OutputStream output, final int valu
387387
* @param value value to write
388388
*/
389389
public static void writeSwappedLong(final byte[] data, final int offset, final long value) {
390-
data[ offset + 0 ] = (byte)( ( value >> 0 ) & 0xff );
391-
data[ offset + 1 ] = (byte)( ( value >> 8 ) & 0xff );
392-
data[ offset + 2 ] = (byte)( ( value >> 16 ) & 0xff );
393-
data[ offset + 3 ] = (byte)( ( value >> 24 ) & 0xff );
394-
data[ offset + 4 ] = (byte)( ( value >> 32 ) & 0xff );
395-
data[ offset + 5 ] = (byte)( ( value >> 40 ) & 0xff );
396-
data[ offset + 6 ] = (byte)( ( value >> 48 ) & 0xff );
397-
data[ offset + 7 ] = (byte)( ( value >> 56 ) & 0xff );
390+
data[ offset + 0 ] = (byte)( value >> 0 & 0xff );
391+
data[ offset + 1 ] = (byte)( value >> 8 & 0xff );
392+
data[ offset + 2 ] = (byte)( value >> 16 & 0xff );
393+
data[ offset + 3 ] = (byte)( value >> 24 & 0xff );
394+
data[ offset + 4 ] = (byte)( value >> 32 & 0xff );
395+
data[ offset + 5 ] = (byte)( value >> 40 & 0xff );
396+
data[ offset + 6 ] = (byte)( value >> 48 & 0xff );
397+
data[ offset + 7 ] = (byte)( value >> 56 & 0xff );
398398
}
399399

400400
/**
@@ -405,14 +405,14 @@ public static void writeSwappedLong(final byte[] data, final int offset, final l
405405
* @throws IOException in case of an I/O problem
406406
*/
407407
public static void writeSwappedLong(final OutputStream output, final long value) throws IOException {
408-
output.write((byte) ((value >> 0) & 0xff));
409-
output.write((byte) ((value >> 8) & 0xff));
410-
output.write((byte) ((value >> 16) & 0xff));
411-
output.write((byte) ((value >> 24) & 0xff));
412-
output.write((byte) ((value >> 32) & 0xff));
413-
output.write((byte) ((value >> 40) & 0xff));
414-
output.write((byte) ((value >> 48) & 0xff));
415-
output.write((byte) ((value >> 56) & 0xff));
408+
output.write((byte) (value >> 0 & 0xff));
409+
output.write((byte) (value >> 8 & 0xff));
410+
output.write((byte) (value >> 16 & 0xff));
411+
output.write((byte) (value >> 24 & 0xff));
412+
output.write((byte) (value >> 32 & 0xff));
413+
output.write((byte) (value >> 40 & 0xff));
414+
output.write((byte) (value >> 48 & 0xff));
415+
output.write((byte) (value >> 56 & 0xff));
416416
}
417417

418418
/**
@@ -423,8 +423,8 @@ public static void writeSwappedLong(final OutputStream output, final long value)
423423
* @param value value to write
424424
*/
425425
public static void writeSwappedShort(final byte[] data, final int offset, final short value) {
426-
data[ offset + 0 ] = (byte)( ( value >> 0 ) & 0xff );
427-
data[ offset + 1 ] = (byte)( ( value >> 8 ) & 0xff );
426+
data[ offset + 0 ] = (byte)( value >> 0 & 0xff );
427+
data[ offset + 1 ] = (byte)( value >> 8 & 0xff );
428428
}
429429

430430
/**
@@ -435,8 +435,8 @@ public static void writeSwappedShort(final byte[] data, final int offset, final
435435
* @throws IOException in case of an I/O problem
436436
*/
437437
public static void writeSwappedShort(final OutputStream output, final short value) throws IOException {
438-
output.write((byte) ((value >> 0) & 0xff));
439-
output.write((byte) ((value >> 8) & 0xff));
438+
output.write((byte) (value >> 0 & 0xff));
439+
output.write((byte) (value >> 8 & 0xff));
440440
}
441441

442442
/**

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ private static String doNormalize(final String fileName, final char separator, f
358358
// adjoining slashes
359359
// If we get here, prefix can only be 0 or greater, size 1 or greater
360360
// If prefix is 0, set loop start to 1 to prevent index errors
361-
for (int i = (prefix != 0) ? prefix : 1; i < size; i++) {
361+
for (int i = prefix != 0 ? prefix : 1; i < size; i++) {
362362
if (array[i] == separator && array[i - 1] == separator) {
363363
System.arraycopy(array, i, array, i - 1, size - i);
364364
size--;
@@ -1107,11 +1107,11 @@ private static boolean isIPv4Address(final String name) {
11071107
*/
11081108
private static boolean isIPv6Address(final String inet6Address) {
11091109
final boolean containsCompressedZeroes = inet6Address.contains("::");
1110-
if (containsCompressedZeroes && (inet6Address.indexOf("::") != inet6Address.lastIndexOf("::"))) {
1110+
if (containsCompressedZeroes && inet6Address.indexOf("::") != inet6Address.lastIndexOf("::")) {
11111111
return false;
11121112
}
1113-
if ((inet6Address.startsWith(":") && !inet6Address.startsWith("::"))
1114-
|| (inet6Address.endsWith(":") && !inet6Address.endsWith("::"))) {
1113+
if (inet6Address.startsWith(":") && !inet6Address.startsWith("::")
1114+
|| inet6Address.endsWith(":") && !inet6Address.endsWith("::")) {
11151115
return false;
11161116
}
11171117
String[] octets = inet6Address.split(":");

src/main/java/org/apache/commons/io/file/attribute/FileTimes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public static long toNtfsTime(final Date date) {
216216
*/
217217
public static long toNtfsTime(final FileTime fileTime) {
218218
final Instant instant = fileTime.toInstant();
219-
final long javaHundredNanos = (instant.getEpochSecond() * HUNDRED_NANOS_PER_SECOND) + (instant.getNano() / 100);
219+
final long javaHundredNanos = instant.getEpochSecond() * HUNDRED_NANOS_PER_SECOND + instant.getNano() / 100;
220220
return Math.subtractExact(javaHundredNanos, WINDOWS_EPOCH_OFFSET);
221221
}
222222

src/main/java/org/apache/commons/io/input/BoundedReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public int read() throws IOException {
102102
return EOF;
103103
}
104104

105-
if (markedAt >= 0 && (charsRead - markedAt) >= readAheadLimit) {
105+
if (markedAt >= 0 && charsRead - markedAt >= readAheadLimit) {
106106
return EOF;
107107
}
108108
charsRead++;

src/main/java/org/apache/commons/io/input/ReaderInputStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ public int read(final byte[] b) throws IOException {
328328
@Override
329329
public int read(final byte[] array, int off, int len) throws IOException {
330330
Objects.requireNonNull(array, "array");
331-
if (len < 0 || off < 0 || (off + len) > array.length) {
331+
if (len < 0 || off < 0 || off + len > array.length) {
332332
throw new IndexOutOfBoundsException("Array size=" + array.length + ", offset=" + off + ", length=" + len);
333333
}
334334
int read = 0;

src/main/java/org/apache/commons/io/output/UnsynchronizedByteArrayOutputStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public InputStream toInputStream() {
123123

124124
@Override
125125
public void write(final byte[] b, final int off, final int len) {
126-
if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0)) {
126+
if (off < 0 || off > b.length || len < 0 || off + len > b.length || off + len < 0) {
127127
throw new IndexOutOfBoundsException(String.format("offset=%,d, length=%,d", off, len));
128128
}
129129
if (len == 0) {

0 commit comments

Comments
 (0)