Sample

int-9a1a347e35e0-I08

Select one of ten high-readability unrelated code templates per class

Matched original source

Lines102

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.5910–1; higher is more readable
Dorn0.3660–1; higher is more readable
Mi0.510–1; higher is more readable
LLOC40Logical lines; fewer is more readable
DeepSeek V4 Pro70–20; mean of three runs
GPT-6.1 Sol14.670–20; mean of three runs
BTTF0.3010–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() { { int morningTemperature = 18; int eveningTemperature = 14; int lowerTemperature = morningTemperature; if (eveningTemperature < lowerTemperature) { lowerTemperature = eveningTemperature; } } 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.3400.363−112.212
Source linesThe number of non-empty source lines.102+40.8
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.804−7.206

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

Score0.591

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.103−2.611
Indentation frequencyHow rapidly indentation changes from line to line.90+2.376
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.90−1.644
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.101.866+1.014
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.95.883+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.951−0.399
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.107−0.097

Intercept 0.07 + feature contributions = -0.549 (log-odds).
Score = sigmoid(-0.549) = 0.366.

Score0.51
Score40
Run 1

The class has a clear purpose and some reasonable structure, but several issues hurt readability. A major defect is an unrelated, stray code block inside the size() method that computes temperature variables—this is confusing and clearly accidental. The size() method also contains a complex ternary expression mixing arithmetic, method calls, and conditionals on one line, reducing clarity. contains() is structured logically but has moderate nesting and multiple boolean checks that are not broken into helper methods. Method names like predecessorsOrEmpty and successorsOrEmpty are descriptive, and constant definitions are clear. However, the reading flow is disrupted by the misplaced block, and action granularity suffers from dense expressions. Overall, the code is understandable in parts but requires cleanup to improve readability.

Run 2

The code has clear naming and good comments, but there are major issues. A block of unrelated code (morningTemperature/eveningTemperature) is accidentally inserted inside the size() method, which is a critical structural error that drastically hurts readability and intent. The class structure overall is logical, but this foreign code creates confusion. Nesting is moderate; methods like contains() use conditional branches but are not overly deep. Action granularity is mostly reasonable, but some boolean expressions combine multiple actions on one line. The size() method mixes a leftover block with real logic, making it hard to follow. Reading flow is disrupted by the stray block and slightly long conditionals. If the leftover block were removed and conditions simplified, readability would improve significantly.

Run 3

The code has several serious readability issues. There is an unrelated block of code (temperature variables) accidentally inserted inside the size() method, which breaks logical structure and reading flow. This is likely a copy-paste error but significantly harms clarity. Beyond that, the class has a reasonable structure with an abstract base class and enum, but methods like size() and contains() use dense conditional expressions and nested ternaries that are hard to parse. The contains() method has multiple boolean checks and OR conditions combined with method calls, increasing cognitive load. Some intent is documented via javadoc and method names like predecessorsOrEmpty, which helps, but the overall flow is disrupted by the stray code block and compact logic. The code length is moderate but not concise in places, and action granularity sometimes combines multiple logical steps per line. Overall, readability is poor.

Run 1

Code Structure: Fields, enum, constructor, overrides, and helper methods are logically organized, but the unrelated temperature block in size() disrupts cohesion. Nesting: Generally shallow, with straightforward conditionals and early returns; the extraneous block adds unnecessary nesting. Clarity of intent: Descriptive names and documentation make incident-edge handling clear, although the temperature calculation has no apparent purpose and the compound size expression requires careful reading. Code length: Mostly concise, but unused temperature calculations and repeated predecessor lookups add avoidable code. Action granularity: Statements generally perform one action per line; compound return expressions remain reasonably formatted. Reading flow: Method organization and consistent formatting support natural reading, except for the abruptly inserted, poorly indented temperature block.

Run 2

Code Structure: The class is logically organized into fields, an enum, overrides, and focused helpers, but an unrelated temperature-calculation block disrupts size(). Nesting: Mostly shallow conditionals and early returns keep complexity manageable; the extraneous block adds unnecessary nesting. Clarity of intent: Descriptive names and helper documentation explain graph operations well, though the self-loop adjustment requires careful reading and the temperature code has no apparent purpose. Code length: Generally concise, with some repetitive helper branching and unnecessary temperature statements. Action granularity: Statements usually perform one action per line; compound return expressions are reasonably formatted but denser. Reading flow: Consistent organization and formatting support natural reading, except for the poorly indented, irrelevant block inside size(), which significantly interrupts the flow.

Run 3

Code Structure: The class is logically organized into fields, an enum, overrides, and focused helpers, but the unrelated temperature block in size() disrupts cohesion. Nesting: Generally shallow; guard clauses simplify contains(), while the extraneous block adds unnecessary nesting. Clarity of intent: Descriptive names and helper documentation explain edge filtering, but the temperature calculation has no apparent purpose and the self-loop adjustment requires careful reading. Code length: Mostly concise, with avoidable length from unused temperature calculations and some repetitive branching. Action granularity: Statements generally perform one action per line; compound return expressions remain manageable, although size() combines several operations. Reading flow: Method ordering and consistent graph terminology support natural reading, but the poorly indented temperature block interrupts the flow substantially.