Sample

int-8fb9380e2fc4-I01

Remove line comments, block comments, and Javadoc

Matched original source

Lines129

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.5230–1; higher is more readable
Dorn0.1240–1; higher is more readable
Mi0.6290–1; higher is more readable
LLOC37Logical lines; fewer is more readable
DeepSeek V4 Pro15.670–20; mean of three runs
GPT-6.1 Sol160–20; mean of three runs
BTTF0.4240–1; higher is more readable

Views

Source code

package com.google.common.graph; import static com.google.common.base.Preconditions.checkState; import static java.util.Objects.requireNonNull; import com.google.common.collect.AbstractIterator; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import java.util.Iterator; import java.util.Set; import org.jspecify.annotations.Nullable; abstract class EndpointPairIterator<N> extends AbstractIterator<EndpointPair<N>> { private final BaseGraph<N> graph; private final Iterator<N> nodeIterator; @Nullable N node = null; Iterator<N> successorIterator = ImmutableSet.<N>of().iterator(); static <N> EndpointPairIterator<N> of(BaseGraph<N> graph) { return graph.isDirected() ? new Directed<N>(graph) : new Undirected<N>(graph); } private EndpointPairIterator(BaseGraph<N> graph) { this.graph = graph; this.nodeIterator = graph.nodes().iterator(); } final boolean advance() { checkState(!successorIterator.hasNext()); if (!nodeIterator.hasNext()) { return false; } node = nodeIterator.next(); successorIterator = graph.successors(node).iterator(); return true; } private static final class Directed<N> extends EndpointPairIterator<N> { private Directed(BaseGraph<N> graph) { super(graph); } @Override protected @Nullable EndpointPair<N> computeNext() { while (true) { if (successorIterator.hasNext()) { return EndpointPair.ordered(requireNonNull(node), successorIterator.next()); } if (!advance()) { return endOfData(); } } } } private static final class Undirected<N> extends EndpointPairIterator<N> { private @Nullable Set<@Nullable N> visitedNodes; private Undirected(BaseGraph<N> graph) { super(graph); this.visitedNodes = Sets.newHashSetWithExpectedSize(graph.nodes().size() + 1); } @Override protected @Nullable EndpointPair<N> computeNext() { while (true) { requireNonNull(visitedNodes); while (successorIterator.hasNext()) { N otherNode = successorIterator.next(); if (!visitedNodes.contains(otherNode)) { return EndpointPair.unordered(requireNonNull(node), otherNode); } } visitedNodes.add(node); if (!advance()) { visitedNodes = null; return endOfData(); } } } } }

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.3304.828−109.059
Source linesThe number of non-empty source lines.129+51.6
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.621−6.931

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

Score0.523

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.129+3.725
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.130−3.567
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.129−2.539
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.128.69+1.389
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.123−0.253
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.85.923+0.026

Intercept 0.07 + feature contributions = -1.953 (log-odds).
Score = sigmoid(-1.953) = 0.124.

Score0.629
Score37
Run 1

The code demonstrates good structure, clear intent, and moderate nesting. Classes are logically separated (base, Directed, Undirected), and method names like advance() and computeNext() reveal purpose. However, there are excessive blank lines and placeholder comments that disrupt reading flow. Some lines mix actions, like `node = nodeIterator.next(); successorIterator = graph.successors(node).iterator();` in sequence, which is acceptable. The use of `@Nullable` and null assignments for state management is subtle but not immediately clear. The Undirected iterator's nulling of visitedNodes feels like a minor hack. Overall, readability is above average but hindered by formatting noise and minor ambiguity in state transitions.

Run 2

The code is generally well-structured and readable. It uses clear class hierarchy with Directed and Undirected inner classes extending a common base, good naming conventions, and appropriate use of static factory methods. The main readability issues are: excessive blank lines (particularly in the middle of the Undirected class), some unnecessary comments that are empty or whitespace-only, and slight complexity in the Undirected.computeNext() method with the visitedNodes nullability and casting. The `requireNonNull` calls add some noise. The overall flow is logical, with reasonable method lengths and mostly one action per line. Nesting depth is acceptable (maximum 2-3 levels in computeNext methods). The code could be tightened by removing empty comment blocks and reducing excessive vertical spacing, which would improve clarity without changing functionality.

Run 3

The code demonstrates good structural organization with clear separation between directed and undirected cases via private static inner classes. The naming is descriptive and the overall flow is logical. However, readability is impacted by several issues: excessive blank lines disrupt reading flow, there are multiple empty comment blocks that add noise without value, and the undirected computeNext method relies on nullable fields and null checks that create mental overhead. The method advance() embeds a state precondition that requires understanding the iterator lifecycle, making intent less immediately clear. Action granularity is mostly good, but the undirected method mixes iteration, filtering, and state mutation in ways that require careful reading. Nesting is reasonable, though the while-true loops with internal conditionals create moderate complexity.

Run 1

Code Structure: The shared iterator base and separate directed/undirected implementations provide logical organization. Nesting: Directed traversal is shallow; undirected traversal has moderate nesting with two loops and a conditional. Clarity of intent: Descriptive names and ordered/unordered endpoint construction communicate purpose, but the visited-node lifecycle, initial null insertion, and duplicate-edge avoidance lack explanation. Code length: The implementation is reasonably concise, though excessive blank lines unnecessarily stretch it. Action granularity: Statements generally perform one action per line, making state transitions easy to follow. Reading flow: Methods follow a natural progression from construction to advancement and traversal, but large whitespace gaps interrupt continuity, and the stateful iteration requires some careful tracking.

Run 2

Code Structure: A shared iterator base with separate directed and undirected implementations provides logical organization. Nesting: The directed implementation is shallow; the undirected implementation adds a manageable nested loop and conditional. Clarity of intent: Descriptive names and ordered/unordered endpoint construction convey purpose, but the visited-node invariant, initial null insertion, and cleanup assignment lack explanatory comments. Code length: The implementation is reasonably concise, but excessive blank lines unnecessarily lengthen it and separate related sections. Action granularity: Statements generally perform one action per line; inline iterator advancement in return expressions remains understandable. Reading flow: Factory, initialization, advancement, and specialized iteration follow a natural sequence, although irregular whitespace and implicit state transitions interrupt readability.

Run 3

Code Structure: Shared iterator state and advancement logic are cleanly separated from directed and undirected implementations. Nesting: Mostly shallow, although the undirected implementation uses nested loops and a conditional. Clarity of intent: Descriptive names and explicit ordered/unordered endpoint construction communicate purpose; the nullable visited-node set, initial null insertion, and duplicate-suppression behavior would benefit from explanation. Code length: Functional code is concise, but excessive blank lines substantially inflate its visual length. Action granularity: Statements generally perform one clear action per line. Reading flow: The factory, shared setup, and specialized implementations form a logical sequence, but large whitespace gaps interrupt scanning, and understanding iteration state requires tracking several mutable fields.