diff --git a/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/RequestOptionsGenerator.java b/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/RequestOptionsGenerator.java index 5e7e027b31..fc1d70ed34 100644 --- a/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/RequestOptionsGenerator.java +++ b/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/RequestOptionsGenerator.java @@ -316,6 +316,7 @@ private MethodAndStaticVar generateStaticMethodEquivalentForRequestOptionsStatic return new MethodAndStaticVar(methodSpecBuilder.build(), requiredStaticField); } + @SuppressWarnings("checkstyle:UnnecessaryParentheses") // Readability private static boolean memoizeStaticMethodFromArguments(ExecutableElement staticMethod) { return staticMethod.getParameters().isEmpty() || (staticMethod.getParameters().size() == 1 diff --git a/build.gradle b/build.gradle index e71ce474a4..4579dc82f0 100644 --- a/build.gradle +++ b/build.gradle @@ -169,7 +169,7 @@ subprojects { project -> apply plugin: 'checkstyle' checkstyle { - toolVersion = '8.5' + toolVersion = '8.45.1' } checkstyle { diff --git a/checkstyle.xml b/checkstyle.xml index d8a1c0ee5b..e6d04238fd 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -30,8 +30,10 @@ - + + + diff --git a/integration/cronet/src/main/java/com/bumptech/glide/integration/cronet/BufferQueue.java b/integration/cronet/src/main/java/com/bumptech/glide/integration/cronet/BufferQueue.java index c320dc7723..8a43d5486d 100644 --- a/integration/cronet/src/main/java/com/bumptech/glide/integration/cronet/BufferQueue.java +++ b/integration/cronet/src/main/java/com/bumptech/glide/integration/cronet/BufferQueue.java @@ -62,6 +62,7 @@ public ByteBuffer getFirstBuffer(UrlResponseInfo info) { return ByteBuffer.allocateDirect((int) Math.min(bufferSizeHeuristic(info), 524288)); } + @SuppressWarnings("checkstyle:UnnecessaryParentheses") // Readability private static long bufferSizeHeuristic(UrlResponseInfo info) { final Map> headers = info.getAllHeaders(); if (headers.containsKey(CONTENT_LENGTH)) { diff --git a/integration/sqljournaldiskcache/src/main/java/com/bumptech/glide/integration/sqljournaldiskcache/JournaledLruDiskCache.java b/integration/sqljournaldiskcache/src/main/java/com/bumptech/glide/integration/sqljournaldiskcache/JournaledLruDiskCache.java index 9ef2a76a81..e966360077 100644 --- a/integration/sqljournaldiskcache/src/main/java/com/bumptech/glide/integration/sqljournaldiskcache/JournaledLruDiskCache.java +++ b/integration/sqljournaldiskcache/src/main/java/com/bumptech/glide/integration/sqljournaldiskcache/JournaledLruDiskCache.java @@ -120,6 +120,7 @@ private static Looper getBackgroundLooper() { return workThread.getLooper(); } + @SuppressWarnings("checkstyle:UnnecessaryParentheses") // Readability private void openIfNotOpen() { if (!isOpen) { synchronized (this) { diff --git a/library/src/main/java/com/bumptech/glide/load/engine/DiskCacheStrategy.java b/library/src/main/java/com/bumptech/glide/load/engine/DiskCacheStrategy.java index b5b1379caf..3100826c91 100644 --- a/library/src/main/java/com/bumptech/glide/load/engine/DiskCacheStrategy.java +++ b/library/src/main/java/com/bumptech/glide/load/engine/DiskCacheStrategy.java @@ -124,6 +124,7 @@ public boolean isDataCacheable(DataSource dataSource) { return dataSource == DataSource.REMOTE; } + @SuppressWarnings("checkstyle:UnnecessaryParentheses") // Readability @Override public boolean isResourceCacheable( boolean isFromAlternateCacheKey, DataSource dataSource, EncodeStrategy encodeStrategy) { diff --git a/library/src/main/java/com/bumptech/glide/load/engine/bitmap_recycle/LruArrayPool.java b/library/src/main/java/com/bumptech/glide/load/engine/bitmap_recycle/LruArrayPool.java index 874f3b02b8..c1d932acde 100644 --- a/library/src/main/java/com/bumptech/glide/load/engine/bitmap_recycle/LruArrayPool.java +++ b/library/src/main/java/com/bumptech/glide/load/engine/bitmap_recycle/LruArrayPool.java @@ -126,7 +126,7 @@ private boolean mayFillRequest(int requestedSize, Integer actualSize) { } private boolean isNoMoreThanHalfFull() { - return currentSize == 0 || (maxSize / currentSize >= 2); + return currentSize == 0 || maxSize / currentSize >= 2; } @Override @@ -135,7 +135,7 @@ public synchronized void clearMemory() { } @Override - public synchronized void trimMemory(int level) { + public synchronized void trimMemory(int level){ if (level >= android.content.ComponentCallbacks2.TRIM_MEMORY_BACKGROUND) { clearMemory(); } else if (level >= android.content.ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN diff --git a/library/src/main/java/com/bumptech/glide/load/engine/bitmap_recycle/LruBitmapPool.java b/library/src/main/java/com/bumptech/glide/load/engine/bitmap_recycle/LruBitmapPool.java index 8ebf35628d..17f96f518c 100644 --- a/library/src/main/java/com/bumptech/glide/load/engine/bitmap_recycle/LruBitmapPool.java +++ b/library/src/main/java/com/bumptech/glide/load/engine/bitmap_recycle/LruBitmapPool.java @@ -239,18 +239,19 @@ public void clearMemory() { trimToSize(0); } + @SuppressWarnings("checkstyle:UnnecessaryParentheses") // Readability @SuppressLint("InlinedApi") @Override public void trimMemory(int level) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "trimMemory, level=" + level); } - if ((level >= ComponentCallbacks2.TRIM_MEMORY_BACKGROUND) - || ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) - && (level >= ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN))) { + if (level >= ComponentCallbacks2.TRIM_MEMORY_BACKGROUND + || (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M + && level >= ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN)) { clearMemory(); - } else if ((level >= ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN) - || (level == ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL)) { + } else if (level >= ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN + || level == ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL) { trimToSize(getMaxSize() / 2); } } diff --git a/library/src/main/java/com/bumptech/glide/load/engine/cache/ExternalPreferredCacheDiskCacheFactory.java b/library/src/main/java/com/bumptech/glide/load/engine/cache/ExternalPreferredCacheDiskCacheFactory.java index 1ac0a82200..db3f8ff177 100644 --- a/library/src/main/java/com/bumptech/glide/load/engine/cache/ExternalPreferredCacheDiskCacheFactory.java +++ b/library/src/main/java/com/bumptech/glide/load/engine/cache/ExternalPreferredCacheDiskCacheFactory.java @@ -48,14 +48,14 @@ public File getCacheDirectory() { // Already used internal cache, so keep using that one, // thus avoiding using both external and internal with transient errors. - if ((null != internalCacheDirectory) && internalCacheDirectory.exists()) { + if (internalCacheDirectory != null && internalCacheDirectory.exists()) { return internalCacheDirectory; } File cacheDirectory = context.getExternalCacheDir(); // Shared storage is not available. - if ((cacheDirectory == null) || (!cacheDirectory.canWrite())) { + if (cacheDirectory == null || !cacheDirectory.canWrite()) { return internalCacheDirectory; } if (diskCacheName != null) { diff --git a/library/src/main/java/com/bumptech/glide/load/resource/bitmap/DefaultImageHeaderParser.java b/library/src/main/java/com/bumptech/glide/load/resource/bitmap/DefaultImageHeaderParser.java index 458de79181..041319e11b 100644 --- a/library/src/main/java/com/bumptech/glide/load/resource/bitmap/DefaultImageHeaderParser.java +++ b/library/src/main/java/com/bumptech/glide/load/resource/bitmap/DefaultImageHeaderParser.java @@ -580,7 +580,7 @@ public int read(byte[] buffer, int byteCount) throws IOException { int numBytesRead = 0; int lastReadResult = 0; while (numBytesRead < byteCount - && ((lastReadResult = is.read(buffer, numBytesRead, byteCount - numBytesRead)) != -1)) { + && (lastReadResult = is.read(buffer, numBytesRead, byteCount - numBytesRead)) != -1) { numBytesRead += lastReadResult; } diff --git a/library/src/main/java/com/bumptech/glide/load/resource/drawable/AnimatedImageDecoder.java b/library/src/main/java/com/bumptech/glide/load/resource/drawable/AnimatedImageDecoder.java index ec642ce0ec..2c396e7e65 100644 --- a/library/src/main/java/com/bumptech/glide/load/resource/drawable/AnimatedImageDecoder.java +++ b/library/src/main/java/com/bumptech/glide/load/resource/drawable/AnimatedImageDecoder.java @@ -60,6 +60,7 @@ boolean handles(InputStream is) throws IOException { return isHandled(ImageHeaderParserUtils.getType(imageHeaderParsers, is, arrayPool)); } + @SuppressWarnings("checkstyle:UnnecessaryParentheses") // Readability private boolean isHandled(ImageType imageType) { return imageType == ImageType.ANIMATED_WEBP || (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && imageType == ImageType.ANIMATED_AVIF); diff --git a/third_party/gif_decoder/src/main/java/com/bumptech/glide/gifdecoder/GifHeaderParser.java b/third_party/gif_decoder/src/main/java/com/bumptech/glide/gifdecoder/GifHeaderParser.java index c6e24da678..a26d527f1d 100644 --- a/third_party/gif_decoder/src/main/java/com/bumptech/glide/gifdecoder/GifHeaderParser.java +++ b/third_party/gif_decoder/src/main/java/com/bumptech/glide/gifdecoder/GifHeaderParser.java @@ -355,7 +355,7 @@ private void readNetscapeExt() { int b2 = ((int) block[2]) & MASK_INT_LOWEST_BYTE; header.loopCount = (b2 << 8) | b1; } - } while ((blockSize > 0) && !err()); + } while (blockSize > 0 && !err()); } diff --git a/third_party/gif_decoder/src/main/java/com/bumptech/glide/gifdecoder/StandardGifDecoder.java b/third_party/gif_decoder/src/main/java/com/bumptech/glide/gifdecoder/StandardGifDecoder.java index 7655723103..ad9ea6e061 100644 --- a/third_party/gif_decoder/src/main/java/com/bumptech/glide/gifdecoder/StandardGifDecoder.java +++ b/third_party/gif_decoder/src/main/java/com/bumptech/glide/gifdecoder/StandardGifDecoder.java @@ -168,7 +168,7 @@ public void advance() { @Override public int getDelay(int n) { int delay = -1; - if ((n >= 0) && (n < header.frameCount)) { + if (n >= 0 && n < header.frameCount) { delay = header.frames.get(n).delay; } return delay; @@ -499,6 +499,7 @@ private Bitmap setPixels(GifFrame currentFrame, GifFrame previousFrame) { return result; } + @SuppressWarnings("checkstyle:UnnecessaryParentheses") // Readability private void copyIntoScratchFast(GifFrame currentFrame) { int[] dest = mainScratch; int downsampledIH = currentFrame.ih; @@ -807,7 +808,7 @@ private void decodeBitmapData(GifFrame frame) { prefix[available] = (short) oldCode; suffix[available] = (byte) first; ++available; - if (((available & codeMask) == 0) && (available < MAX_STACK_SIZE)) { + if ((available & codeMask) == 0 && available < MAX_STACK_SIZE) { ++codeSize; codeMask += available; }