Sample

int-5e08841acf75-I12

Inline all eligible single-use intermediate local variables

Matched original source

Lines51

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.6050–1; higher is more readable
Dorn0.5210–1; higher is more readable
Mi0.5180–1; higher is more readable
LLOC15Logical lines; fewer is more readable
DeepSeek V4 Pro180–20; mean of three runs
GPT-6.1 Sol190–20; mean of three runs
BTTF0.6240–1; higher is more readable

Views

Source code

package com.google.common.graph; import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterators; import com.google.common.collect.UnmodifiableIterator; import java.util.AbstractSet; import java.util.Map; import org.jspecify.annotations.Nullable; /** * A class to represent the set of edges connecting an (implicit) origin node to a target node. * * <p>The {@link #nodeToOutEdge} map means this class only works on networks without parallel edges. * See {@link MultiEdgesConnecting} for a class that works with parallel edges. * * @author James Sexton * @param <E> Edge parameter type */ final class EdgesConnecting<E> extends AbstractSet<E> { private final Map<?, E> nodeToOutEdge; private final Object targetNode; EdgesConnecting(Map<?, E> nodeToEdgeMap, Object targetNode) { this.nodeToOutEdge = checkNotNull(nodeToEdgeMap); this.targetNode = checkNotNull(targetNode); } @Override public UnmodifiableIterator<E> iterator() { E connectingEdge = getConnectingEdge(); return (connectingEdge == null) ? ImmutableSet.<E>of().iterator() : Iterators.singletonIterator(connectingEdge); } @Override public int size() { return getConnectingEdge() == null ? 0 : 1; } @Override public boolean contains(@Nullable Object edge) { E connectingEdge = getConnectingEdge(); return connectingEdge != null && connectingEdge.equals(edge); } private @Nullable E getConnectingEdge() { return nodeToOutEdge.get(targetNode); } }

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.1511.099−49.866
Source linesThe number of non-empty source lines.51+20.4
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.818−7.228

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

Score0.605

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.99.808+0.806
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.52−0.805
Indentation frequencyHow rapidly indentation changes from line to line.43+0.75
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.981−0.57
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.43−0.566
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.50.762+0.3
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.087+0.1

Intercept 0.07 + feature contributions = 0.086 (log-odds).
Score = sigmoid(0.086) = 0.521.

Score0.518
Score15
Run 1

The code is highly readable. The class has a clear, single responsibility and is well-documented. The structure is logical, with a private helper method (getConnectingEdge) eliminating duplication. Nesting is minimal — all methods are flat, with only simple null checks. Intent is unambiguous: the class represents edges connecting two nodes in a graph without parallel edges. The code length is appropriate, with concise methods and no unnecessary verbosity. Each line performs a single logical action, and the reading flow is natural — constructor, iterator, size, contains, then the private helper. The only minor point is the conditional expression in iterator() spans multiple lines, but the formatting is standard and readable. Overall, this is exemplary clean Java code.

Run 2

The code is highly readable due to its clear structure, minimal nesting, and concise implementation. The class has a single, well-defined purpose representing edges connecting an implicit origin to a target node. Methods are short, focused, and follow a logical reading flow. The use of helper method getConnectingEdge() eliminates duplication and improves clarity. Nesting is minimal with ternary operators used appropriately for simple conditional returns. Each line performs one logical action, and naming is descriptive. The code follows Google Java conventions with proper imports and Javadoc. Minor deductions for slight cognitive overhead in understanding the map-based edge representation and the single-line ternary operators, but overall the implementation is exceptionally clean and maintainable.

Run 3

The code is well-structured and highly readable. It clearly represents a set of edges connecting nodes, with concise methods (iterator, size, contains) delegating to a single helper (getConnectingEdge). Nesting is minimal, with only a couple of ternary expressions that remain flat. Intent is obvious from class and method names, and the Javadoc explains the distinction from MultiEdgesConnecting. Code length is appropriate—no unnecessary boilerplate. Each method performs a focused action with good granularity. The reading flow is natural, from constructor to iterator to size to contains, followed by the private helper. Use of Preconditions and ImmutableSet adds clarity and safety. Minor deduction only for the ternary return statements, which slightly interrupt flow compared to an if-else, but overall it is excellent.

Run 1

Code Structure: Well-organized class with fields, constructor, standard set operations, and a focused lookup helper. Nesting: Essentially flat; simple conditional expressions avoid nested control flow. Clarity of intent: Descriptive names and class documentation clearly explain the single-edge constraint and purpose. Code length: Concise, with little unnecessary code or duplication. Action granularity: Each statement performs one clear action, and lookup results are stored locally where appropriate. Reading flow: Methods follow a natural sequence and consistently use the same helper. Minor readability drawbacks include the multiline ternary in iterator() and slightly inconsistent naming between nodeToEdgeMap and nodeToOutEdge.

Run 2

Code Structure: Fields, constructor, overridden set methods, and a private lookup helper are logically organized. Nesting: Methods remain flat, with simple conditional expressions and no nested control flow. Clarity of intent: Descriptive names and class documentation clearly explain the single-edge set abstraction and its restriction against parallel edges. Code length: The implementation is concise without unnecessary repetition or boilerplate. Action granularity: Each statement performs one clear operation; conditional expressions compactly express straightforward choices. Reading flow: The progression from initialization to public behavior and then the lookup helper is natural. Minor readability costs include the generic empty-set iterator syntax and the multiline ternary in iterator(), which require slightly more attention.

Run 3

Code Structure: Well-organized class with clearly separated constructor, set operations, and a shared lookup helper. Nesting: Flat methods with no nested control flow; simple conditional expressions are easy to follow. Clarity of intent: Descriptive names and class documentation clearly explain the zero-or-one-edge model and the restriction against parallel edges. Code length: Concise, with no unnecessary logic or repetition beyond straightforward lookups. Action granularity: Each statement performs one clear action, and conditional returns remain readable. Reading flow: Fields, initialization, public operations, and the private helper follow a natural sequence. Minor readability costs come from the wildcard map type and the slightly different constructor parameter and field names.