Sample

int-9ee72f22b107-I13

Lower every eligible classic and enhanced for loop to a while loop

Matched original source

Lines53

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.7950–1; higher is more readable
Dorn0.4740–1; higher is more readable
Mi0.7160–1; higher is more readable
LLOC15Logical lines; fewer is more readable
DeepSeek V4 Pro17.670–20; mean of three runs
GPT-6.1 Sol190–20; mean of three runs
BTTF0.5620–1; higher is more readable

Views

Source code

package com.google.common.collect; import com.google.common.annotations.GwtCompatible; import java.util.Map.Entry; import java.util.Objects; import org.jspecify.annotations.Nullable; /** * Implementation of the {@code equals}, {@code hashCode}, and {@code toString} methods of {@code * Entry}. * * @author Jared Levy */ @GwtCompatible abstract class AbstractMapEntry<K extends @Nullable Object, V extends @Nullable Object> implements Entry<K, V> { @Override @ParametricNullness public abstract K getKey(); @Override @ParametricNullness public abstract V getValue(); @Override @ParametricNullness public V setValue(@ParametricNullness V value) { throw new UnsupportedOperationException(); } @Override public boolean equals(@Nullable Object object) { if (object instanceof Entry) { Entry<?, ?> that = (Entry<?, ?>) object; return Objects.equals(this.getKey(), that.getKey()) && Objects.equals(this.getValue(), that.getValue()); } return false; } @Override public int hashCode() { K k = getKey(); V v = getValue(); return ((k == null) ? 0 : k.hashCode()) ^ ((v == null) ? 0 : v.hashCode()); } /** Returns a string representation of the form {@code {key}={value}}. */ @Override public String toString() { return getKey() + "=" + getValue(); } }

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.1546.216−51.025
Source linesThe number of non-empty source lines.53+21.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.95−7.426

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

Score0.795

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.48+0.923
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.54−0.876
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.95.111+0.73
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.48−0.681
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.963−0.442
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.52.704+0.327
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.113−0.154

Intercept 0.07 + feature contributions = -0.102 (log-odds).
Score = sigmoid(-0.102) = 0.474.

Score0.716
Score15
Run 1

The code is well-structured with clear separation of concerns: abstract getters, a default setter throwing UnsupportedOperationException, and overridden equals/hashCode/toString methods. Nesting is minimal (one level in equals). Intent is explicit through method names, Javadoc, and use of Objects.equals. The equals method is concise and correct, used with instanceof pattern and wildcard cast. hashCode follows the standard Entry contract with null checks via ternary operators. toString is a simple one-liner matching its contract. Minor readability improvements could include extracting the null-handling logic into helper methods or using Objects.hashCode, but the current style is consistent and idiomatic for Guava. Overall, the code maintains a natural reading flow and one action per line, with no excessive length or ambiguity.

Run 2

The code is highly readable. It has a clear, logical structure with a single class implementing a well-defined interface. Nesting is minimal, with only one level in the equals method. Intent is clear from class and method names, and the Javadoc provides helpful context. Code length is concise and appropriate, with no redundancies. Each line performs a distinct action, contributing to clean action granularity. The reading flow is natural, following a logical sequence of methods and using standard Java idioms. Minor complexity arises from null-handling and generic casting, but this is typical for collection implementations and does not significantly hinder readability.

Run 3

The code is highly readable. Structure is logical: methods are clearly separated and follow a natural order (getters, setter, equals, hashCode, toString). Nesting is minimal—only one level deep in equals and hashCode. Intent is clear from descriptive method and variable names. The code is concise and avoids unnecessary verbosity, with hashCode and equals implemented in a standard, recognizable pattern. Action granularity is good: most lines perform a single operation; chained method calls in equals remain clear. Reading flow is natural and well-organized. Javadoc and annotations add clarity without clutter. Minor deductions for the slightly dense ternary in hashCode and the unavoidable generics casting, but overall it exemplifies clean, maintainable Java code.

Run 1

Code Structure: A well-organized class with clearly separated methods implementing the Entry contract. Nesting: Minimal, with only one conditional block in equals. Clarity of intent: Standard method names, overrides, and documentation make the purpose clear; terse variables k and v slightly reduce clarity. Code length: Concise, with no unnecessary logic or repetition. Action granularity: Statements generally perform one action each, though hashCode combines null checks, hash calculations, and XOR in one expression. Reading flow: Methods follow a natural order, and consistent formatting makes the code easy to scan. Generic nullness annotations add some visual complexity but convey useful type information.

Run 2

Code Structure: Methods are logically organized within a small, focused abstraction. Nesting: Only one shallow conditional appears in equals; other methods are flat. Clarity of intent: Standard Entry method names, documentation, and familiar implementations clearly communicate purpose. Short variable names in hashCode slightly reduce clarity, and the unsupported setValue behavior could be documented explicitly. Code length: Concise without unnecessary repetition or complexity. Action granularity: Each statement performs a focused action; compound equality and hash calculations appropriately express single logical operations. Reading flow: Consistent formatting and straightforward method bodies make the code easy to follow, although generic nullness annotations add some visual density.

Run 3

Code Structure: Methods are logically organized within a focused abstraction implementing standard map-entry behavior. Nesting: Only one shallow conditional appears in equals; other methods are flat. Clarity of intent: Familiar method names, annotations, and documentation clearly communicate purpose, though the abbreviated k and v variables slightly reduce clarity. Code length: The implementation is concise without unnecessary scaffolding. Action granularity: Each statement performs a distinct action; the hash-code expression combines two computations naturally but is slightly dense. Reading flow: Consistent formatting and straightforward method bodies make the code easy to follow, with only minor visual complexity from generic bounds, annotations, and ternary expressions.