Sample

int-8c6ec846301e-I05

Rewrite eligible decimal integer literals in hexadecimal notation

Matched original source

Lines93

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.6110–1; higher is more readable
Dorn0.3810–1; higher is more readable
Mi0.4050–1; higher is more readable
LLOC35Logical lines; fewer is more readable
DeepSeek V4 Pro15.670–20; mean of three runs
GPT-6.1 Sol17.670–20; mean of three runs
BTTF0.1420–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() { if (graph.isDirected()) { return predecessorsOrEmpty(node).size() + successorsOrEmpty(node).size() - (edgeType == EdgeType.BOTH && predecessorsOrEmpty(node).contains(node) ? 0x1 : 0x0); } 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.3192.537−105.354
Source linesThe number of non-empty source lines.93+37.2
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.219

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

Score0.611

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.94−2.292
Indentation frequencyHow rapidly indentation changes from line to line.81+2.065
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.81−1.438
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.92.845+0.888
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.95.894+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.96−0.401
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.109−0.118

Intercept 0.07 + feature contributions = -0.484 (log-odds).
Score = sigmoid(-0.484) = 0.381.

Score0.405
Score35
Run 1

The code is fairly readable due to clear class structure, logical method naming, and useful Javadoc comments. The helper methods reduce duplication and improve clarity in size() and contains(). However, it loses points for several issues: the ternary expression in size() uses hex literals (0x1/0x0) instead of boolean true/false, reducing clarity. The contains() method has nested conditionals and repeated graph.isDirected() checks, adding mild nesting and slight ambiguity. Some logic — particularly the directed size calculation and incident-edge containment checks — could be extracted for better flow. Overall, the structure is solid, but a few dense expressions and nesting patterns prevent it from being highly readable.

Run 2

The code is well-structured and readable overall. It has clear class and method names, meaningful Javadoc, and a logical organization with helper methods that reduce duplication. The nesting is shallow (mostly 2-3 levels), and the reading flow is natural. The main readability issue is in the `size()` method: the inline ternary using hex literals (`0x1` / `0x0`) and the multi-line expression make the intent less obvious. The `contains` method is slightly long but still logical. Some minor verbosity exists in the repeated `endpointPair` variable declarations, but overall the code is concise, purposeful, and easy to follow.

Run 3

The code is generally well-structured and readable. It follows a logical organization with clear separation of concerns (fields, constructor, overridden methods, private helpers). Nesting is minimal, with only a couple of two-level conditionals. Intent is mostly clear: it represents a set of incident edges for a node in a graph. Methods like predecessorsOrEmpty and successorsOrEmpty improve clarity. However, readability is slightly reduced by the compact ternary expression in size(), which combines arithmetic and a boolean check in one line. The method contains() has multiple branches but remains flat and understandable. Variable names like nodeU and nodeV are a bit vague. Overall, the code is concise, uses helper methods effectively, and maintains good reading flow, but could benefit from slightly more explicit handling of the edgeType logic in size() and clearer endpoint variable naming.

Run 1

Code Structure: Fields, enum, constructor, public overrides, and private helpers are logically organized. Nesting: Control flow is shallow, with early returns simplifying contains(). Clarity of intent: Descriptive names and helper documentation clearly convey edge filtering; however, the self-loop correction in size() requires interpretation, and hexadecimal 0x1/0x0 unnecessarily obscure ordinary counts. Code length: Generally concise, though repeated predecessor lookups and explicit else branches after returns add minor verbosity. Action granularity: Statements generally perform one action each; compound boolean expressions remain manageable, but size() combines several operations in one expression. Reading flow: Methods follow a natural progression, and directed versus undirected behavior is clearly separated. Minor drawbacks include the missing blank line after the package declaration and the uncommented self-loop adjustment.

Run 2

Code Structure: Fields, enum, constructor, overridden methods, and private helpers are logically organized with clear responsibilities. Nesting: Shallow conditionals and early validation returns keep control flow easy to follow. Clarity of intent: Descriptive names, enum comments, and helper documentation explain edge filtering well; however, the self-loop adjustment in size() lacks explanation, and hexadecimal 0x1/0x0 unnecessarily obscure simple values. Code length: Compact overall, with minor repetition in directedness checks and helper calls. Action granularity: Statements generally perform one action per line, although compound return expressions require slightly more attention. Reading flow: Consistent formatting and separate directed/undirected branches support natural reading; the multiline arithmetic and Boolean expressions introduce modest cognitive overhead.

Run 3

Code Structure: Methods are logically organized, with edge-selection logic isolated in small helpers. Nesting: Shallow conditionals and early returns keep complexity low, though some else branches are unnecessary. Clarity of intent: Descriptive names, enum comments, and helper documentation explain the purpose well; hexadecimal 0x1 and 0x0 obscure an otherwise straightforward self-loop adjustment. Code length: Concise overall, with minor repetition in graph queries and similar helper methods. Action granularity: Statements generally perform one action per line; compound return expressions remain manageable. Reading flow: Validation precedes membership checks naturally, and directed versus undirected behavior is clearly separated. The size calculation requires slightly more effort to understand because it combines conditional edge selection and self-loop deduplication.