Sample

int-fcf345420c1e-I06

Invert eligible conditions and exchange their branches

Matched original source

Lines162

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.8360–1; higher is more readable
Dorn0.6520–1; higher is more readable
Mi0.0860–1; higher is more readable
LLOC50Logical lines; fewer is more readable
DeepSeek V4 Pro110–20; mean of three runs
GPT-6.1 Sol130–20; mean of three runs
BTTF0.5390–1; higher is more readable

Views

Source code

package io.netty.util.concurrent; import io.netty.util.internal.ObjectUtil; /** * <p>A promise combiner monitors the outcome of a number of discrete futures, then notifies a final, aggregate promise * when all of the combined futures are finished. The aggregate promise will succeed if and only if all of the combined * futures succeed. If any of the combined futures fail, the aggregate promise will fail. The cause failure for the * aggregate promise will be the failure for one of the failed combined futures; if more than one of the combined * futures fails, exactly which cause of failure will be assigned to the aggregate promise is undefined.</p> * * <p>Callers may populate a promise combiner with any number of futures to be combined via the * {@link PromiseCombiner#add(Future)} and {@link PromiseCombiner#addAll(Future[])} methods. When all futures to be * combined have been added, callers must provide an aggregate promise to be notified when all combined promises have * finished via the {@link PromiseCombiner#finish(Promise)} method.</p> * * <p>This implementation is <strong>NOT</strong> thread-safe and all methods must be called * from the {@link EventExecutor} thread.</p> */ public final class PromiseCombiner { private int expectedCount; private int doneCount; private Promise<Void> aggregatePromise; private Throwable cause; private final GenericFutureListener<Future<?>> listener = new GenericFutureListener<Future<?>>() { @Override public void operationComplete(final Future<?> future) { if (!((executor.inEventLoop()))) { executor.execute(new Runnable() { @Override public void run() { operationComplete0(future); } }); } else { operationComplete0(future); } } private void operationComplete0(Future<?> future) { assert executor.inEventLoop(); ++doneCount; if (!((!future.isSuccess() && cause == null))) {} else { cause = future.cause(); } if (!((doneCount == expectedCount && aggregatePromise != null))) {} else { tryPromise(); } } }; private final EventExecutor executor; /** * Deprecated use {@link PromiseCombiner#PromiseCombiner(EventExecutor)}. */ @Deprecated public PromiseCombiner() { this(ImmediateEventExecutor.INSTANCE); } /** * The {@link EventExecutor} to use for notifications. You must call {@link #add(Future)}, {@link #addAll(Future[])} * and {@link #finish(Promise)} from within the {@link EventExecutor} thread. * * @param executor the {@link EventExecutor} to use for notifications. */ public PromiseCombiner(EventExecutor executor) { this.executor = ObjectUtil.checkNotNull(executor, "executor"); } /** * Adds a new promise to be combined. New promises may be added until an aggregate promise is added via the * {@link PromiseCombiner#finish(Promise)} method. * * @param promise the promise to add to this promise combiner * * @deprecated Replaced by {@link PromiseCombiner#add(Future)}. */ @Deprecated public void add(Promise promise) { add((Future) promise); } /** * Adds a new future to be combined. New futures may be added until an aggregate promise is added via the * {@link PromiseCombiner#finish(Promise)} method. * * @param future the future to add to this promise combiner */ @SuppressWarnings({ "unchecked", "rawtypes" }) public void add(Future future) { checkAddAllowed(); checkInEventLoop(); ++expectedCount; future.addListener(listener); } /** * Adds new promises to be combined. New promises may be added until an aggregate promise is added via the * {@link PromiseCombiner#finish(Promise)} method. * * @param promises the promises to add to this promise combiner * * @deprecated Replaced by {@link PromiseCombiner#addAll(Future[])} */ @Deprecated public void addAll(Promise... promises) { addAll((Future[]) promises); } /** * Adds new futures to be combined. New futures may be added until an aggregate promise is added via the * {@link PromiseCombiner#finish(Promise)} method. * * @param futures the futures to add to this promise combiner */ @SuppressWarnings({ "unchecked", "rawtypes" }) public void addAll(Future... futures) { for (Future future : futures) { this.add(future); } } /** * <p>Sets the promise to be notified when all combined futures have finished. If all combined futures succeed, * then the aggregate promise will succeed. If one or more combined futures fails, then the aggregate promise will * fail with the cause of one of the failed futures. If more than one combined future fails, then exactly which * failure will be assigned to the aggregate promise is undefined.</p> * * <p>After this method is called, no more futures may be added via the {@link PromiseCombiner#add(Future)} or * {@link PromiseCombiner#addAll(Future[])} methods.</p> * * @param aggregatePromise the promise to notify when all combined futures have finished */ public void finish(Promise<Void> aggregatePromise) { ObjectUtil.checkNotNull(aggregatePromise, "aggregatePromise"); checkInEventLoop(); if (!((this.aggregatePromise != null))) {} else { throw new IllegalStateException("Already finished"); } this.aggregatePromise = aggregatePromise; if (!((doneCount == expectedCount))) {} else { tryPromise(); } } private void checkInEventLoop() { if (!((!executor.inEventLoop()))) {} else { throw new IllegalStateException("Must be called from EventExecutor thread"); } } private boolean tryPromise() { return (cause == null) ? aggregatePromise.trySuccess(null) : aggregatePromise.tryFailure(cause); } private void checkAddAllowed() { if (!((aggregatePromise != null))) {} else { throw new IllegalStateException("Adding promises is not allowed after finished adding"); } } }

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.3416.592−112.748
Source linesThe number of non-empty source lines.162+64.8
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.587−6.881

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

