Sample

int-382a2d9faa4e-I01

Remove line comments, block comments, and Javadoc

Matched original source

Lines291

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.7590–1; higher is more readable
Dorn0.0280–1; higher is more readable
Mi0.5540–1; higher is more readable
LLOC58Logical lines; fewer is more readable
DeepSeek V4 Pro15.670–20; mean of three runs
GPT-6.1 Sol14.670–20; mean of three runs
BTTF0.590–1; higher is more readable

Views

Source code

package com.google.common.collect; import com.google.common.annotations.GwtCompatible; import com.google.common.primitives.Booleans; import com.google.errorprone.annotations.InlineMe; import java.util.Comparator; import org.jspecify.annotations.Nullable; @GwtCompatible public abstract class ComparisonChain { private ComparisonChain() {} public static ComparisonChain start() { return ACTIVE; } private static final ComparisonChain ACTIVE = new ComparisonChain() { @SuppressWarnings("unchecked") @Override public ComparisonChain compare(Comparable<?> left, Comparable<?> right) { return classify(((Comparable<Object>) left).compareTo(right)); } @Override public <T extends @Nullable Object> ComparisonChain compare( @ParametricNullness T left, @ParametricNullness T right, Comparator<T> comparator) { return classify(comparator.compare(left, right)); } @Override public ComparisonChain compare(int left, int right) { return classify(Integer.compare(left, right)); } @Override public ComparisonChain compare(long left, long right) { return classify(Long.compare(left, right)); } @Override public ComparisonChain compare(float left, float right) { return classify(Float.compare(left, right)); } @Override public ComparisonChain compare(double left, double right) { return classify(Double.compare(left, right)); } @Override public ComparisonChain compareTrueFirst(boolean left, boolean right) { return classify(Boolean.compare(right, left)); } @Override public ComparisonChain compareFalseFirst(boolean left, boolean right) { return classify(Boolean.compare(left, right)); } ComparisonChain classify(int result) { return (result < 0) ? LESS : (result > 0) ? GREATER : ACTIVE; } @Override public int result() { return 0; } }; private static final ComparisonChain LESS = new InactiveComparisonChain(-1); private static final ComparisonChain GREATER = new InactiveComparisonChain(1); private static final class InactiveComparisonChain extends ComparisonChain { final int result; InactiveComparisonChain(int result) { this.result = result; } @Override public ComparisonChain compare(Comparable<?> left, Comparable<?> right) { return this; } @Override public <T extends @Nullable Object> ComparisonChain compare( @ParametricNullness T left, @ParametricNullness T right, Comparator<T> comparator) { return this; } @Override public ComparisonChain compare(int left, int right) { return this; } @Override public ComparisonChain compare(long left, long right) { return this; } @Override public ComparisonChain compare(float left, float right) { return this; } @Override public ComparisonChain compare(double left, double right) { return this; } @Override public ComparisonChain compareTrueFirst(boolean left, boolean right) { return this; } @Override public ComparisonChain compareFalseFirst(boolean left, boolean right) { return this; } @Override public int result() { return result; } } public abstract ComparisonChain compare(Comparable<?> left, Comparable<?> right); public abstract <T extends @Nullable Object> ComparisonChain compare( @ParametricNullness T left, @ParametricNullness T right, Comparator<T> comparator); public abstract ComparisonChain compare(int left, int right); public abstract ComparisonChain compare(long left, long right); public abstract ComparisonChain compare(float left, float right); public abstract ComparisonChain compare(double left, double right); @InlineMe(replacement = "this.compareFalseFirst(left, right)") @Deprecated public final ComparisonChain compare(Boolean left, Boolean right) { return compareFalseFirst(left, right); } public abstract ComparisonChain compareTrueFirst(boolean left, boolean right); public abstract ComparisonChain compareFalseFirst(boolean left, boolean right); public abstract int result(); }

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.4600.914−151.83
Source linesThe number of non-empty source lines.291+116.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.558−6.838

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

Score0.759

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.291+9.328
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.292−9.302
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.291−6.257
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.290.897+3.656
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.95.945−0.399
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.082+0.142

Intercept 0.07 + feature contributions = -3.565 (log-odds).
Score = sigmoid(-3.565) = 0.028.

Score0.554
Score58
Run 1

