Skip to content

Commit

Permalink
Update Checkstyle to 8.45.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sjudd committed Sep 19, 2023
1 parent 69e2204 commit bd2a519
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ subprojects { project ->
apply plugin: 'checkstyle'

checkstyle {
toolVersion = '8.5'
toolVersion = '8.45.1'
}

checkstyle {
Expand Down
4 changes: 3 additions & 1 deletion checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
<property name="format" value="^\s*for \(.*?([^ ]:|:[^ ])"/>
<property name="message" value="Space needed around ':' character."/>
</module>

<module name="SuppressWarningsFilter" />
<module name="TreeWalker">
<module name="SuppressWarningsHolder" />

<!-- Checks for uncommented main() methods (debugging leftovers). -->
<!-- Checks that long constants are defined with an upper ell. -->
<!-- See http://checkstyle.sourceforge.net/config_misc.html#UpperEll -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, List<String>> headers = info.getAllHeaders();
if (headers.containsKey(CONTENT_LENGTH)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ private static Looper getBackgroundLooper() {
return workThread.getLooper();
}

@SuppressWarnings("checkstyle:UnnecessaryParentheses") // Readability
private void openIfNotOpen() {
if (!isOpen) {
synchronized (this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit bd2a519

Please sign in to comment.