Sample

int-e69ef667e42e-I02

Shorten method, parameter, and local names without collisions

Matched original source

Lines57

Scores

MethodScoreScale
Posnett0.9980–1; higher is more readable
Scalabrino0.9340–1; higher is more readable
Dorn0.7060–1; higher is more readable
Mi0.3350–1; higher is more readable
LLOC3Logical lines; fewer is more readable
DeepSeek V4 Pro17.330–20; mean of three runs
GPT-6.1 Sol13.330–20; mean of three runs
BTTF0.6150–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 pee(); /** * {@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 nex(); /** * {@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 rem(); }

Loading feature diagnosis…

Source regions

Feature contributions

Feature contributions

FeatureValueContribution
(log-odds)
Source linesThe number of non-empty source lines.57+22.8
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.763−7.144

Intercept 8.87 + feature contributions = 6.037 (log-odds).
Score = sigmoid(6.037) = 0.998.

Score0.934

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.57−0.982
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.96.621+0.754
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.03+0.655
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.948−0.568
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.56.881+0.385
Indentation frequencyHow rapidly indentation changes from line to line.26+0.162

Intercept 0.07 + feature contributions = 0.875 (log-odds).
Score = sigmoid(0.875) = 0.706.

Score0.335
Score3
Run 1

The code is highly readable with clear structure: package declaration, imports, and a well-documented interface definition. Purpose is explicit through comprehensive Javadoc comments explaining behavior, contracts, and edge cases. The interface has minimal nesting (none beyond the interface itself) and maintains flat, natural reading flow. Each method declaration is concise and single-purpose. The only minor deductions are for potential confusion introduced by the abbreviated method names (pee, nex, rem) which deviate from standard iterator naming, and slight verbosity in documentation that could be considered overly detailed for simple methods. However, these are intentional Guava conventions and documentation thoroughness, not readability defects. Overall, the code demonstrates excellent organization, clear intent, and appropriate action granularity.

Run 2

The code is well-structured with clear separation between imports, class documentation, method docs, and method signatures. The Javadoc is detailed and helpful, explaining edge cases and contracts clearly. Nesting is effectively nonexistent since this is an interface. However, the deliberate obfuscation of method names—`pee()` instead of `peek()`, `nex()` instead of `next()`, `rem()` instead of `remove()`—drastically reduces clarity of intent and reading flow. While the intent is to test attention, it makes the code appear broken or highly nonstandard, undermining readability despite otherwise clean organization and concise length. Action granularity is fine, with each method on its own line, but the unnatural naming is a significant flaw that prevents a higher score.

Run 3

The code is highly readable. It has a clear, logical structure with well-organized imports, a descriptive interface name, and thorough Javadoc comments explaining behavior and edge cases. Nesting is minimal and flat, the intent is unambiguous, and the code is concise. Each method is on a single line, improving action granularity. The reading flow follows a natural order: class declaration, peek method, next method, then remove method, with inherited behavior documented appropriately. The only minor issues are the abbreviated method names ('pee', 'nex', 'rem'), which deviate from standard Java naming conventions and slightly reduce clarity, but the surrounding documentation compensates for this.

Run 1

Code Structure: The interface is logically organized, with imports, class documentation, and individually documented method declarations. Nesting: Minimal nesting makes it easy to scan. Clarity of intent: The lookahead purpose is clearly explained, but abbreviated names pee(), nex(), and rem() conflict with the documented peek(), next(), and remove(), substantially undermining clarity. The latter two also have misleading @Override annotations because their names do not match Iterator methods. Code length: Appropriately concise for a documented public interface, although documentation dominates the declarations. Action granularity: Each declaration and annotation occupies its own line, with no combined actions. Reading flow: Consistent formatting and method ordering support natural reading, but repeated discrepancies between documentation and declarations interrupt understanding.

Run 2

Code Structure: The interface is logically organized, with imports, interface documentation, and individually documented methods. Nesting: Flat declarations make it easy to scan. Clarity of intent: The lookahead purpose is clear, but pee(), nex(), and rem() conflict with the documented peek(), next(), and remove() names. Moreover, @Override on nex() and rem() is invalid because these names do not match Iterator methods, undermining confidence in the API. Code length: The interface is concise; documentation is extensive but explains useful behavioral contracts. Action granularity: Each declaration and annotation occupies a separate line, with no bundled operations. Reading flow: Method ordering is natural, but repeatedly reconciling documentation with incorrect method names disrupts comprehension.

Run 3

Code Structure: The interface is logically organized, with imports, class documentation, and individually documented methods. Nesting: Flat declarations make scanning easy. Clarity of intent: Documentation clearly describes a peeking iterator, but pee(), nex(), and rem() conflict with the documented peek(), next(), and remove() names. The latter two also incorrectly use @Override, undermining confidence in the API. Code length: Concise declarations with substantial but useful contract documentation. Action granularity: Each declaration and annotation occupies its own line; no actions are combined. Reading flow: Consistent formatting and method ordering support natural reading, but repeated references to nonexistent or mismatched method names interrupt comprehension.