Sample

int-7cd1948d9f61-I10

Remove about 40% of line-break groups while retaining structure

Matched original source

Lines121

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.7490–1; higher is more readable
Dorn0.220–1; higher is more readable
Mi0.0130–1; higher is more readable
LLOC50Logical lines; fewer is more readable
DeepSeek V4 Pro3.670–20; mean of three runs
GPT-6.1 Sol110–20; mean of three runs
BTTF0.4680–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()) { operationComplete0(future); } else { executor.execute(new Runnable() { @Override public void run() { operationComplete0(future); } }); } } private void operationComplete0(Future<?> future) { assert executor.inEventLoop(); ++doneCount; if (!future.isSuccess() && cause == null) { cause = future.cause(); } if (doneCount == expectedCount && aggregatePromise != null) { 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) { throw new IllegalStateException("Already finished"); } this.aggregatePromise = aggregatePromise; if (doneCount == expectedCount) { tryPromise(); } } private void checkInEventLoop() { if (!executor.inEventLoop()) { 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) { 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.3071.679−101.365
Source linesThe number of non-empty source lines.121+48.4
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.679−7.018

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

Score0.749

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.175.967−3.788
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.122−3.283
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.175.967+2.035
Indentation frequencyHow rapidly indentation changes from line to line.66+1.546
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.120.876+1.28
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.048+0.48
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398

Intercept 0.07 + feature contributions = -1.263 (log-odds).
Score = sigmoid(-1.263) = 0.22.

Score0.013
Score50
Run 1

This code has severe readability issues. The structure is extremely tangled—multiple statements are crammed onto single lines, imports and class-level code share lines, and listener logic is deeply nested with inline anonymous inner classes. Nesting is excessive: inside the `operationComplete` listener, there is an `if` block containing an anonymous `Runnable` with another method call to `operationComplete0`, all compressed together. Clarity of intent is poor because whitespace and line breaks are missing, making it difficult to parse method boundaries and logic flow. Code length is not excessive, but compression to single lines destroys readability. Action granularity is often several actions per line, such as incrementing a counter, checking future success, and setting cause all in one line. Reading flow is highly unnatural—readers must decrypt dense lines instead of following a structured, vertically aligned sequence. Despite Javadocs being present, they are visually embedded with code in ways that further obscure separation.

Run 2

The code has severe readability issues. Structure is tangled: numerous methods are crammed onto single lines alongside field declarations, violating action granularity. Nesting is problematic — the anonymous listener contains nested conditionals and an inner anonymous Runnable, obscuring logic. Intent is partially documented via Javadoc, but the implementation's formatting undermines clarity. Code length is bloated by compression artifacts (multiple statements per line). Reading flow is disorganized; declarations, methods, and logic run together without visual separation. While method names are descriptive, the formatting makes scanning difficult. The mixed indentation styles and lack of consistent line breaks significantly reduce maintainability despite the underlying logic being relatively straightforward.

Run 3

The code suffers from severe formatting and structural problems. Multiple statements are crammed onto single lines, making it difficult to parse the logic. The inner anonymous listener class is particularly problematic, with nested method definitions and conditionals on the same lines, obscuring the flow of control. While the class has a clear purpose (combining futures) and basic naming is acceptable, the implementation details are obscured by poor layout. The code violates most readability principles: no consistent line breaks, multiple actions per line, deeply nested anonymous inner classes, and confusing reading flow. The JavaDoc is present but the code itself appears as if it was auto-minified, making it unnecessarily difficult to read and maintain.

Run 1

Code Structure: Responsibilities are logically separated into small methods, but compressed declarations and method boundaries obscure the organization. Nesting: Most control flow is shallow; the anonymous listener containing an anonymous Runnable adds localized complexity. Clarity of intent: Descriptive names and comprehensive Javadoc clearly explain aggregation, failure handling, and thread constraints. Code length: Implementation methods are concise, though repeated documentation and deprecated overloads increase reading volume. Action granularity: Multiple declarations, checks, increments, and calls frequently share a line, making individual operations harder to distinguish. Reading flow: Inconsistent indentation, inline annotations, crowded braces, and adjacent method definitions repeatedly interrupt otherwise natural control flow. Overall, the underlying design is understandable, but poor formatting substantially reduces readability.

Run 2

Code Structure: Responsibilities are logically separated into methods, but compressed declarations and merged method boundaries obscure that organization. Nesting: Most methods are shallow; the listener's anonymous Runnable introduces moderate nesting that cramped formatting makes harder to follow. Clarity of intent: Descriptive names and thorough Javadoc clearly explain aggregation, failure handling, and event-loop constraints. Code length: Implementation methods are concise, although extensive, somewhat repetitive documentation increases reading length. Action granularity: Multiple declarations, checks, updates, and control statements frequently share a line, reducing readability. Reading flow: Inconsistent indentation, inline annotations, crowded braces, and comments attached to closing braces interrupt otherwise logical progression. The underlying design is understandable, but formatting significantly increases the effort required to trace execution.

Run 3

Code Structure: Responsibilities are logically separated into adding futures, finishing aggregation, handling completion, and validation, but compressed formatting obscures method boundaries. Nesting: Generally shallow, though nested anonymous listener and Runnable implementations make completion handling harder to scan. Clarity of intent: Descriptive names and detailed documentation clearly explain aggregation behavior and threading requirements. Code length: Implementation methods are concise; documentation is lengthy but useful, and deprecated overloads add some overhead. Action granularity: Multiple declarations, checks, updates, and control statements share lines, substantially reducing readability. Reading flow: Inconsistent brace placement, inline annotations, and methods joined to closing braces interrupt natural top-to-bottom reading. Overall, clear design and documentation are undermined by poor formatting.