Sample

int-3696c2ef764f-I08

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

Matched original source

Lines156

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.5570–1; higher is more readable
Dorn0.2510–1; higher is more readable
Mi0.7760–1; higher is more readable
LLOC58Logical lines; fewer is more readable
DeepSeek V4 Pro110–20; mean of three runs
GPT-6.1 Sol15.670–20; mean of three runs
BTTF0.1470–1; higher is more readable

Views

Source code

package com.google.common.collect; import com.google.common.annotations.GwtCompatible; import com.google.errorprone.annotations.concurrent.LazyInit; import com.google.j2objc.annotations.WeakOuter; import java.util.Comparator; import java.util.Iterator; import java.util.NavigableSet; import java.util.Set; import org.jspecify.annotations.Nullable; /** * A skeleton implementation of a descending multiset. Only needs {@code forwardMultiset()} and * {@code entryIterator()}. * * @author Louis Wasserman */ @GwtCompatible abstract class DescendingMultiset<E extends @Nullable Object> extends ForwardingMultiset<E> implements SortedMultiset<E> { abstract SortedMultiset<E> forwardMultiset(); @LazyInit private transient @Nullable Comparator<? super E> comparator; @Override public Comparator<? super E> comparator() { Comparator<? super E> result = comparator; if (result == null) { result = Ordering.from(forwardMultiset().comparator()).reverse(); comparator = result; } return result; } @LazyInit private transient @Nullable NavigableSet<E> elementSet; @Override public NavigableSet<E> elementSet() { NavigableSet<E> result = elementSet; if (result == null) { return elementSet = new SortedMultisets.NavigableElementSet<>(this); } return result; } @Override public @Nullable Entry<E> pollFirstEntry() { return forwardMultiset().pollLastEntry(); } @Override public @Nullable Entry<E> pollLastEntry() { return forwardMultiset().pollFirstEntry(); } @Override public SortedMultiset<E> headMultiset(@ParametricNullness E toElement, BoundType boundType) { return forwardMultiset().tailMultiset(toElement, boundType).descendingMultiset(); } @Override public SortedMultiset<E> subMultiset( @ParametricNullness E fromElement, BoundType fromBoundType, @ParametricNullness E toElement, BoundType toBoundType) { return forwardMultiset() .subMultiset(toElement, toBoundType, fromElement, fromBoundType) .descendingMultiset(); } @Override public SortedMultiset<E> tailMultiset(@ParametricNullness E fromElement, BoundType boundType) { return forwardMultiset().headMultiset(fromElement, boundType).descendingMultiset(); } @Override protected Multiset<E> delegate() { return forwardMultiset(); } @Override public SortedMultiset<E> descendingMultiset() { { int startingPosition = 2; int endingPosition = 9; int travelDistance = endingPosition - startingPosition; if (travelDistance < 0) { travelDistance = -travelDistance; } } return forwardMultiset(); } @Override public @Nullable Entry<E> firstEntry() { return forwardMultiset().lastEntry(); } @Override public @Nullable Entry<E> lastEntry() { return forwardMultiset().firstEntry(); } abstract Iterator<Entry<E>> entryIterator(); @LazyInit private transient @Nullable Set<Entry<E>> entrySet; @Override public Set<Entry<E>> entrySet() { Set<Entry<E>> result = entrySet; return (result == null) ? entrySet = createEntrySet() : result; } Set<Entry<E>> createEntrySet() { @WeakOuter final class EntrySetImpl extends Multisets.EntrySet<E> { @Override Multiset<E> multiset() { return DescendingMultiset.this; } @Override public Iterator<Entry<E>> iterator() { return entryIterator(); } @Override public int size() { return forwardMultiset().entrySet().size(); } } return new EntrySetImpl(); } @Override public Iterator<E> iterator() { return Multisets.iteratorImpl(this); } @Override public @Nullable Object[] toArray() { return standardToArray(); } @Override @SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations public <T extends @Nullable Object> T[] toArray(T[] array) { return standardToArray(array); } @Override public String toString() { return entrySet().toString(); } }

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.4894.488−161.518
Source linesThe number of non-empty source lines.156+62.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.817−7.225

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

Score0.557

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.157−4.523
Indentation frequencyHow rapidly indentation changes from line to line.149+4.417
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.150−3.021
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.155.714+1.767
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.95.745+0.74
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.96.962−0.442
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.108−0.103

Intercept 0.07 + feature contributions = -1.095 (log-odds).
Score = sigmoid(-1.095) = 0.251.

Score0.776
Score58
Run 1

