Sample
int-3649510cbce9-I13
Lower every eligible classic and enhanced for loop to a while loop
Scores
| Method | Score | Scale |
|---|---|---|
| Posnett | 0 | 0–1; higher is more readable |
| Scalabrino | 0.622 | 0–1; higher is more readable |
| Dorn | 0.284 | 0–1; higher is more readable |
| Mi | 0.575 | 0–1; higher is more readable |
| LLOC | 37 | Logical lines; fewer is more readable |
| DeepSeek V4 Pro | 16.67 | 0–20; mean of three runs |
| GPT-6.1 Sol | 17 | 0–20; mean of three runs |
| BTTF | 0.5 | 0–1; higher is more readable |
Views
Loading feature diagnosis…
Source regions
Feature contributions
Feature contributions
| Feature | Value | Contribution (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. | 3304.828 | −109.059 |
| Source linesThe number of non-empty source lines. | 129 | +51.6 |
| 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.721 | −7.082 |
Intercept 8.87 + feature contributions = -55.671 (log-odds).
Score = sigmoid(-55.671) = 0.
| Score | 0.622 |
|---|
Feature contributions
| Feature | Value | Contribution (log-odds) |
|---|---|---|
| Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code. | 130 | −3.567 |
| Indentation frequencyHow rapidly indentation changes from line to line. | 86 | +2.238 |
| Number layout frequencyHow rapidly the number of numeric values per line changes through the code. | 86 | −1.553 |
| Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom. | 128.752 | +1.39 |
| Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right. | 97.631 | +0.771 |
| 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.977 | −0.569 |
| Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *. | 0.066 | +0.296 |
Intercept 0.07 + feature contributions = -0.924 (log-odds).
Score = sigmoid(-0.924) = 0.284.
| Score | 0.575 |
|---|
| Score | 37 |
|---|
Run 1
The code is highly readable with clear logical organization: an abstract base class encapsulates shared logic, while directed and undirected variants are cleanly separated into subclasses. Nesting is minimal and control flow is straightforward. The intent of each method and field is well-documented with Javadoc and inline comments, including explanations of non-obvious decisions like the use of null in `visitedNodes` and the safety of `requireNonNull`. Code length is appropriate—concise but not overly compact. Action granularity is mostly one action per line, contributing to clarity. The reading flow is natural: fields, constructors, static factory, shared helper, then subclasses. Minor deductions: the inner `while (true)` loops and reliance on state (`node`, `successorIterator`) add slight cognitive load, and the `@Nullable` set with null `visitedNodes` is a bit unusual despite explicit comments. Overall, it is exceptionally well-structured for a graph iterator implementation.
Run 2
The code is well-structured with clear class hierarchy, logical separation of directed and undirected cases, and good documentation. Nesting is minimal—only two levels in computeNext methods. Intent is clear from method names and Javadoc. Actions are appropriately granular, with one operation per line mostly. The reading flow is natural, aided by descriptive comments and a visual example. Minor deductions: the `while (true)` loops with multiple exit points slightly obscure control flow, and the null-handling logic (e.g., clearing `visitedNodes` to null) adds some cognitive overhead despite comments. Overall, highly readable.
Run 3
The code is generally well-structured and readable. It has clear class hierarchy, meaningful names, and helpful Javadoc including a visual example for the undirected case. The state management is mostly clear. However, a few aspects hurt readability: the use of mutable fields (node, successorIterator, visitedNodes) combined with a while(true) loop in computeNext() creates a somewhat non-linear flow. The nullable fields and repeated requireNonNull() calls add cognitive overhead, requiring the reader to carefully track state invariants. The advance() method has a checkState precondition that must be understood in context. Overall, it is reasonably concise but could be clearer with more explicit state handling (e.g., encapsulating the node and successor iterator together) or less reliance on null sentinels. These issues prevent a higher score.
Run 1
Code Structure: Logical organization separates shared iteration state from directed and undirected implementations, with a small factory and reusable advance method. Nesting: Directed traversal is shallow; undirected traversal has moderate nesting through two loops and a conditional, but remains manageable. Clarity of intent: Descriptive names and comments explain duplicate suppression, self-loops, and null-safety invariants. However, adding null to visitedNodes and later clearing the set introduce non-obvious lifecycle details. Code length: Implementation is reasonably concise; the lengthy illustrative documentation adds bulk but helps explain the algorithm. Action granularity: Most lines perform one clear action, with only straightforward expressions combining operations. Reading flow: Methods and subclasses follow a natural progression, although understanding computeNext requires tracking shared mutable state and AbstractIterator lifecycle behavior.
Run 2
Code Structure: Shared traversal logic and separate directed/undirected implementations provide clear organization. Nesting: Mostly shallow, although the undirected iterator combines nested loops and a conditional. Clarity of intent: Descriptive names, invariant comments, and the worked example explain edge enumeration and duplicate prevention well; nullable state and the initial null entry in visitedNodes introduce some cognitive overhead. Code length: Implementation is concise, though the extensive example and repeated null-safety explanations lengthen the presentation. Action granularity: Statements generally perform one action per line, with straightforward state updates. Reading flow: Initialization, traversal, and termination follow a logical sequence, but understanding computeNext requires tracking shared mutable state and the AbstractIterator lifecycle. Overall, the code is highly readable with modest complexity from iterator invariants and null handling.
Run 3
Code Structure: Shared traversal logic is cleanly separated from directed and undirected implementations. Nesting: Generally shallow, although the undirected iterator combines nested loops and a conditional. Clarity of intent: Descriptive names and detailed comments explain duplicate suppression, self-loops, and null-safety invariants; nullable state and initially adding null to the visited set introduce some cognitive overhead. Code length: Implementation is concise, though the extensive example documentation lengthens the listing. Action granularity: Statements generally perform one action per line, with straightforward state updates. Reading flow: Factory, initialization, shared advancement, and specialized iteration follow a logical sequence. Understanding execution requires tracking iterator state across calls and knowing AbstractIterator's lifecycle, slightly reducing readability.