Sample

int-5733caf0c23e-I01

Remove line comments, block comments, and Javadoc

Matched original source

Lines69

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.5660–1; higher is more readable
Dorn0.2160–1; higher is more readable
Mi0.3770–1; higher is more readable
LLOC25Logical lines; fewer is more readable
DeepSeek V4 Pro16.330–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.4470–1; higher is more readable

Views

Source code

package com.google.common.collect; import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.annotations.GwtCompatible; import com.google.common.annotations.GwtIncompatible; import com.google.common.annotations.J2ktIncompatible; import com.google.errorprone.annotations.concurrent.LazyInit; import java.io.Serializable; import org.jspecify.annotations.Nullable; @GwtCompatible final class NaturalOrdering extends Ordering<Comparable<?>> implements Serializable { static final NaturalOrdering INSTANCE = new NaturalOrdering(); @LazyInit private transient @Nullable Ordering<@Nullable Comparable<?>> nullsFirst; @LazyInit private transient @Nullable Ordering<@Nullable Comparable<?>> nullsLast; @Override @SuppressWarnings("unchecked") public int compare(Comparable<?> left, Comparable<?> right) { checkNotNull(left); checkNotNull(right); return ((Comparable<Object>) left).compareTo(right); } @Override @SuppressWarnings("unchecked") public <S extends Comparable<?>> Ordering<@Nullable S> nullsFirst() { Ordering<@Nullable Comparable<?>> result = nullsFirst; if (result == null) { result = nullsFirst = super.<Comparable<?>>nullsFirst(); } return (Ordering<@Nullable S>) result; } @Override @SuppressWarnings("unchecked") public <S extends Comparable<?>> Ordering<@Nullable S> nullsLast() { Ordering<@Nullable Comparable<?>> result = nullsLast; if (result == null) { result = nullsLast = super.<Comparable<?>>nullsLast(); } return (Ordering<@Nullable S>) result; } @Override @SuppressWarnings("unchecked") public <S extends Comparable<?>> Ordering<S> reverse() { return (Ordering<S>) ReverseNaturalOrdering.INSTANCE; } private Object readResolve() { return INSTANCE; } @Override public String toString() { return "Ordering.natural()"; } private NaturalOrdering() {} @GwtIncompatible @J2ktIncompatible private static final long serialVersionUID = 0; }

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.2415.477−79.711
Source linesThe number of non-empty source lines.69+27.6
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.922−7.383

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

Score0.566

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.69+1.65
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.70−1.442
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.69−1.163
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.68.779+0.552
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.12−0.22
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.84.914+0.069

Intercept 0.07 + feature contributions = -1.289 (log-odds).
Score = sigmoid(-1.289) = 0.216.

Score0.377
Score25
Run 1

The code demonstrates excellent readability through clear structure and logical organization. The class is well-defined with appropriate annotations and follows a natural reading flow from field declarations through methods. Nesting is minimal with only a simple null-check pattern in nullsFirst()/nullsLast(). Intent is clear - implementing natural ordering with lazy initialization for null-handling variants. Code length is appropriate with concise method implementations. Action granularity is well-maintained with one primary operation per line, particularly in the compare method. The use of @SuppressWarnings annotations with brief explanations maintains clarity despite the unchecked cast complexity. Field visibility and transient annotations are properly used, showing thoughtful design. The private constructor and readResolve() method correctly enforce singleton pattern. Minor improvements could include extracting the lazy initialization pattern into a helper method, but the current implementation remains highly readable with predictable structure and clear naming conventions.

Run 2

The code demonstrates strong readability with clear structure, purpose, and adherence to Java conventions. It has a logical organization with fields, then public methods, then serialization and utility methods. Nesting is minimal with only simple null-check conditionals. The intent is explicit: a singleton natural ordering implementation. Method names are descriptive, and each line performs a single action. The code is concise despite type-checking boilerplate. Minor deductions arise from the scattered @SuppressWarnings annotations and some serialization clarity concerns, but these are idiomatic for such a class. Overall, this is well-structured, maintainable code.

Run 3

The code is generally readable but has several issues. The structure is logical with clear separation of methods and consistent use of lazy initialization patterns. However, the generic type declarations with nested wildcards and unchecked cast suppressions significantly hurt readability - lines like 'Ordering<@Nullable Comparable<?>>' and the multiple @SuppressWarnings annotations create visual noise. The code repeats the nullsFirst/nullLast lazy initialization pattern verbatim, making it somewhat verbose. Action granularity is mixed - some lines contain multiple operations (assignment plus null check). Reading flow is natural with methods ordered logically, but the excessive annotations (4 different compatibility annotations) at the class level and scattered throughout reduce clarity. The private constructor placement and serialVersionUID at the bottom feel slightly disorganized. For experienced Guava developers this code would be more readable, but for general Java developers the complex generics and framework-specific annotations reduce comprehension significantly.

Run 1

Code Structure: The class is logically organized around natural comparison, null-handling variants, reversal, and singleton support. Nesting: Methods are flat, with only single-level conditionals for lazy initialization. Clarity of intent: Descriptive method and field names communicate purpose well, although generic casts and dense annotations require familiarity with Java's type system. Code length: The implementation is concise, with minor duplication between nullsFirst and nullsLast. Action granularity: Most lines perform one action, but chained assignments combine local assignment and cache updates. Reading flow: Methods follow a coherent sequence, though excessive blank lines, inconsistent whitespace, and multiple annotations on single lines slightly disrupt scanning.

Run 2

Code Structure: Clearly organized around a singleton natural ordering, with focused methods and related cache fields. Nesting: Very shallow; only the lazy initialization methods contain a single conditional. Clarity of intent: Descriptive names and familiar overrides communicate purpose well, although complex generic annotations, unchecked casts, and unexplained lazy caching require Java expertise. Code length: Concise overall; the parallel nullsFirst and nullsLast methods are reasonable duplication, but excess blank lines add clutter. Action granularity: Most lines perform one action, though chained assignments combine local assignment and cache updates, and the final field declaration packs annotations onto one line. Reading flow: Methods follow a coherent sequence, but inconsistent whitespace and dense type declarations slightly interrupt scanning.

Run 3

Code Structure: Logically organized around a singleton ordering implementation, with small, focused methods. Nesting: Very shallow; caching methods contain only one conditional level. Clarity of intent: Descriptive names and standard overrides make comparison, null handling, reversal, and singleton preservation clear, though generic casts and dense annotations require extra attention. Code length: Concise overall, with minor duplication between nullsFirst and nullsLast and unnecessary blank lines. Action granularity: Most statements perform one action, but chained assignments combine local assignment and cache updates. Reading flow: Methods follow a natural sequence and use consistent patterns; irregular whitespace and the compressed annotation/field declaration slightly disrupt scanning.