Sample

int-7753dd57426c-I12

Inline all eligible single-use intermediate local variables

Matched original source

Lines88

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.630–1; higher is more readable
Dorn0.4490–1; higher is more readable
Mi0.1120–1; higher is more readable
LLOC18Logical lines; fewer is more readable
DeepSeek V4 Pro170–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.450–1; higher is more readable

Views

Source code

package com.google.common.collect; import com.google.common.annotations.GwtCompatible; import com.google.common.annotations.GwtIncompatible; import com.google.common.annotations.J2ktIncompatible; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.LinkedHashMap; import org.jspecify.annotations.Nullable; /** * A {@code Multiset} implementation with predictable iteration order. Its iterator orders elements * according to when the first occurrence of the element was added. When the multiset contains * multiple instances of an element, those instances are consecutive in the iteration order. If all * occurrences of an element are removed, after which that element is added to the multiset, the * element will appear at the end of the iteration. * * <p>See the Guava User Guide article on <a href= * "https://github.com/google/guava/wiki/NewCollectionTypesExplained#multiset">{@code Multiset}</a>. * * @author Kevin Bourrillion * @author Jared Levy * @since 2.0 */ @GwtCompatible public final class LinkedHashMultiset<E extends @Nullable Object> extends AbstractMapBasedMultiset<E> { /** Creates a new, empty {@code LinkedHashMultiset} using the default initial capacity. */ public static <E extends @Nullable Object> LinkedHashMultiset<E> create() { return new LinkedHashMultiset<>(); } /** * Creates a new, empty {@code LinkedHashMultiset} with the specified expected number of distinct * elements. * * @param distinctElements the expected number of distinct elements * @throws IllegalArgumentException if {@code distinctElements} is negative */ public static <E extends @Nullable Object> LinkedHashMultiset<E> create(int distinctElements) { return new LinkedHashMultiset<>(distinctElements); } /** * Creates a new {@code LinkedHashMultiset} containing the specified elements. * * <p>This implementation is highly efficient when {@code elements} is itself a {@link Multiset}. * * @param elements the elements that the multiset should contain */ public static <E extends @Nullable Object> LinkedHashMultiset<E> create( Iterable<? extends E> elements) { LinkedHashMultiset<E> multiset = create(Multisets.inferDistinctElements(elements)); Iterables.addAll(multiset, elements); return multiset; } private LinkedHashMultiset() { super(new LinkedHashMap<E, Count>()); } private LinkedHashMultiset(int distinctElements) { super(Maps.newLinkedHashMapWithExpectedSize(distinctElements)); } /** * @serialData the number of distinct elements, the first element, its count, the second element, * its count, and so on */ @GwtIncompatible @J2ktIncompatible private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); Serialization.writeMultiset(this, stream); } @GwtIncompatible @J2ktIncompatible private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); setBackingMap(new LinkedHashMap<E, Count>()); Serialization.populateMultiset(this, stream, (stream.readInt())); } @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.2036.701−67.211
Source linesThe number of non-empty source lines.88+35.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.816−7.224

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

Score0.63

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.89−2.115
Indentation frequencyHow rapidly indentation changes from line to line.60+1.338
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.60−0.956
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.87.911+0.819
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.97.742+0.773
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.966−0.569
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.052+0.434

Intercept 0.07 + feature contributions = -0.206 (log-odds).
Score = sigmoid(-0.206) = 0.449.

Score0.112
Score18
Run 1

The code is highly readable. It follows a clear, logical structure: class-level Javadoc, factory methods, constructors, serialization methods, and constants. Intents are explicit through descriptive method names and complete Javadoc comments. The class is concise, with no redundant code. Action granularity is well-managed, with one primary action per line in core methods. Nesting is minimal and controlled. Reading flow is natural, moving from public API to internal details. Minor deductions: the blank line inside readObject slightly disrupts flow, and the serialization methods rely on external context for meaning, but overall it exemplifies clean, maintainable code.

Run 2

The code is well-structured, with clear separation of factory methods, constructors, and serialization logic. Nesting is minimal, and intent is evident from descriptive method and parameter names. Javadoc comments explain purpose and behavior. Action granularity is mostly one action per line, though serialization methods mix stream operations with collection manipulation. Reading flow is natural, following a logical progression from public API to internal implementation. Minor issues include inconsistent indentation on @GwtIncompatible annotations and a slightly compressed serialVersionUID declaration, but these do not significantly hinder readability. Overall, the code is concise for a collection implementation and adheres to clean coding conventions.

Run 3

The code is generally well-structured and readable. The class-level Javadoc clearly explains behavior, and factory methods are neatly separated with their own documentation. The three `create` overloads read naturally, showing logical progression from empty to sized to iterable. Nesting is minimal, and most lines express a single action. The main readability issue is the inconsistent indentation of `writeObject` and `readObject`: the annotations at lines 82-83 and 91-92 are over-indented relative to the access modifier, creating visual disorientation. Additionally, the mixed-generation serialization logic places a field definition after methods, which slightly disrupts reading flow. Overall, the code is concise, uses descriptive method names, and follows Guava style conventions closely, but minor formatting inconsistencies prevent a higher score.

Run 1

Code Structure: Factory methods, constructors, and serialization methods are logically grouped. Nesting: Methods are flat, with no nested control flow. Clarity of intent: Descriptive names and helpful Javadoc clearly explain creation and iteration behavior, although serialization details depend on external helpers. Code length: Implementations are concise; documentation adds useful context rather than unnecessary verbosity. Action granularity: Each executable statement performs a focused action on its own line. Reading flow: Organization is natural and consistent overall, but extra indentation on serialization method declarations, compressed annotations on serialVersionUID, unnecessary parentheses around stream.readInt(), and stray whitespace slightly disrupt presentation.

Run 2

Code Structure: Factory methods, constructors, and serialization hooks are logically grouped. Nesting: Methods are flat, with no nested control flow. Clarity of intent: Descriptive names and useful Javadoc clearly explain creation options and iteration behavior, though some implementation details depend on inherited methods and helpers. Code length: The implementation is concise; documentation adds useful context rather than unnecessary bulk. Action granularity: Statements generally perform one action per line, although the final line combines annotations and a field declaration. Reading flow: Method ordering and consistent naming make the code easy to follow. Minor formatting issues—overindented serialization method declarations, missing spacing after the package declaration, and redundant parentheses around stream.readInt()—slightly reduce polish and readability.

Run 3

Code Structure: Factories, constructors, and serialization methods are logically grouped with clear responsibilities. Nesting: Methods are flat, with no nested control flow. Clarity of intent: Descriptive names and useful Javadoc clearly explain behavior, although inherited functionality and serialization helpers require external context. Code length: The implementation is concise; documentation adds useful context rather than unnecessary bulk. Action granularity: Executable statements generally perform one action per line, though the final declaration compresses annotations and a field onto one line. Reading flow: Organization is natural and consistent overall. Minor distractions include misindented serialization method declarations, missing spacing after the package declaration, and redundant parentheses around stream.readInt().