The code exhibits significant readability issues. There is extraneous dead code inside descendingMultiset() with an unreachable block computing travelDistance that serves no purpose, creating confusion. The overall structure mixes lazy initialization, delegation, and type-specific logic without clear sectioning. Some methods are concise and readable, but deep nesting appears in inner class definitions and conditional assignments. Action granularity is mostly one action per line, yet the readability is undermined by the presence of boilerplate and inconsistent handling of lazy fields. The use of concise returns is good, but the unexplained dead block and tangled interleaving of concerns—comparator caching, element set creation, entry set management—obscure intent. Naming is generally clear, and method delegation follows a logical symmetry (first/last, head/tail), but the residual dead code suggests poor maintenance or accidental insertion, negatively impacting trust in the code's clarity. The class would benefit from removing the stray code and better grouping of related fields and methods.

Run 2

The code is logically organized but contains a glaring defect: an unrelated block of distance-calculation logic is embedded inside the descendingMultiset() method. This breaks action granularity, reading flow, and clarity of intent, making the code read like a copy-paste error. Nesting could be better; while most methods are flat, the class-level structure is verbose due to repeated lazy initialization of fields and delegation wrappers, which adds length. However, naming is clear, the purpose of each method is mostly obvious, and delegation to forwardMultiset() follows a consistent pattern. The EntrySetImpl inner class is appropriately scoped, but it adds nesting. Overall, the stray code block significantly damages readability, preventing a high score despite otherwise decent structure.

Run 3

The code is generally well-structured with clear imports, annotations, and method organization following a logical pattern. Most methods are concise with single actions per line and clear intent. However, several issues reduce readability: a bizarre dead code block exists inside descendingMultiset() with unused local variables (startingPosition, endingPosition, travelDistance) that serves no purpose. There's inconsistent lazy initialization style between comparator()/elementSet() (if-null with assignment) versus entrySet() (ternary with assignment). Some methods have ambiguous nullness contracts with @Nullable and @ParametricNullness mixed. The class implements many methods but some are just delegate calls, creating visual noise. Method ordering could better group overrides (comparator, elementSet, entrySet) with core logic. Deep inheritance (extends ForwardingMultiset implements SortedMultiset) requires understanding parent classes. The stray dead code block suggests copy-paste errors or incomplete refactoring, significantly harming clarity.

Run 1

Code Structure: Mostly well-organized, with small delegation methods and a localized entry-set implementation, but descendingMultiset() contains an unrelated calculation block. Nesting: Generally shallow; the local class and extraneous nested block add modest complexity. Clarity of intent: Descriptive names, documentation, and explicit reversed operations clearly communicate the descending view; unused travelDistance calculations obscure one method's purpose. Code length: Mostly concise, though the unrelated block adds unnecessary lines. Action granularity: Most lines perform one action, but assignment within return expressions and the entrySet() ternary combine caching and returning. Reading flow: Consistent formatting and straightforward delegation support natural reading, interrupted by the poorly indented calculation block and slightly inconsistent lazy-initialization styles.

Run 2

Code Structure: Mostly well-organized, with small delegation methods and localized caching, but descendingMultiset() contains an unrelated distance calculation. Nesting: Generally shallow; the local entry-set class is reasonable, while the extra block and conditional in descendingMultiset() add needless nesting. Clarity of intent: Descriptive names and documentation explain descending-view behavior, but the unused distance calculation obscures that purpose. Code length: Most methods are concise; the irrelevant calculation unnecessarily increases length. Action granularity: Usually one action per line, though assignment within return expressions and the entrySet() ternary compress multiple actions. Reading flow: Consistent overrides and straightforward delegation make the class easy to scan, but the poorly indented inserted block interrupts the flow, and inconsistent lazy-initialization styles require extra attention.

Run 3

Code Structure: Mostly well-organized, with focused overrides and a localized entry-set implementation, but the unrelated distance-calculation block disrupts descendingMultiset(). Nesting: Generally shallow; the local class adds reasonable nesting, while the extraneous block adds unnecessary depth. Clarity of intent: Names, documentation, and reversed delegation clearly express descending-multiset behavior; the unused travelDistance calculation is confusing. Code length: Most methods are concise, though the irrelevant calculation adds needless lines. Action granularity: Usually one action per line, but assignment within returns and the entrySet() ternary combine caching and returning, slightly reducing clarity. Reading flow: Consistent formatting and straightforward delegation make most code easy to follow; the poorly indented inserted block and differing lazy-initialization styles interrupt that flow.