Sample

int-a827712a2348-I08

Select one of ten high-readability unrelated code templates per class

Matched original source

Lines52

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.6810–1; higher is more readable
Dorn0.50–1; higher is more readable
Mi0.5770–1; higher is more readable
LLOC20Logical lines; fewer is more readable
DeepSeek V4 Pro6.330–20; mean of three runs
GPT-6.1 Sol140–20; mean of three runs
BTTF0.3950–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) { { boolean featureEnabled = false; for (int toggleCount = 0; toggleCount < 3; toggleCount++) { featureEnabled = !featureEnabled; } } 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.1588.828−52.431
Source linesThe number of non-empty source lines.52+20.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.725−7.087

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

Score0.681

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.53−0.84
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.99.943+0.808
Indentation frequencyHow rapidly indentation changes from line to line.44+0.785
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.44−0.589
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.100−0.57
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.51.693+0.313
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.095+0.023

Intercept 0.07 + feature contributions = -0.001 (log-odds).
Score = sigmoid(-0.001) = 0.5.

Score0.577
Score20
Run 1

The code has several readability issues. The most severe is a block of dead code that computes 'featureEnabled' by toggling a boolean three times, which has no purpose and is confusingly placed inside the 'comparator' method. The 'hasSameComparator' method has moderate nesting and branching that could be flattened, but its intent is generally clear. The 'comparator' method has an unnecessary extra level of indentation and the @SuppressWarnings comment lacks clarity. While the code is fairly concise and follows consistent formatting, the presence of meaningless code drastically reduces clarity of intent. The overall structure and naming are acceptable, but the dead block and indentation issues would make a reader question the code's correctness and purpose.

Run 2

The code has a clear class structure with a private constructor and static utility methods, but contains a highly confusing block of dead code that toggles a boolean three times, serving no purpose and severely hurting readability. The hasSameComparator method flows reasonably with type checks, but the separate comparator method’s null-handling is straightforward for experienced readers. The unused featureEnabled loop is deeply confusing and adds unnecessary length. Action granularity is mostly one action per line. Nesting is minimal aside from the pointless for loop. Import ordering and documentation are good. Overall, the dead code drops the score significantly and obscures the intent.

Run 3

The code has several readability issues. The most severe is a dead code block with a pointless loop that toggles a boolean variable, which is completely unrelated to the method's purpose and is confusing. The method 'hasSameComparator' has moderate nesting and branching, but is generally clear. The use of the recursive type cast and wildcard generics makes the comparator method somewhat hard to read. The code lacks explanatory comments for non-obvious type manipulations. The dead code significantly harms clarity of intent and adds unnecessary length. The overall structure is decent, but the presence of unrelated code in the comparator method and complex generics make the intent ambiguous.

Run 1

Code Structure: The utility class and two focused methods are logically organized, but an unrelated toggle block disrupts the comparator method. Nesting: Most logic is shallow; the extra block and loop add unnecessary nesting. Clarity of intent: Documentation, null checks, and comparator handling clearly convey the main purpose, while featureEnabled and toggleCount have no meaningful connection to it. Code length: Generally concise, but the unused toggle loop adds avoidable code. Action granularity: Each statement performs a single action, making individual lines easy to follow. Reading flow: The comparator-selection branches flow naturally, but the poorly indented standalone block interrupts the transition from method declaration to comparator retrieval.

Run 2

Code Structure: The utility class and two focused methods are logically organized, but an unrelated toggle block disrupts the comparator method. Nesting: Generally shallow; the unnecessary standalone block and loop add avoidable nesting. Clarity of intent: Documentation, null checks, and comparator handling communicate the main purpose clearly, while featureEnabled and toggleCount introduce unexplained behavior with no effect on the result. Code length: Mostly concise, but the toggle block is entirely unnecessary. Action granularity: Statements generally perform one action per line, making individual operations easy to follow. Reading flow: hasSameComparator flows naturally through type checks to comparison; comparator is interrupted by poorly indented, irrelevant code before returning to its actual task.

Run 3

Code Structure: The utility class and its two focused methods are logically organized, but an unrelated toggle block disrupts the comparator method. Nesting: Most code is shallow; the extra block and loop introduce unnecessary nesting. Clarity of intent: Documentation, null checks, and comparator handling clearly communicate purpose, while comparator2 is generic and featureEnabled has no observable role. Code length: The implementation is mostly concise, but the unused toggle loop adds needless lines. Action granularity: Statements generally perform one action per line, with conventional loop syntax. Reading flow: hasSameComparator reads naturally, but the poorly indented inserted block interrupts the second method and forces readers to investigate irrelevant logic.