Sample

int-1d520c07ffae-I13

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

Matched original source

Lines93

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.6140–1; higher is more readable
Dorn0.3810–1; higher is more readable
Mi0.5070–1; higher is more readable
LLOC35Logical lines; fewer is more readable
DeepSeek V4 Pro16.330–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.460–1; higher is more readable

Views

Source code

package com.google.common.graph; import com.google.common.collect.ImmutableSet; import java.util.AbstractSet; import java.util.Set; import org.jspecify.annotations.Nullable; /** * Abstract base class for an incident edges set that allows different implementations of {@link * AbstractSet#iterator()}. */ abstract class IncidentEdgeSet<N> extends AbstractSet<EndpointPair<N>> { final N node; final ArchetypeGraph<N> graph; final EdgeType edgeType; enum EdgeType { INCOMING, // incoming incident edges only OUTGOING, // outgoing incident edges only BOTH // both incoming and outgoing incident edges } IncidentEdgeSet(ArchetypeGraph<N> graph, N node, EdgeType edgeType) { this.graph = graph; this.node = node; this.edgeType = edgeType; } @Override public boolean remove(@Nullable Object o) { throw new UnsupportedOperationException(); } @Override public int size() { if (graph.isDirected()) { return predecessorsOrEmpty(node).size() + successorsOrEmpty(node).size() - (edgeType == EdgeType.BOTH && predecessorsOrEmpty(node).contains(node) ? 1 : 0); } else { return graph.adjacentNodes(node).size(); } } @Override public boolean contains(@Nullable Object obj) { if (!(obj instanceof EndpointPair)) { return false; } EndpointPair<?> endpointPair = (EndpointPair<?>) obj; if (graph.isDirected() != endpointPair.isOrdered()) { return false; } if (graph.isDirected()) { Object source = endpointPair.source(); Object target = endpointPair.target(); return (node.equals(source) && successorsOrEmpty(node).contains(target)) || (node.equals(target) && predecessorsOrEmpty(node).contains(source)); } else { Set<N> adjacent = graph.adjacentNodes(node); Object nodeU = endpointPair.nodeU(); Object nodeV = endpointPair.nodeV(); return (node.equals(nodeV) && adjacent.contains(nodeU)) || (node.equals(nodeU) && adjacent.contains(nodeV)); } } /** * Returns the predecessors of the given node, or an empty set if this set does not represent * incoming edges. */ private Set<N> predecessorsOrEmpty(N node) { if (edgeType == EdgeType.INCOMING || edgeType == EdgeType.BOTH) { return graph.predecessors(node); } else { return ImmutableSet.of(); } } /** * Returns the successors of the given node, or an empty set if this set does not represent * outgoing edges. */ private Set<N> successorsOrEmpty(N node) { if (edgeType == EdgeType.OUTGOING || edgeType == EdgeType.BOTH) { return graph.successors(node); } else { return ImmutableSet.of(); } } }

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.3171.581−104.662
Source linesThe number of non-empty source lines.93+37.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.805−7.207

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

Score0.614

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.94−2.292
Indentation frequencyHow rapidly indentation changes from line to line.81+2.065
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.81−1.438
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.92.856+0.888
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.95.894+0.743
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.95.989−0.401
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.109−0.12

Intercept 0.07 + feature contributions = -0.485 (log-odds).
Score = sigmoid(-0.485) = 0.381.

Score0.507
Score35
Run 1

The code is well-structured and readable. It uses a logical class hierarchy, clear method names, and descriptive Javadoc. The `EdgeType` enum improves clarity. Methods are concise, and code is mostly flat with minimal nesting. The main readability concern is in `contains` and `size`, which have slightly complex boolean logic and repeated calls to helper methods. Additionally, the ternary in `size` and the mixed concerns in `contains` make the intent slightly harder to parse at a glance. Overall, the structure and naming are strong, but a few expressions could be extracted for even better clarity.

Run 2

The code is well-structured and readable. It has a clear class purpose, good documentation, and logical organization. The nesting is shallow, with simple if-else branches and no deep indentation. Method names like `predecessorsOrEmpty` clearly convey intent. The code is concise without being overly dense. Each line generally performs a single action, and the reading flow is natural. Minor deductions: the `size()` method has a complex ternary expression that could be extracted for clarity, and the `contains()` method has a long boolean expression that slightly reduces readability. Overall, the code is maintainable and understandable.

Run 3

The code is well-structured with clear class and method organization. The edge type enum helps clarify intent. Methods are small and focused, generally one action per line. Nesting is minimal in most methods, though 'contains' has two levels with boolean logic across multiple lines. The ternary in 'size' with method calls inside is slightly dense but understandable. Javadoc comments on private helper methods are good. The 'contains' method has multiple conditions and object casting that add complexity but remain readable. Overall, the code is concise and follows good practices, though some expressions could use explanatory variables.

Run 1

Code Structure: Fields, enum, constructor, overrides, and focused helpers are logically organized. Nesting: Shallow conditionals and early validation returns keep complexity low. Clarity of intent: Descriptive names, enum comments, and helper documentation make edge filtering clear; the self-loop adjustment in size() could use an explanatory comment. Code length: Compact and appropriately scoped, although repeated predecessor lookups and explicit else branches add minor verbosity. Action granularity: Statements generally perform one action each; compound boolean expressions remain manageable, but size() combines several calculations. Reading flow: Consistent formatting and a natural progression from public behavior to private helpers make the class easy to follow, with slightly denser expressions in size() and contains().

Run 2

Code Structure: Well-organized class with focused overrides, an explicit edge-type enum, and small helper methods. Nesting: Shallow conditionals and early validation returns keep control flow easy to follow. Clarity of intent: Descriptive names and helper documentation clearly explain edge filtering; the self-loop subtraction in size() would benefit from a comment. Code length: Concise overall, though repeated predecessor lookups and unnecessary else branches add minor verbosity. Action granularity: Statements generally perform one action per line; compound return expressions remain reasonably readable. Reading flow: Fields, constructor, public methods, and private helpers follow a natural order. Directed and undirected cases are cleanly separated, although the multiline arithmetic and Boolean expressions require slightly more attention.

Run 3

Code Structure: Fields, enum, constructor, overrides, and private helpers are logically organized, with edge-selection logic isolated in helpers. Nesting: Shallow conditionals and early validation returns keep branching easy to follow. Clarity of intent: Descriptive names, enum comments, and helper documentation clearly convey graph-edge behavior; the self-loop subtraction in size() would benefit from a brief explanation. Code length: Compact and appropriate, though repeated predecessor lookups and explicit else branches add minor verbosity. Action granularity: Statements generally perform one action each; compound boolean expressions and the size calculation require slightly more attention. Reading flow: Validation precedes membership checks, and directed versus undirected behavior is clearly separated. Overall, the code is highly readable, with only modest complexity in its arithmetic and membership expressions.