The code demonstrates good structure with clear separation between the abstract ComparisonChain and its concrete implementations. The nesting depth is minimal - only one level in the anonymous ACTIVE class and one in InactiveComparisonChain. Method names clearly express intent (compareTrueFirst, compareFalseFirst, classify). Each line performs a single action, and the reading flow is natural with logical method ordering. However, the code has issues: excessive blank lines (100+ empty lines at the top and bottom) significantly hurt readability, making the file unnecessarily long. The @SuppressWarnings('unchecked') annotation requires explanation. Some methods like the deprecated compare(Boolean, Boolean) wrapper add complexity that could be confusing. The classify method's ternary chain, while concise, could be more explicit. The abstract method declarations are well-documented with Javadoc-style comments explaining the 'chain' behavior. Overall, the code is well-organized but the excessive whitespace and some compressed logic prevent a higher score.

Run 2

The code is generally well-structured and readable. It uses a clear class hierarchy (active vs inactive comparison chains) and flat method bodies with minimal nesting. Each compare method performs a single action (delegating to a comparator or primitive comparison), and the classify method cleanly handles the ternary logic. The anonymous ACTIVE implementation and InactiveComparisonChain subclass are logical and avoid duplication where appropriate. However, readability is slightly reduced by the unusually large number of blank lines between the package/import declarations and the class definition, which disrupts the natural reading flow. Additionally, the use of anonymous inner classes and the presence of numerous overridden methods with identical return-this bodies in InactiveComparisonChain could be seen as repetitive, though this is a common pattern for such fluent APIs. Overall, the intent is clear, and the code is concise, but the formatting inconsistency and repetition prevent a higher score.

Run 3

The code follows a clear, logical structure with a well-defined class hierarchy: an abstract ComparisonChain with active and inactive implementations. Each comparison method is concise and delegates to a common classify method, flattening nesting and maintaining one action per line. This design is idiomatic and elegant for the domain. However, readability is notably reduced by large blocks of blank lines and placeholder comments (e.g., around the private constructor and before abstract methods), which break the visual flow and suggest unfinished documentation. Deep generic and annotation syntax in signatures (e.g., Comparator<T> with @Nullable) adds complexity for readers unfamiliar with Guava conventions. Still, the core logic remains straightforward and the class's intent is obvious.

Run 1

Code Structure: Active and inactive comparison states are logically separated, with consistent overload implementations. Nesting: Mostly shallow; the anonymous class and nested ternary add modest complexity. Clarity of intent: Descriptive names communicate comparison ordering and state transitions, though short-circuit behavior and reversed arguments in compareTrueFirst lack explanation. Code length: Repeated overloads are largely justified by the API, but excessive blank lines substantially inflate the listing. Action granularity: Methods generally perform one clear action per line; classify compresses three outcomes into a single expression. Reading flow: Consistent formatting within methods helps, but large whitespace gaps and placing abstract API declarations after implementations interrupt navigation.

Run 2

Code Structure: Active and inactive comparison states are logically separated, with consistently grouped overloads, although implementation details precede most public API declarations. Nesting: Generally shallow; the anonymous class and nested ternary introduce modest complexity. Clarity of intent: Descriptive method names and state constants convey comparison behavior, but missing documentation leaves short-circuit semantics and reversed arguments in compareTrueFirst less immediately obvious. Code length: Overload repetition is largely justified, but excessive blank lines substantially inflate the code and an unused import adds clutter. Action granularity: Statements generally perform one clear action per line; classify compresses multiple decisions into one expression. Reading flow: Consistent formatting within methods helps, but large whitespace gaps interrupt navigation and separate related declarations unnecessarily.

Run 3

Code Structure: Active and inactive comparison states are logically separated, with consistent overloads, though implementation precedes much of the public API. Nesting: Generally shallow; the anonymous class adds modest nesting, and the nested ternary slightly complicates classification. Clarity of intent: Descriptive names and short methods convey comparison chaining, but missing documentation makes short-circuit behavior and reversed boolean ordering less immediately obvious. Code length: Numerous overloads require repetition, while excessive blank lines unnecessarily inflate the listing. Action granularity: Statements generally perform one action per line, with compact comparison-and-classification expressions remaining understandable. Reading flow: Consistent formatting and method patterns help, but large whitespace gaps interrupt navigation, and readers must move between the active implementation, inactive implementation, and abstract declarations.