Sample
int-e29cbd022aab-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 |
| Dorn | 0.107 | 0–1; higher is more readable |
| Mi | 0.183 | 0–1; higher is more readable |
| LLOC | 27 | Logical lines; fewer is more readable |
| DeepSeek V4 Pro | 11 | 0–20; mean of three runs |
| GPT-6.1 Sol | 15 | 0–20; mean of three runs |
| BTTF | 0.582 | 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. | 1869.045 | −61.679 |
| Source linesThe number of non-empty source lines. | 62 | +24.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.642 | −6.963 |
Intercept 8.87 + feature contributions = -34.972 (log-odds).
Score = sigmoid(-34.972) = 0.
Feature contributions
| Feature | Value | Contribution (log-odds) |
|---|---|---|
| Indentation frequencyHow rapidly indentation changes from line to line. | 62 | +1.407 |
| Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code. | 63 | −1.194 |
| 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. | 112.968 | −1.12 |
| Number layout frequencyHow rapidly the number of numeric values per line changes through the code. | 62 | −1.002 |
| Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right. | 0 | −0.804 |
| Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom. | 61.789 | +0.454 |
| Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *. | 0.09 | +0.068 |
Intercept 0.07 + feature contributions = -2.121 (log-odds).
Score = sigmoid(-2.121) = 0.107.
| Score | 0.183 |
|---|
| Score | 27 |
|---|
Run 1
The code has clear enum constants and simple operations, but readability is significantly undermined by convoluted constructs. The static block uses an unnecessary nested block and a manual while-loop instead of a standard for-each, adding noise. The findBySubProtocol method similarly uses a manual loop with an extra block wrapper, obscuring intent. Several unnecessary blank lines and inconsistent formatting (misaligned braces) break reading flow. While method lengths are short and actions somewhat granular, the manual array iteration and redundant blocks violate clarity and length criteria, making the code feel artificially verbose and harder to scan than it should be.
Run 2
The code structure is logical and the enum itself is clear. However, readability is significantly hurt by the manually unrolled for-each loops in the static initializer and findBySubProtocol method. These introduce unnecessary nesting (extra braces), multiple actions within loop headers, and disrupt the natural reading flow. Replacing these with standard for-each loops would make the code much cleaner and more concise. The static block could even be replaced with a stream. Naming is generally good, but the loopArray and loopIndex variables are awkward and lower the clarity of intent.
Run 3
The code is logically organized but suffers from several readability issues. The enum constants and methods are clear, but the static initializer and findBySubProtocol method use awkward manual loop constructs instead of standard for-each loops. The unnecessary nested blocks and verbose array iteration logic make simple operations harder to follow. Long lines, inconsistent spacing, and lack of blank lines between members reduce readability. While the intent is understandable and the class is concise, the non-idiomatic Java loop patterns disrupt natural reading flow and create unnecessary nesting. Action granularity is mostly one per line, but the loop boilerplate obscures the simple logic of collecting sub-protocols or finding a match. Overall, the code would be much more readable with standard Java idioms, consistent formatting, and removal of redundant braces/indentation.
Run 1
Code Structure: The enum is logically organized into constants, initialization, fields, constructor, accessors, and lookup. Nesting: Unnecessary scoped blocks and a null-check enclosing a loop and conditional create avoidable nesting. Clarity of intent: Names and straightforward methods clearly convey version-to-subprotocol mapping, although generic loop variables add noise. Code length: Explicit arrays, indices, and while loops are unnecessarily verbose compared with enhanced for loops. Action granularity: Most lines perform one action, but array access combined with index increment slightly reduces clarity. Reading flow: The overall sequence is natural, but redundant blocks and inconsistent indentation interrupt it. The code remains understandable, with its main readability weaknesses concentrated in the two loops.
Run 2
Code Structure: The enum logically groups protocol constants, initialization, fields, accessors, and lookup behavior. Nesting: Redundant blocks and a null check enclosing a while loop and conditional introduce unnecessary depth. Clarity of intent: Descriptive names make protocol mapping and lookup clear, although mechanical loop variables distract. Code length: Mostly concise, but explicit arrays, counters, and while loops are unnecessarily verbose compared with enhanced for loops. Action granularity: Most lines perform one action; incrementing the index inside array access combines iteration advancement with element retrieval. Reading flow: The overall sequence is natural, but redundant braces, inconsistent indentation, and expanded loops interrupt otherwise straightforward reading.
Run 3
Code Structure: The enum logically groups constants, initialization, fields, accessors, and lookup behavior, though redundant blocks clutter the loops. Nesting: The initializer has unnecessary nesting, and the lookup combines a null check, extra block, loop, and conditional. Clarity of intent: Descriptive names make version mapping and protocol lookup clear; generic loop variables add distracting mechanics. Code length: Manual array traversal and index management are unnecessarily verbose compared with enhanced for-loops. Action granularity: Most lines perform one action, but indexing with post-increment combines retrieval and index mutation. Reading flow: Declaration order is natural and methods are straightforward, but inconsistent indentation and redundant braces interrupt scanning.