Sample

int-caf4b3fa5b1f-I12

Inline all eligible single-use intermediate local variables

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.670–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 generally well-structured and readable. It uses clear naming, logical organization, and flat nesting with early returns. The `predecessorsOrEmpty` and `successorsOrEmpty` helpers improve clarity and avoid repetition. However, the `size()` method contains a complex one-line conditional expression that somewhat hurts readability. The `contains()` method is clear but could be slightly simplified. Overall, it is concise, intent-revealing, and easy to follow for developers familiar with graph concepts.

Run 3

The code is well-structured with clear separation of concerns, using an enum to represent edge types and helper methods to encapsulate logic. It maintains a mostly flat structure, with only one level of nesting in conditionals, which aids readability. The intent is clear from the class and method names, though the `contains` and `size` methods contain some complex boolean logic that could be slightly simplified. The code is concise and avoids unnecessary length, with each line performing a single logical action. Reading flow is natural, moving from field declarations to constructors, then core methods and private helpers. Overall, it is highly readable, with minor opportunities for improving expression clarity in the `size` and `contains` methods.

Run 1

Code Structure: Fields, enum, constructor, overrides, and private helpers are logically organized. Nesting: Shallow conditionals and early validation returns keep complexity low. Clarity of intent: Descriptive names, enum comments, and helper documentation explain edge filtering clearly; the self-loop adjustment in size() would benefit from a comment. Code length: Concise overall, though repeated predecessorsOrEmpty(node) calls and explicit else branches add minor verbosity. Action granularity: Statements generally perform one action each; compound return expressions combine related checks appropriately. Reading flow: Consistent formatting and clear directed/undirected branches make execution easy to follow, although the arithmetic and ternary expression in size() require extra attention.

Run 2

Code Structure: Fields, enum, constructor, overrides, and helper methods are logically organized with clear separation of responsibilities. Nesting: Shallow conditionals and early returns keep control flow easy to follow. Clarity of intent: Descriptive names, enum comments, and helper documentation explain edge filtering well; the self-loop subtraction in size() would benefit from a brief comment. Code length: Compact and appropriate, though repeated helper calls and explicit else branches add minor verbosity. Action granularity: Statements generally perform one action per line; multiline boolean expressions remain readable. Reading flow: Validation precedes membership checks naturally, and directed versus undirected behavior is clearly separated. The compound size calculation requires slightly more attention than the rest.

Run 3

Code Structure: Fields, edge types, constructor, overrides, and helper methods are logically organized. Nesting: Shallow conditionals and early returns keep control flow easy to follow. Clarity of intent: Descriptive names, enum comments, and helper documentation clearly convey directed-edge filtering; the self-loop adjustment in size() would benefit from a comment. Code length: Compact and appropriately factored, though repeated predecessor queries and explicit else branches add minor verbosity. Action granularity: Statements generally perform one action per line; compound boolean expressions and the size calculation are readable but require extra attention. Reading flow: Consistent formatting and parallel handling of directed and undirected graphs make the code natural to scan, with only the self-loop arithmetic slightly interrupting comprehension.