Sample

int-0ff1bb5a636d-I01

Remove line comments, block comments, and Javadoc

Matched original source

Lines162

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.7510–1; higher is more readable
Dorn0.7070–1; higher is more readable
Mi0.340–1; higher is more readable
LLOC50Logical lines; fewer is more readable
DeepSeek V4 Pro160–20; mean of three runs
GPT-6.1 Sol15.670–20; mean of three runs
BTTF0.5020–1; higher is more readable

Views

Source code

package io.netty.util.concurrent; import io.netty.util.internal.ObjectUtil; 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 public PromiseCombiner() { this(ImmediateEventExecutor.INSTANCE); } public PromiseCombiner(EventExecutor executor) { this.executor = ObjectUtil.checkNotNull(executor, "executor"); } @Deprecated public void add(Promise promise) { add((Future) promise); } @SuppressWarnings({ "unchecked", "rawtypes" }) public void add(Future future) { checkAddAllowed(); checkInEventLoop(); ++expectedCount; future.addListener(listener); } @Deprecated public void addAll(Promise... promises) { addAll((Future[]) promises); } @SuppressWarnings({ "unchecked", "rawtypes" }) public void addAll(Future... futures) { for (Future future : futures) { this.add(future); } } 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.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.435−6.652

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

Score0.751

Feature contributions

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

Intercept 0.07 + feature contributions = 0.881 (log-odds).
Score = sigmoid(0.881) = 0.707.

Score0.34
Score50
Run 1

The code is generally well-structured and readable. It uses clear naming conventions, separates concerns into private methods (checkInEventLoop, tryPromise, checkAddAllowed), and keeps methods concise. The listener's logic is appropriately encapsulated in an inner class with a helper method (operationComplete0) to handle event loop concerns. However, some issues slightly reduce readability: the listener is declared before the executor field it references, which disrupts natural top-to-bottom flow. There are numerous blank lines and comments suggesting editing artifacts. The deprecated methods and raw type suppressions add noise. Nesting is moderate - the inner class contains an anonymous Runnable, but the logic is flat enough to follow. Action granularity is mostly good, with one logical operation per line. Overall, the code is maintainable and clear but could benefit from field ordering improvements and removal of unnecessary blank lines/comments.

Run 2

The code is well-structured with clear class organization and logical grouping of methods and fields. Nesting is shallow except for the listener inner class with its inline Runnable, which is acceptable. Intent is clear: combine multiple futures into one aggregated promise. The code is reasonably concise, though there are many blank lines and excessive Javadoc spacing that add unnecessary length. Action granularity is good—most lines perform one logical action. The reading flow is natural, with methods arranged in a sensible order. Minor readability improvements could include reducing excessive blank lines, adding a comment to explain the listener's purpose, and consolidating deprecated overloaded methods. Overall, the code is quite readable and maintainable.

Run 3

The code is generally well-structured and readable. It has clear separation of methods, reasonable naming, and consistent formatting. The listener implementation handles event loop dispatch correctly with flat nesting. Some readability issues: the deprecated no-arg constructor and multiple deprecated methods add noise; the add/addAll methods have unnecessary @SuppressWarnings; there are comments with odd spacing/empty lines; and the listener is defined as an anonymous inner class at field level, which slightly hurts natural flow. Overall intent is clear, actions are granular, and nesting is minimal.

Run 1

Code Structure: Fields, constructors, public operations, and private helpers are logically organized, though the large inline listener interrupts the layout. Nesting: Most methods are flat; anonymous listener and Runnable classes introduce moderate nesting. Clarity of intent: Descriptive names make completion counting, failure tracking, and aggregate completion understandable, but concurrency assumptions and raw generic types require additional interpretation. Code length: Methods are concise, but excessive blank lines unnecessarily expand the file. Action granularity: Statements generally perform one action per line, making state changes easy to follow. Reading flow: Adding futures and finishing aggregation form a coherent workflow, but irregular spacing and callbacks embedded among fields disrupt scanning.

Run 2

Code Structure: Responsibilities are logically separated into adding futures, finishing aggregation, handling completion, and validating state. Nesting: Most methods are flat, although the anonymous listener containing an anonymous Runnable introduces deeper nesting. Clarity of intent: Descriptive names make aggregation behavior understandable, but raw generic types and undocumented event-loop assumptions require additional interpretation. Code length: Methods are concise, but excessive blank lines unnecessarily expand the code; deprecated overloads add minor repetition. Action granularity: Statements generally perform one action per line, making updates and checks easy to follow. Reading flow: Consistent formatting and small helper methods support natural reading, but large whitespace gaps and placing the executor field after the listener interrupt the flow.

Run 3

Code Structure: Cohesive class with well-separated methods for registration, completion, and validation; the embedded listener slightly interrupts organization. Nesting: Mostly shallow, though anonymous listener and Runnable classes introduce localized depth. Clarity of intent: Descriptive names make promise aggregation understandable, but raw types, deprecated overloads, and undocumented lifecycle assumptions require extra interpretation. Code length: Methods are concise, but excessive blank lines and anonymous-class boilerplate unnecessarily expand the listing. Action granularity: Statements generally perform one action per line, making state changes easy to follow. Reading flow: Registration and finish methods follow a logical progression, supported by focused helpers; large whitespace gaps and placing the executor field after the listener disrupt otherwise natural reading.