Sample

int-b6b329dcfdc9-I11

Split eligible integer literals into pairs of short-named intermediate variables

Matched original source

Lines45

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.6820–1; higher is more readable
Dorn0.7160–1; higher is more readable
Mi0.5770–1; higher is more readable
LLOC16Logical lines; fewer is more readable
DeepSeek V4 Pro17.670–20; mean of three runs
GPT-6.1 Sol18.330–20; mean of three runs
BTTF0.5310–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 java.util.Comparator; import java.util.SortedSet; import org.jspecify.annotations.Nullable; /** * Utilities for dealing with sorted collections of all types. * * @author Louis Wasserman */ @GwtCompatible final class SortedIterables { private SortedIterables() {} /** * Returns {@code true} if {@code elements} is a sorted collection using an ordering equivalent to * {@code comparator}. */ public static boolean hasSameComparator(Comparator<?> comparator, Iterable<?> elements) { checkNotNull(comparator); checkNotNull(elements); Comparator<?> comparator2; if (elements instanceof SortedSet) { comparator2 = comparator((SortedSet<?>) elements); } else if (elements instanceof SortedIterable) { comparator2 = ((SortedIterable<?>) elements).comparator(); } else { return false; } return comparator.equals(comparator2); } @SuppressWarnings("unchecked") // if sortedSet.comparator() is null, the set must be naturally ordered public static <E extends @Nullable Object> Comparator<? super E> comparator( SortedSet<E> sortedSet) { Comparator<? super E> result = sortedSet.comparator(); if (result == null) { result = (Comparator<? super E>) Ordering.natural(); } return 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.1376.306−45.418
Source linesThe number of non-empty source lines.45+18
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.703−7.054

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

Score0.682

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.100+0.809
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.46−0.592
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.99.978−0.569
Indentation frequencyHow rapidly indentation changes from line to line.37+0.543
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.44.782+0.216
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.092+0.052

Intercept 0.07 + feature contributions = 0.926 (log-odds).
Score = sigmoid(0.926) = 0.716.

Score0.577
Score16
Run 1

The code is highly readable with clear structure, flat nesting, and concise methods. The class has a well-defined single purpose: utilities for sorted collections. Each method performs one logical action per line, and the reading flow is natural. The `hasSameComparator` method uses a clear if-else chain to check different collection types before comparing comparators. Javadoc documentation explains intent precisely. The code is appropriately concise without unnecessary verbosity. Minor deductions could be made for the type cast and null-handling in the comparator method requiring a comment for clarity, but overall the code exemplifies strong readability practices.

Run 2

The code is well-structured and readable. It has a clear class purpose, logical method organization, minimal nesting (max 2 levels), and good action granularity. Method names and variable names clearly express intent. The `hasSameComparator` method uses a straightforward if-else chain for type checking, which is easy to follow. The `comparator` method is concise with a single null check. The only minor readability deduction is for the @SuppressWarnings annotation with a slightly cryptic comment about null comparators, but this is standard Guava style and necessary for generic type safety.

Run 3

The code is well-structured with clear separation of concerns and a logical organization. It has minimal nesting (only one level of if-else and a null check), making it easy to follow. Intent is immediately obvious from method names and documentation. The code is concise—no unnecessary verbosity—and each line performs a single coherent action. Reading flow is natural, with helper methods and clear return points. The only minor deduction is the unchecked cast and suppressed warning, which slightly obscures flow and requires the explanatory comment.

Run 1

Code Structure: Two focused utility methods are logically organized within a non-instantiable class. Nesting: Simple conditionals keep nesting shallow, with an early return for unsupported iterables. Clarity of intent: Method names, documentation, and the natural-ordering comment clearly explain behavior; comparator2 is slightly less descriptive than ideal. Code length: The implementation is concise without sacrificing validation or clarity. Action granularity: Each statement performs a single action, making the logic easy to follow. Reading flow: Validation, comparator extraction, and comparison proceed naturally; the helper cleanly handles the null-comparator convention. Minor formatting issues, such as the lack of spacing between the package and imports, slightly reduce polish.

Run 2

Code Structure: A focused utility class cleanly separates comparator equivalence checking from comparator retrieval. Nesting: Shallow conditionals and an early return keep control flow simple. Clarity of intent: Method names, documentation, and the natural-ordering comment explain behavior well; comparator2 is less descriptive than an alternative such as elementsComparator. Code length: Concise, with no unnecessary logic or repetition. Action granularity: Each statement performs a single clear action. Reading flow: Null checks, type inspection, comparator extraction, and comparison follow a natural sequence. Generic bounds and unchecked casts introduce minor reading overhead, and spacing between the package declaration and imports could improve visual organization.

Run 3

Code Structure: A focused utility class cleanly separates comparator matching from comparator retrieval. Nesting: Shallow conditionals and an early return keep control flow simple. Clarity of intent: Descriptive methods, documentation, and the natural-ordering comment explain behavior well; comparator2 is less informative, and the generic cast requires some Java knowledge. Code length: Concise, with no unnecessary logic or repetition. Action granularity: Each statement performs one clear action. Reading flow: Validation, type checks, comparator extraction, and comparison follow a natural sequence. Minor formatting issues, such as missing blank lines between package and import groups, slightly reduce readability.