Score0.836

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.163−4.735
Indentation frequencyHow rapidly indentation changes from line to line.107+2.964
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.161.81+1.852
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.119.945−1.415
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.115.656+1.062
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.052+0.435
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398

Intercept 0.07 + feature contributions = 0.63 (log-odds).
Score = sigmoid(0.63) = 0.652.

Score0.086
Score50
Run 1

The code has some good elements: clear Javadoc, logical class organization, and descriptive method names. However, it is severely undermined by bizarre conditional patterns like `if (!((condition))) {} else { ... }`, which inverts logic and makes the code hard to follow. These patterns appear consistently throughout, suggesting either obfuscation or an automated transformation. The anonymous inner listener and nested Runnable add complexity, though the nesting level is manageable. The intent of the class is clear, but the actual implementation of conditional logic is ambiguous and unnatural. Action granularity is mixed—some lines do too much, while the inverted conditionals spread a single logical action across multiple lines with empty blocks. Overall, the code works but reads as if deliberately made less maintainable despite its structural clarity.

Run 2

The code has good documentation and logical structure, but readability is significantly hurt by inverted conditional patterns like `if (!((condition))) {} else { ... }` throughout. These empty-if blocks with logic in else clauses are confusing and non-idiomatic. The anonymous inner listener class adds nesting and obscures the main flow. Method names like `operationComplete0` are unclear. The class is concise overall, but the action granularity suffers—multiple operations are packed into conditionals awkwardly. While the purpose is clear from Javadoc, the implementation's intent is muddied by these anti-patterns. The code would be much more readable with straightforward `if (condition) { ... }` statements and breaking the listener logic into clearer methods.

Run 3

The code has clear documentation and logical class structure, with methods that are generally short and purposeful. However, readability is significantly hurt by unnatural inverted conditional patterns (e.g., `if (!condition) {} else { ... }`) that obscure intent and disrupt reading flow. The listener's operationComplete method contains a nested anonymous Runnable with inner logic, adding unnecessary depth. Several methods could be more concise, and the inversion of boolean checks adds cognitive overhead. Action granularity is mostly fine, but the overall flow feels awkward due to these stylistic choices.

Run 1

Code Structure: Well-organized class with focused methods separating registration, completion, and validation. Nesting: Mostly shallow, although anonymous listener and Runnable classes add depth. Clarity of intent: Descriptive names and thorough documentation explain promise aggregation, but negated conditions, redundant parentheses, and empty if branches obscure straightforward checks. Code length: Methods are concise; repetitive documentation and deprecated overloads increase overall length. Action granularity: Generally one action per line, but compact empty-if/else constructs reduce visual clarity. Reading flow: Method organization and consistent formatting support navigation, while inverted conditional logic repeatedly interrupts natural reading. Overall, the design is understandable, but unnecessarily convoluted conditionals significantly reduce readability.

Run 2

Code Structure: Well organized into focused methods, with separate validation and completion helpers. Nesting: Mostly shallow, though anonymous listener and Runnable classes add depth. Clarity of intent: Descriptive names and thorough documentation explain aggregation behavior, but inverted conditions with empty if branches, redundant parentheses, and double negations obscure straightforward checks. Code length: Implementation methods are concise; extensive, partly repetitive documentation and deprecated overloads increase overall length. Action granularity: Generally one action per line, but empty if/else constructs compress control syntax awkwardly. Reading flow: Public methods follow a sensible lifecycle, and helper extraction supports comprehension; however, repeatedly translating negated conditions interrupts the otherwise natural flow.

Run 3

Code Structure: Well-organized class with distinct methods for adding futures, finishing aggregation, and validating state. Nesting: Most methods are shallow, but anonymous listener and Runnable classes introduce deeper nesting. Clarity of intent: Descriptive names and thorough documentation clarify the purpose; negated conditions, redundant parentheses, and empty if branches followed by meaningful else blocks substantially obscure straightforward checks. Code length: Implementation methods are concise, though repetitive documentation and deprecated overloads increase length. Action granularity: Generally one action per line, but inline empty branches compress conditional structure awkwardly. Reading flow: Public operations and private helpers follow a reasonable sequence, yet inverted conditional patterns repeatedly interrupt natural reading and require mentally reconstructing the intended logic.