Sample

int-160c8d2dea0c-I10

Remove about 40% of line-break groups while retaining structure

Matched original source

Lines49

Scores

MethodScoreScale
Posnett0.9450–1; higher is more readable
Scalabrino0.9290–1; higher is more readable
Dorn0.6430–1; higher is more readable
Mi0.0770–1; higher is more readable
LLOC3Logical lines; fewer is more readable
DeepSeek V4 Pro16.330–20; mean of three runs
GPT-6.1 Sol160–20; mean of three runs
BTTF0.6450–1; higher is more readable

Views

Source code

package com.google.common.collect; import com.google.common.annotations.GwtCompatible; import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.errorprone.annotations.DoNotMock; import java.util.Iterator; import java.util.NoSuchElementException; import org.jspecify.annotations.Nullable; /** * An iterator that supports a one-element lookahead while iterating. * * <p>See the Guava User Guide article on <a href= * "https://github.com/google/guava/wiki/CollectionHelpersExplained#peekingiterator">{@code * PeekingIterator}</a>. * * @author Mick Killianey * @since 2.0 */ @DoNotMock("Use Iterators.peekingIterator") @GwtCompatible public interface PeekingIterator<E extends @Nullable Object> extends Iterator<E> { /** * Returns the next element in the iteration, without advancing the iteration. * * <p>Calls to {@code peek()} should not change the state of the iteration, except that it * <i>may</i> prevent removal of the most recent element via {@link #remove()}. * * @throws NoSuchElementException if the iteration has no more elements according to {@link * #hasNext()} */ @ParametricNullness E peek(); /** * {@inheritDoc} * * <p>The objects returned by consecutive calls to {@link #peek()} then {@link #next()} are * guaranteed to be equal to each other. */ @CanIgnoreReturnValue @Override @ParametricNullness E next(); /** * {@inheritDoc} * * <p>Implementations may or may not support removal when a call to {@link #peek()} has occurred * since the most recent call to {@link #next()}. * * @throws IllegalStateException if there has been a call to {@link #peek()} since the most recent * call to {@link #next()} and this implementation does not support this sequence of calls * (optional) */ @Override void remove(); }

Loading feature diagnosis…

Source regions

Feature contributions

Feature contributions

FeatureValueContribution
(log-odds)
Source linesThe number of non-empty source lines.49+19.6
Halstead volumeHow much symbolic information the code contains. It combines the total number of operators and values with the number of distinct ones.560.253−18.488
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.759−7.139

Intercept 8.87 + feature contributions = 2.842 (log-odds).
Score = sigmoid(2.842) = 0.945.

Score0.929

Feature contributions

FeatureValueContribution
(log-odds)
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.108.92−0.948
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.106.82+0.919
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.48−0.663
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.029+0.656
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.48.845+0.273
Indentation frequencyHow rapidly indentation changes from line to line.18−0.115

Intercept 0.07 + feature contributions = 0.59 (log-odds).
Score = sigmoid(0.59) = 0.643.

Score0.077
Score3
Run 1

The code is generally well-structured with clear documentation and logical organization. The interface is concise and purposeful, with good use of annotations and Javadoc. However, there are some readability issues: multiple import statements are compressed onto single lines, and class-level annotations are appended to the end of the Javadoc block rather than on separate lines. The closing brace shares a line with the final method, which slightly disrupts the reading flow. The method declarations are appropriately flat with no nesting, and each action is clearly separated. The Javadoc is thorough but well-formatted. Overall, the code is readable but would benefit from more consistent line breaks and formatting, particularly around imports and annotations.

Run 2

The code is highly readable overall. Structure is logical with clear separation between interface declaration, annotations, and method definitions. Javadoc is thorough and well-formatted, adding significant clarity. Nesting is essentially flat — the interface has no nested blocks. Intent is unambiguous: a peeking iterator with clear behavioral contracts. Action granularity is mostly one action per line, though a few lines combine annotations (e.g., '@Override void remove();' and the interface-level annotations). Reading flow is natural: imports, documentation, declaration, then methods. Minor deductions: multiple imports on one line (admittedly common in Java), some annotation stacking on single lines, and the class-level annotations placed after the Javadoc slightly disrupt visual separation. Overall, excellent clarity and organization.

Run 3

The code is generally well-structured and readable: clear interface definition, good use of Javadoc, and natural method ordering (peek, next, remove). However, readability is negatively impacted by inconsistent formatting in the imports section (multiple imports on one line) and annotations placed on the same line as declarations rather than on separate lines. The Javadoc is comprehensive and clarifies intent, but the method signature annotations are cramped on a single line, reducing scanability. Nesting is minimal and clarity of intent is strong; the main issues are typographic spacing and line-break consistency, which slightly disrupt natural reading flow.

Run 1

1. Code Structure: The interface logically groups three related iterator methods, with documentation attached to each. 2. Nesting: No nested control flow; the interface is flat and easy to scan. 3. Clarity of intent: Descriptive names and detailed Javadoc clearly explain lookahead behavior and removal constraints. 4. Code length: Concise declarations; documentation adds useful contract details rather than unnecessary bulk. 5. Action granularity: Multiple imports on one line and annotations, declarations, and the closing brace sharing lines reduce visual separation. 6. Reading flow: Method order is natural, but compressed formatting around the interface annotations and remove() interrupts an otherwise clean reading flow.

Run 2

Code Structure: The interface is logically organized into peek, next, and remove declarations, each with relevant documentation. Nesting: There is no deep nesting or complex control flow. Clarity of intent: Descriptive names and detailed contracts clearly explain lookahead behavior and removal restrictions. Code length: The interface is concise; its documentation is substantial but useful rather than unnecessarily long. Action granularity: Several imports share one line, and some annotations, declarations, and closing braces are compressed together, reducing scanability. Reading flow: Method ordering is natural, but inconsistent formatting, annotations appended to documentation endings, and the final inline closing brace interrupt an otherwise clear presentation.

Run 3

Code Structure: The interface is logically organized around peek(), next(), and remove(), with relevant documentation grouped with each method. Nesting: There is no deep nesting, making the code easy to scan. Clarity of intent: Descriptive method names and precise Javadoc clearly explain lookahead behavior and removal constraints. Code length: The interface is concise; its documentation is longer than the declarations but provides useful contract details. Action granularity: Multiple imports on one line and annotations, declarations, and closing braces compressed together reduce readability. Reading flow: Method ordering is natural, but inconsistent line breaks and annotations appended to comment endings interrupt the otherwise clear flow.