Sample

int-123fb14da323-I06

Invert eligible conditions and exchange their branches

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 with a clear, logical structure. The class has a single responsibility, and methods are short with descriptive names. Nesting is minimal—only simple ternary expressions are used, avoiding deep indentation. Intent is explicit through method names like getConnectingEdge and contains, and the Javadoc explains the class's purpose and limitation. Code length is concise without sacrificing clarity. Action granularity is appropriate: each line performs one logical operation. Reading flow is natural, with fields, constructor, and overridden methods ordered logically. Minor deductions: the ternary in iterator() could be slightly clearer, and the wildcard generic Map<?, E> is understandable but slightly less explicit than ideal.

Run 3

The code is well-structured with clear logical organization: fields are declared first, followed by a constructor, then public API methods (iterator, size, contains), and a private helper at the end. Nesting is minimal with flat conditional expressions using ternary operators. Intent is clear—the class represents edges between implicit origins and a target node, supported by useful Javadoc and null checks. Length is concise; no unnecessary code or redundant logic exists. Action granularity is excellent, with one primary action per line, especially within the iterator method where the ternary is broken across lines for readability. Reading flow is natural, following a top-down progression from fields to constructor to public methods to private helper. Minor improvements could include an inline comment explaining why getConnectingEdge may return null, and perhaps breaking the size() ternary for consistency, but overall the code is highly readable.

Run 1

Code Structure: A focused class with logically organized fields, constructor, set operations, and a shared lookup helper. Nesting: Essentially flat; simple conditionals avoid nested control flow. Clarity of intent: Descriptive names and documentation clearly explain the single-edge constraint and purpose, though the implicit origin node requires some graph context. Code length: Concise without unnecessary abstraction or repetition. Action granularity: Each statement performs one clear action; ternary expressions compactly represent straightforward alternatives. Reading flow: Natural progression from initialization to public behavior and the private helper. The multiline iterator ternary and generic factory syntax add slight visual complexity, but overall readability is excellent.

Run 2

Code Structure: Fields, constructor, overridden set operations, and a private lookup helper are logically organized. Nesting: There are no nested blocks; simple conditional expressions keep control flow flat. Clarity of intent: Descriptive names and class documentation clearly explain the edge-set abstraction and its restriction to networks without parallel edges. Code length: The implementation is concise, with a helper centralizing the lookup and no unnecessary logic. Action granularity: Statements generally perform one action each; conditional returns remain easy to understand. Reading flow: Methods follow a natural sequence and consistently use the same lookup pattern. Minor readability drawbacks are the tightly packed imports and the multiline ternary with explicit generic syntax in iterator(), which is slightly less immediate than the other methods.

Run 3

Code Structure: Fields, constructor, set-operation overrides, and a private lookup helper are logically organized. Nesting: Methods are flat, with simple conditional expressions and no nested control flow. Clarity of intent: Descriptive names and class documentation clearly explain the connecting-edge set and its restriction against parallel edges; nullability annotations clarify absence handling. Code length: The implementation is concise, with minimal boilerplate and a shared helper avoiding repeated lookup details. Action granularity: Each statement performs a focused action, although conditional expressions combine selection and return. Reading flow: Methods follow familiar collection conventions and are easy to scan. Minor readability drawbacks are the densely grouped imports and the multiline ternary with an explicit generic type in iterator(), which is slightly less immediate than the other methods.