Sample

int-64831abb5951-I08

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

Matched original source

Lines113

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.5460–1; higher is more readable
Dorn0.3410–1; higher is more readable
Mi0.4190–1; higher is more readable
LLOC37Logical lines; fewer is more readable
DeepSeek V4 Pro8.670–20; mean of three runs
GPT-6.1 Sol150–20; mean of three runs
BTTF0.340–1; higher is more readable

Views

Source code

package com.google.common.collect; import static com.google.common.collect.Sets.unmodifiableNavigableSet; import com.google.common.annotations.GwtCompatible; import com.google.common.annotations.GwtIncompatible; import com.google.common.annotations.J2ktIncompatible; import com.google.common.collect.Multisets.UnmodifiableMultiset; import com.google.errorprone.annotations.concurrent.LazyInit; import java.util.Comparator; import java.util.NavigableSet; import org.jspecify.annotations.Nullable; /** * Implementation of {@link Multisets#unmodifiableSortedMultiset(SortedMultiset)}, split out into * its own file so it can be GWT emulated (to deal with the differing elementSet() types in GWT and * non-GWT). * * @author Louis Wasserman */ @GwtCompatible final class UnmodifiableSortedMultiset<E extends @Nullable Object> extends UnmodifiableMultiset<E> implements SortedMultiset<E> { UnmodifiableSortedMultiset(SortedMultiset<E> delegate) { super(delegate); { int morningTemperature = 18; int eveningTemperature = 14; int lowerTemperature = morningTemperature; if (eveningTemperature < lowerTemperature) { lowerTemperature = eveningTemperature; } } } @Override protected SortedMultiset<E> delegate() { return (SortedMultiset<E>) super.delegate(); } @Override public Comparator<? super E> comparator() { return delegate().comparator(); } @Override NavigableSet<E> createElementSet() { return unmodifiableNavigableSet(delegate().elementSet()); } @Override public NavigableSet<E> elementSet() { return (NavigableSet<E>) super.elementSet(); } @LazyInit private transient @Nullable UnmodifiableSortedMultiset<E> descendingMultiset; // TODO(b/418181860): This method creates retain cycles in J2ObjC. In order to break the cycle, // there needs to be separate classes for primary and descending multiset, where the primary one // would hold {@code @LazyInit @RetainedWith @Nullable} reference to its descending multiset, and // the other {@code final} reference. @Override public SortedMultiset<E> descendingMultiset() { UnmodifiableSortedMultiset<E> result = descendingMultiset; if (result == null) { result = new UnmodifiableSortedMultiset<>(delegate().descendingMultiset()); result.descendingMultiset = this; return descendingMultiset = result; } return result; } @Override public @Nullable Entry<E> firstEntry() { return delegate().firstEntry(); } @Override public @Nullable Entry<E> lastEntry() { return delegate().lastEntry(); } @Override public @Nullable Entry<E> pollFirstEntry() { throw new UnsupportedOperationException(); } @Override public @Nullable Entry<E> pollLastEntry() { throw new UnsupportedOperationException(); } @Override public SortedMultiset<E> headMultiset(@ParametricNullness E upperBound, BoundType boundType) { return Multisets.unmodifiableSortedMultiset(delegate().headMultiset(upperBound, boundType)); } @Override public SortedMultiset<E> subMultiset( @ParametricNullness E lowerBound, BoundType lowerBoundType, @ParametricNullness E upperBound, BoundType upperBoundType) { return Multisets.unmodifiableSortedMultiset( delegate().subMultiset(lowerBound, lowerBoundType, upperBound, upperBoundType)); } @Override public SortedMultiset<E> tailMultiset(@ParametricNullness E lowerBound, BoundType boundType) { return Multisets.unmodifiableSortedMultiset(delegate().tailMultiset(lowerBound, boundType)); } @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.3438.614−113.474
Source linesThe number of non-empty source lines.113+45.2
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.87−7.305

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

Score0.546

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.114−3
Indentation frequencyHow rapidly indentation changes from line to line.103+2.826
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.103−1.943
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.112.8+1.167
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.87.772+0.612
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.98.956−0.526
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.083+0.134

Intercept 0.07 + feature contributions = -0.66 (log-odds).
Score = sigmoid(-0.66) = 0.341.

Score0.419
Score37
Run 1

The code is largely well-structured, with clear method overrides and delegation patterns. However, it contains a severe readability issue: an unrelated block of code (temperature variables) is erroneously inserted inside the constructor, breaking both logic and flow. This disrupts the natural reading order and creates confusion. The remaining methods follow a flat structure with minimal nesting and clear intent, but the extraneous block severely impacts clarity, action granularity, and overall coherence. The class also uses some vertical space for parameter alignment in subMultiset, which is acceptable. Overall, while the surrounding code is readable, the misplaced temperature logic makes it appear tangled and ambiguous, leading to a low score.

Run 2

The code has clear structure and logical organization for a Guava collection wrapper, with consistent delegation patterns and readable method names. However, a glaring issue severely impacts clarity: a stray block of unrelated variable declarations (morningTemperature, eveningTemperature) is embedded inside the constructor body, breaking the reader's flow and introducing confusion. Nesting is otherwise flat, and most methods are concise and single-purpose. The descendingMultiset() method introduces some complexity with its lazy initialization and cycle handling, but it is still reasonably written. The TODO comment is helpful but lengthy. Overall, readability is above average, but the accidental code block and the inherent boilerplate of wrapper classes keep it from being highly readable.

Run 3

The code has a severe readability flaw: an unrelated, unreachable block of code (`int morningTemperature...`) is inserted inside the constructor, making it syntactically invalid and completely disrupting logical organization and reading flow. Beyond that critical issue, the rest of the class is reasonably structured with clear method names and one primary action per line. Nesting is minimal (only one if-statement in the injected block), and intent is generally clear for the multiset wrapper. However, the invalid code block destroys clarity, introduces multiple actions per line within the constructor, and makes the overall structure tangled. The class itself would be moderately readable without the injected block, but as written it is unreadable/non-compilable.

Run 1

Code Structure: The class is logically organized around delegation and unmodifiable views, but the unrelated temperature-calculation block disrupts the constructor. Nesting: Most methods are flat; the constructor adds an unnecessary block and conditional, while lazy initialization uses shallow nesting. Clarity of intent: Naming, overrides, and documentation clearly convey the wrapper's purpose, but the unused temperature calculation is unexplained and distracting. Code length: Delegating methods are concise; the temperature block adds unnecessary length. Action granularity: Most statements perform one action per line, although returning an assignment in descendingMultiset combines caching and returning. Reading flow: Consistent method formatting and straightforward delegation support natural reading, but the constructor block's inconsistent indentation and the field declaration between methods interrupt the flow.

Run 2

Code Structure: The wrapper class is logically organized into small delegation methods, but the unrelated temperature-calculation block disrupts the constructor. Nesting: Most methods are flat; the constructor adds an unnecessary block and conditional, while lazy initialization uses only one conditional. Clarity of intent: Naming, documentation, and explicit unsupported operations clearly communicate an unmodifiable multiset wrapper; the unused temperature calculation has no apparent purpose. Code length: Most methods are concise, though the irrelevant constructor code adds needless length. Action granularity: Statements generally perform one action per line, but returning an assignment in descendingMultiset combines caching and returning. Reading flow: Consistent overrides and straightforward delegation support natural reading, but the poorly indented constructor block, densely grouped annotations, and mid-class field declaration interrupt it.

Run 3

Code Structure: The wrapper is logically organized into short delegation methods, but an unrelated temperature-calculation block disrupts the constructor. Nesting: Most methods are flat; the constructor adds unnecessary block and conditional nesting. Clarity of intent: Naming, documentation, and explicit exceptions clearly communicate an unmodifiable sorted multiset, while the unused temperature calculation has no apparent purpose. Code length: Delegation methods are appropriately concise, but the irrelevant constructor code adds avoidable length. Action granularity: Most lines perform one action; returning an assignment in descendingMultiset combines caching and returning, slightly reducing clarity. Reading flow: Consistent method formatting and grouping generally support scanning, but the poorly indented constructor block and densely placed annotations interrupt the flow.