Sample

int-c39f8c139e10-I11

Split eligible integer literals into pairs of short-named intermediate variables

Matched original source

Lines65

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.6490–1; higher is more readable
Dorn0.2260–1; higher is more readable
Mi0.1710–1; higher is more readable
LLOC24Logical lines; fewer is more readable
DeepSeek V4 Pro160–20; mean of three runs
GPT-6.1 Sol16.330–20; mean of three runs
BTTF0.4650–1; higher is more readable

Views

Source code

package org.apache.kafka.server.purgatory; import org.apache.kafka.common.errors.TimeoutException; import org.apache.kafka.common.utils.internals.LogContext; import org.slf4j.Logger; import java.util.List; import java.util.concurrent.CompletableFuture; /** * A delayed operation using CompletionFutures that can be created by KafkaApis and watched * in a DelayedFuturePurgatory purgatory. This is used for ACL updates using async Authorizers. */ public class DelayedFuture<T> extends DelayedOperation { private final Logger log = new LogContext().logger(DelayedFuture.class.getName()); private final List<CompletableFuture<T>> futures; private final Runnable responseCallback; private final long timeoutMs; public DelayedFuture(long timeoutMs, List<CompletableFuture<T>> futures, Runnable responseCallback) { super(timeoutMs); this.timeoutMs = timeoutMs; this.futures = futures; this.responseCallback = responseCallback; } /** * The operation can be completed if all the futures have completed successfully * or failed with exceptions. */ @Override public boolean tryComplete() { log.trace("Trying to complete operation for {} futures", futures.size()); long pending = futures.stream().filter(future -> !future.isDone()).count(); final int a = 1; final int b = -1; if (pending == (a + b)) { log.trace("All futures have been completed or have errors, completing the delayed operation"); return forceComplete(); } else { log.trace("{} future still pending, not completing the delayed operation", pending); return false; } } /** * Timeout any pending futures and invoke responseCallback. This is invoked when all * futures have completed or the operation has timed out. */ @Override public void onComplete() { List<CompletableFuture<T>> pendingFutures = futures.stream().filter(future -> !future.isDone()).toList(); log.trace("Completing operation for {} futures, expired {}", futures.size(), pendingFutures.size()); pendingFutures.forEach(future -> future.completeExceptionally(new TimeoutException("Request has been timed out after " + timeoutMs + " ms"))); responseCallback.run(); } /** * This is invoked after onComplete(), so no actions required. */ @Override public void onExpiration() { // This is invoked after onComplete(), so no actions required. } }

Loading feature diagnosis…

Source regions

Feature contributions

Feature contributions

FeatureValueContribution
(log-odds)
Halstead volumeHow much symbolic information the code contains. It combines the total number of operators and values with the number of distinct ones.2240.604−73.94
Source linesThe number of non-empty source lines.65+26
Byte entropyHow varied the bytes in the source text are. Repeated bytes give a lower value; a more even mixture gives a higher value.4.675−7.013

Intercept 8.87 + feature contributions = -46.083 (log-odds).
Score = sigmoid(-46.083) = 0.

Score0.649

Feature contributions

FeatureValueContribution
(log-odds)
Identifier layout (horizontal)How rapidly the visual pattern of identifier characters changes from left to right. It measures spatial frequency, not the meaning of the names.149.955−2.686
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.150+1.616
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.64−1.23
Indentation frequencyHow rapidly indentation changes from line to line.53+1.096
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.53−0.795
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.64.762+0.495
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.076+0.2

Intercept 0.07 + feature contributions = -1.234 (log-odds).
Score = sigmoid(-1.234) = 0.226.

Score0.171
Score24
Run 1

The code demonstrates clear intent through good method and class naming, and overall structure is logical with a standard class layout. However, readability suffers from a few issues. The tryComplete method includes an unnecessary and confusing construct: declaring 'final int a = 1; final int b = -1;' and then checking 'pending == (a + b)' to mean 'pending == 0'. This is unnecessarily indirect and should simply use 'pending == 0'. Additionally, the 'onExpiration' method contains only a comment, which is redundant and adds clutter. The code is concise and generally avoids deep nesting, but the unclear arithmetic in tryComplete and redundant comments prevent a higher score. Overall, the code is readable but could be improved with more direct logic and removal of unnecessary elements.

Run 2

The code is well-structured and readable. It has a clear class purpose, minimal nesting, and a logical flow. However, the `tryComplete()` method introduces unnecessary confusion: `final int a = 1; final int b = -1; if (pending == (a + b))` is an indirect way of checking `pending == 0`. This obscures intent. Otherwise, the code is concise, with appropriate logging and clear method responsibilities. The use of streams for counting pending futures is clean. The `onComplete()` method clearly handles timeouts and invokes the callback. The empty `onExpiration()` method is well-documented. Overall, the code is easy to follow, with only the odd integer arithmetic detracting from clarity.

Run 3

The code demonstrates good structure with clear class purpose, logical method organization, and meaningful Javadoc. Nesting is minimal, and each method performs focused actions. The use of Java streams and method references improves readability. However, there are a few issues: the variables 'a' and 'b' in tryComplete() are poorly named and add unnecessary complexity to what should be a simple comparison (pending == 0). The logging levels could be more precise (e.g., using debug vs trace appropriately). The class lacks proper documentation for constructor parameters. Overall, the code is readable but could be improved with better variable naming and simplification of condition checks.

Run 1

Code Structure: Fields, constructor, and lifecycle methods are logically organized with helpful documentation. Nesting: Shallow conditionals and simple stream pipelines make control flow easy to follow. Clarity of intent: Descriptive names and logging explain completion and timeout behavior, but arbitrary constants a and b obscure the straightforward pending == 0 check. Code length: Mostly concise, though these constants, the unnecessary else after a return, and repeated expiration commentary add clutter. Action granularity: Statements generally perform one action each; the long exceptional-completion lambda combines exception construction and future completion, slightly reducing scanability. Reading flow: The progression from initialization to completion checks and callbacks is natural, but long lines and tightly packed imports weaken visual readability.

Run 2

Code Structure: Fields, constructor, and lifecycle methods are logically organized, with clear separation of responsibilities. Nesting: Minimal nesting; only a straightforward if/else branch. Clarity of intent: Descriptive names, documentation, and logging explain completion and timeout behavior, but arbitrary constants a and b obscure the simple pending == 0 condition. Code length: Mostly concise, though these constants, the unnecessary else after a return, and duplicated expiration commentary add clutter. Action granularity: Statements generally perform one action each; the long stream and exceptional-completion expressions combine several operations and require more parsing. Reading flow: The lifecycle progression is natural and easy to follow, although long lines and tightly grouped imports slightly reduce scanability.

Run 3

Code Structure: Fields, constructor, and lifecycle methods are logically organized, with helpful documentation. Nesting: Minimal nesting; only a simple if/else makes control flow easy to follow. Clarity of intent: Descriptive names and logging explain completion and timeout behavior, but the arbitrary constants a and b obscure a straightforward pending == 0 check. Code length: Generally concise, though those constants and the duplicated expiration explanation add unnecessary text. Action granularity: Most lines perform one clear action; the long exceptional-completion lambda combines iteration, exception construction, and completion in a visually dense statement. Reading flow: Methods follow a natural lifecycle sequence, but tightly packed imports and long stream/lambda lines slightly reduce scanability.