Sample

int-b5085aa794c2-I11

Split eligible integer literals into pairs of short-named intermediate variables

Matched original source

Lines55

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.6180–1; higher is more readable
Dorn0.50–1; higher is more readable
Mi0.5180–1; higher is more readable
LLOC19Logical lines; fewer is more readable
DeepSeek V4 Pro140–20; mean of three runs
GPT-6.1 Sol160–20; mean of three runs
BTTF0.4660–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() { final int a = 1; final int b = -1; final int c = 2; final int d = -1; return getConnectingEdge() == null ? (a + b) : (c + d); } @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.1752.259−57.825
Source linesThe number of non-empty source lines.55+22
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.812−7.218

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

Score0.618

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.56−0.946
Indentation frequencyHow rapidly indentation changes from line to line.47+0.889
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.99.821+0.806
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.47−0.658
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.964−0.569
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.54.752+0.356
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.091+0.054

Intercept 0.07 + feature contributions = 0.001 (log-odds).
Score = sigmoid(0.001) = 0.5.

Score0.518
Score19
Run 1

The code has a clear purpose and reasonable class structure, but several factors reduce readability. The `size()` method is unnecessarily obfuscated: using variables `a`, `b`, `c`, `d` with values that compute to 0 and 1 is confusing when a simple `return getConnectingEdge() == null ? 0 : 1;` would be clearer. The `iterator()` method is relatively flat and low-nesting, but the ternary expression spans multiple lines and could be simplified. Method naming (`nodeToOutEdge`, `nodeToEdgeMap`) is slightly inconsistent between field and constructor parameter. Action granularity is generally acceptable, but the simultaneous declaration and initialization of four meaningless constants in `size()` violates clarity of intent. The class javadoc is helpful, and the overall flow from iterator to size to contains is logical. The implementation is concise but sacrifices directness in the `size()` method, making it harder to understand than necessary.

Run 2

The code is well-structured with clear class responsibility and logical organization. Nesting is minimal and flat. Intent is clearly conveyed through naming and documentation. However, readability is notably hurt by the size() method: variables a, b, c, d are cryptic and obscure that the method returns 0 or 1. This single flaw undermines otherwise excellent clarity. Action granularity and reading flow are strong—each statement does one thing. The class is concise and avoids unnecessary complexity. Replacing the size() implementation with a simple ternary like `return getConnectingEdge() == null ? 0 : 1;` would make the code essentially perfect. The Javadoc and null-checking patterns are idiomatic and aid understanding.

Run 3

The code is generally readable, with clear class purpose and straightforward methods. However, several issues hamper readability. The size() method introduces pointless local variables (a, b, c, d) to compute 0 or 1, obscuring intent and adding noise. The iterator() method mixes ternary logic with two different iterator types, making it harder to parse. The class structure is logical but tightly coupled to a single Map and target node. The use of wildcard generics in Map<?, E> reduces type clarity. Action granularity is mostly fine, though the ternary expressions could be broken into clearer statements. The reading flow is natural for getConnectingEdge and contains, but the iterator and size methods interrupt that flow with unnecessary abstraction. Overall, the code is maintainable but would benefit from simplified logic and clearer intent in edge cases.

Run 1

Code Structure: Well-organized class with focused methods and a shared lookup helper. Nesting: Flat, with simple conditional expressions and no nested blocks. Clarity of intent: Documentation and descriptive field names clearly explain the single-edge set, but size() obscures a simple 0-or-1 result with meaningless variables and arithmetic. Code length: Mostly concise; the four constants in size() add unnecessary length. Action granularity: Each statement performs one clear action, although the arithmetic introduces needless cognitive work. Reading flow: Methods follow naturally from construction to set operations and lookup, with consistent formatting; the contrived size() implementation interrupts otherwise straightforward reading.

Run 2

Code Structure: Well organized, with focused methods and a shared lookup helper. Nesting: Flat control flow; conditional expressions introduce little complexity. Clarity of intent: Documentation and descriptive field and method names explain the class well, but size() obscures a simple 0-or-1 result behind arbitrary constants and arithmetic. Code length: Mostly concise, though the four constants in size() add unnecessary lines. Action granularity: Each statement performs a single action, making operations easy to follow. Reading flow: Natural progression from fields and construction to collection operations and the helper; the unexplained arithmetic in size() interrupts otherwise straightforward reading.

Run 3

Code Structure: The class is logically organized, with fields, constructor, collection methods, and a shared lookup helper. Nesting: Control flow is flat, using simple conditional expressions without nested blocks. Clarity of intent: Documentation and descriptive names explain the single-edge set behavior, but size() obscures its simple 0-or-1 result with meaningless variables and arithmetic. Code length: Most methods are concise; the four constants in size() add unnecessary length. Action granularity: Each statement performs one clear action, with no crowded multi-statement lines. Reading flow: The method ordering and consistent formatting support natural reading, although the unexplained arithmetic in size() interrupts comprehension. Replacing it with a direct null check returning 0 or 1 would substantially improve readability.