Sample

int-48bfbc7ddaba-I03

Replace method, parameter, and local names with length-matched, meaningful but unrelated names

Matched original source

Lines162

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.8330–1; higher is more readable
Dorn0.6660–1; higher is more readable
Mi0.0790–1; higher is more readable
LLOC50Logical lines; fewer is more readable
DeepSeek V4 Pro3.670–20; mean of three runs
GPT-6.1 Sol11.330–20; mean of three runs
BTTF0.4740–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 validateSession(final Future<?> config) { if (executor.inEventLoop()) { validateRequest(config); } else { executor.execute(new Runnable() { @Override public void copy() { validateRequest(config); } }); } } private void validateRequest(Future<?> client) { assert executor.inEventLoop(); ++doneCount; if (!client.isSuccess() && cause == null) { cause = client.cause(); } if (doneCount == expectedCount && aggregatePromise != null) { readClient(); } } }; 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 document) { this.executor = ObjectUtil.checkNotNull(document, "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 emit(Promise invoice) { emit((Future) invoice); } /** * 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 emit(Future amount) { validateBalance(); validateMessage(); ++expectedCount; amount.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 expand(Promise... duration) { expand((Future[]) duration); } /** * 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 expand(Future... feature) { for (Future status : feature) { this.emit(status); } } /** * <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 select(Promise<Void> defaultBalance) { ObjectUtil.checkNotNull(defaultBalance, "aggregatePromise"); validateMessage(); if (this.aggregatePromise != null) { throw new IllegalStateException("Already finished"); } this.aggregatePromise = defaultBalance; if (doneCount == expectedCount) { readClient(); } } private void validateMessage() { if (!executor.inEventLoop()) { throw new IllegalStateException("Must be called from EventExecutor thread"); } } private boolean readClient() { return (cause == null) ? aggregatePromise.trySuccess(null) : aggregatePromise.tryFailure(cause); } private void validateBalance() { 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.3108.102−102.567
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.568−6.852

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

Score0.833

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.686+1.85
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.963−1.416
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.046+0.5
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398

Intercept 0.07 + feature contributions = 0.692 (log-odds).
Score = sigmoid(0.692) = 0.666.

Score0.079
Score50
Run 1

The code is severely unreadable due to nonsensical method and variable names (e.g., validateSession, copy, validateRequest, readClient, emit, expand, select, validateMessage, validateBalance, feature, duration, invoice, amount) that do not match their actual purpose or the documented API. The Javadoc references methods (add, addAll, finish) that do not exist, while the implemented method names are unrelated. The listener implementation contains confusing nested logic with misleading method names and an unnecessary private method. Field names like expectedCount, doneCount, aggregatePromise are reasonable, but the overall clarity is destroyed by the naming inconsistencies and dead code references. The structure is muddled, though nesting is shallow. The code appears to be a corrupted or obfuscated version of a legitimate PromiseCombiner, making it nearly impossible to infer intent without significant effort.

Run 2

This code is severely obfuscated and unreadable. Method names are misleading or nonsensical in context: 'emit' should be 'add', 'expand' should be 'addAll', 'select' should be 'finish', 'validateSession' should be 'operationComplete', 'validateRequest' should be 'checkDone', etc. Parameter names like 'invoice', 'amount', 'duration', 'status', 'feature', 'defaultBalance', 'document', and 'config' are completely unrelated to promises or futures. The listener's inner class method 'copy' should be 'run'. Key logic (done counting, cause capture, final completion) is buried under these confusing names. Javadoc comments reference the correct method names, but the actual code contradicts them, creating cognitive dissonance. The structure itself is not deeply nested, but the constant name-swapping makes every line require translation. This appears to be deliberately obscured code that fails every readability criterion: clarity of intent is absent, reading flow is unnatural, and action granularity is muddled by misnamed methods performing hidden validations.

Run 3

The code has severe readability issues. Although the overall structure has recognizable sections (fields, constructors, public methods, private helpers), the method and parameter names are misleading and unrelated to the functionality (e.g., 'emit' instead of 'add', 'select' instead of 'finish', parameter names like 'invoice', 'amount', 'document', 'duration', 'feature'). The anonymous listener's method names are also incorrect ('validateSession' should be 'operationComplete', 'copy' should be 'run', 'validateRequest' should be 'notifyListener'). The nesting is moderate, but the incorrect naming obscures intent significantly. Action granularity is mostly one action per line, but the flow is disrupted by misleading method calls and documentation that references methods that no longer exist ('add', 'finish'), creating confusion. The length is reasonable, but clarity and accuracy of naming are poor.

Run 1

1. Code Structure: Fields, constructors, public operations, and private helpers are logically separated, with focused methods. 2. Nesting: Most methods are shallow, although the listener containing an anonymous Runnable introduces deeper nesting. 3. Clarity of intent: Class documentation explains aggregation well, but misleading names such as emit, select, readClient, and defaultBalance obscure actual behavior. Documentation references add, addAll, and finish, which do not match the declared methods. Callback names validateSession and copy also conflict with expected listener and Runnable conventions, increasing confusion. 4. Code length: Implementation methods are concise; extensive, partly repetitive documentation adds length without reliably clarifying the renamed API. 5. Action granularity: Statements generally perform one action per line, making updates and checks easy to follow. 6. Reading flow: Consistent formatting and straightforward conditions support local reading, but understanding the overall lifecycle requires mentally translating unrelated names and reconciling documentation with implementation.

Run 2

Code Structure: Fields, constructors, public methods, and private helpers are logically organized, with completion tracking isolated in a listener. Nesting: Most methods are flat, though the anonymous listener containing an anonymous Runnable adds complexity. Clarity of intent: The main weakness is misleading names such as emit, select, readClient, and defaultBalance. Documentation references add, addAll, and finish, which do not match the actual methods; callback names also conflict with the apparent interfaces. Code length: Implementation methods are concise, but extensive, repetitive documentation increases reading effort. Action granularity: Statements generally perform one action per line, making state changes easy to follow. Reading flow: Formatting and small methods support sequential reading, but unrelated parameter names and mismatched documentation force readers to reconstruct the intended promise-combination behavior.

Run 3

Code Structure: Fields, constructors, public operations, and private helpers are logically organized into small methods. Nesting: Mostly shallow, although the anonymous listener containing an anonymous Runnable adds complexity. Clarity of intent: The main weakness is misleading names such as emit, select, readClient, document, and defaultBalance, which obscure future aggregation. Documentation references absent add/addAll/finish methods and mismatched parameter names. Callback names validateSession and copy also conflict with the expected listener and Runnable interfaces, creating confusion. Code length: Implementation methods are concise, but extensive, repetitive documentation increases reading effort. Action granularity: Statements generally perform one action per line, making individual operations easy to follow. Reading flow: Completion counting and failure propagation follow a reasonable sequence, but inconsistent terminology and stale documentation repeatedly interrupt understanding.