Sample

int-41232237b58c-I11

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

Matched original source

Lines147

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.5660–1; higher is more readable
Dorn0.9030–1; higher is more readable
Mi0.7760–1; higher is more readable
LLOC53Logical lines; fewer is more readable
DeepSeek V4 Pro17.330–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.4480–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() { 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.4612.687−152.219
Source linesThe number of non-empty source lines.147+58.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.812−7.218

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

Score0.566

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.148−4.204
Indentation frequencyHow rapidly indentation changes from line to line.141+4.14
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.146.673+1.64
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.95.676+0.739
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.919−0.44
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.108−0.109

Intercept 0.07 + feature contributions = 2.235 (log-odds).
Score = sigmoid(2.235) = 0.903.

Score0.776
Score53
Run 1

This code is highly readable. The class has a clear single responsibility: providing a descending view of a multiset. The structure is logical, with methods grouped by concern and following the `SortedMultiset` contract. Nesting is minimal; the only inner class is justified for the entry set and has a clear purpose. Intent is evident from method names like `descendingMultiset()` and comments explaining deferred initialization. Code length is appropriate for the functionality, avoiding unnecessary boilerplate through delegation to `forwardMultiset()`. Each method performs one logical action, adhering to good action granularity. The reading flow is natural: constructors, comparator, element set, then mutating/derivative views. Layering with lazy initialization fields (`@LazyInit`) is a standard pattern here and does not obscure logic. Overall, only minor verbose annotations slightly reduce readability, but structure and clarity are excellent.

Run 2

The code is well-structured and follows clear patterns for a descending multiset implementation. The class has a single responsibility and methods are logically organized. Nesting is minimal; the only inner class is isolated in a factory method. Intent is clear through descriptive method names and concise Javadoc. Action granularity is appropriate, with one operation per line in most cases. Reading flow is natural, with related methods grouped together. The lazy initialization pattern is consistent and readable, though it does add some repetitive boilerplate. The main readability challenges are the complex generic type signatures and nullness annotations, which are necessary for Guava's type safety requirements but can obscure the underlying logic for developers unfamiliar with these patterns.

Run 3

The code is highly readable with clear structure and logical organization. The class has a single responsibility (descending multiset wrapper) and methods are concise, each performing one action. Nesting is minimal, with only one inner class that is short and focused. Intent is evident from method names and the class-level Javadoc. The use of lazy initialization for comparator, elementSet, and entrySet is consistent and well-patterned. Method chains like forwardMultiset().tailMultiset(...).descendingMultiset() remain readable due to sensible line breaks. The only minor deductions are for some one-line returns mixing assignment and return (e.g., return elementSet = new SortedMultisets.NavigableElementSet<>(this);) which slightly reduces clarity, and annotations like @ParametricNullness and @SuppressWarnings add visual noise but are necessary for nullness checking.

Run 1

Code Structure: Well-organized forwarding implementation with small, focused methods and cached fields near their accessors. Nesting: Mostly flat; lazy initialization adds minimal branching, while the local entry-set class introduces modest nesting. Clarity of intent: Descriptive method names and the class documentation clearly explain the descending view; reversed delegation consistently expresses its behavior. Code length: Concise for the interface implemented, with little unnecessary logic, although numerous overrides add unavoidable repetition. Action granularity: Most lines perform one action; assignment within return expressions and the entrySet ternary combine caching and returning, slightly reducing clarity. Reading flow: Consistent formatting and straightforward delegation make the code easy to scan, though differing lazy-initialization styles and interspersed fields mildly interrupt uniformity.

Run 2

Code Structure: Well-organized implementation with small methods and localized cached views, though grouping all reversed operations together would improve organization. Nesting: Minimal; only simple null checks and a small local class introduce nesting. Clarity of intent: Descriptive method names, documentation, and explicit first/last and head/tail reversals clearly convey the descending-view purpose. Generic types and annotations add some visual complexity. Code length: Concise for the functionality, with little unnecessary logic; most methods directly delegate. Action granularity: Generally 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 the code easy to follow, although inconsistent lazy-initialization styles and interspersed fields mildly interrupt the flow.

Run 3

Code Structure: Well-organized overrides and a localized entry-set implementation clearly support the descending-view abstraction. Nesting: Mostly flat, with only shallow cache checks and a small local class. Clarity of intent: Descriptive names, documentation, and explicit first/last and head/tail reversals make behavior clear; annotations and library-specific helpers require some background knowledge. Code length: Concise delegation methods avoid unnecessary logic, although repeated override boilerplate adds length. Action granularity: Most statements perform one action; assignment within returns and the entrySet ternary combine caching and returning, slightly reducing readability. Reading flow: Consistent formatting and short methods support easy scanning, but related reversal methods could be grouped more closely, and lazy initialization uses inconsistent styles.