Sample
int-c55fd25596d9-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.595 | 0–1; higher is more readable |
| Dorn | 0.168 | 0–1; higher is more readable |
| Mi | 0.749 | 0–1; higher is more readable |
| LLOC | 58 | Logical lines; fewer is more readable |
| DeepSeek V4 Pro | 16.67 | 0–20; mean of three runs |
| GPT-6.1 Sol | 16.33 | 0–20; mean of three runs |
| BTTF | 0.471 | 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. | 5708.062 | −188.366 |
| Source linesThe number of non-empty source lines. | 175 | +70 |
| Byte entropyHow varied the bytes in the source text are. Repeated bytes give a lower value; a more even mixture gives a higher value. | 5.106 | −7.659 |
Intercept 8.87 + feature contributions = -117.155 (log-odds).
Score = sigmoid(-117.155) = 0.
| Score | 0.595 |
|---|
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. | 176 | −5.195 |
| Indentation frequencyHow rapidly indentation changes from line to line. | 163 | +4.901 |
| Number layout frequencyHow rapidly the number of numeric values per line changes through the code. | 164 | −3.342 |
| Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom. | 174.836 | +2.034 |
| Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right. | 108.926 | +0.953 |
| 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. | 108.977 | −0.951 |
| Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *. | 0.104 | −0.07 |
Intercept 0.07 + feature contributions = -1.6 (log-odds).
Score = sigmoid(-1.6) = 0.168.
| Score | 0.749 |
|---|
| Score | 58 |
|---|
Run 1
The ReadOnlyHttpHeaders class exhibits clear structure and intent. It extends HttpHeaders and systematically overrides mutating methods with UnsupportedOperationException, making the read-only behavior explicit. Nesting is minimal, and method lengths are concise. Action granularity is mostly one per line, with occasional ternary expressions that remain readable. The caching logic for getContentType and getAccept is straightforward. Import statements are organized but could be slightly tidied. One minor deviation occurs in the forEach method, which has an unnecessary extra block and could use a simpler iteration pattern. Overall, the code is highly readable, with clear purpose and consistent design, though the forEach implementation slightly complicates an otherwise clean flow.
Run 2
The code is highly readable, with clear structure and intent. The class is well-documented, imports are organized, and methods are logically grouped. Read-only behavior is consistently enforced via exceptions or unmodifiable wrappers, making the design obvious. Nesting is minimal—only simple if/else blocks for caching and a stream pipeline in headerSet(). Clarity of intent is strong: method names and no-op comments explain behavior. Action granularity is mostly one action per line, though stream and forEach implementations are slightly dense. Reading flow is natural, with constructors, cache getters, blocking mutators, and read-only accessors following a logical order. Minor deductions: the forEach method has unnecessary braces and a manual iterator that could be simplified, and the headerSet() stream is a bit complex. Overall, the code is concise and maintainable.
Run 3
The code is generally readable with a clear logical structure and consistent patterns. Class intent is well documented. Methods are short and mostly flat, with simple if/else caching logic. Most mutating methods are concise one-liners throwing UnsupportedOperationException, which clearly signals read-only intent. However, a few issues reduce clarity: the forEach method has an unnecessary extra brace block and uses a verbose while-loop iterator instead of a simpler for-each or stream, disrupting natural reading flow. The headerSet method uses a multi-line stream chain that is reasonably formatted but somewhat dense. Import ordering is slightly inconsistent. Overall, the code is maintainable and intentions are clear, but minor stylistic inconsistencies and verbose constructs prevent a higher score.
Run 1
Code Structure: Well-organized class with short overrides, although read methods and prohibited mutation methods are somewhat interspersed. Nesting: Mostly shallow; forEach adds an unnecessary block around its loop, and caching methods use avoidable else branches after returns. Clarity of intent: The class documentation, descriptive names, unmodifiable wrappers, and explicit exceptions clearly communicate read-only behavior. Code length: Reasonably concise given the required overrides, though repetitive exception-only methods and verbose iterator code increase length. Action granularity: Most lines perform one clear action; the stream pipeline and callback invocation combine several operations but remain understandable. Reading flow: Consistent annotations and formatting generally support easy scanning, but forEach breaks the style with irregular indentation, a fully qualified raw-looking iterator declaration, redundant parentheses, and a cast. An enhanced for-loop would improve it.
Run 2
Code Structure: The class is logically organized around cached reads, read-only views, and blocked mutations, though related methods could be grouped more consistently. Nesting: Most methods are flat; caching uses shallow branches, while forEach adds an unnecessary block around its loop. Clarity of intent: The class documentation, descriptive names, and consistent UnsupportedOperationException overrides clearly communicate its purpose. Code length: Most methods are concise; repetitive overrides are largely justified by the interface, but forEach is unnecessarily verbose. Action granularity: Statements generally perform one action each, although headerSet combines several transformations in a moderately dense stream pipeline. Reading flow: Consistent annotations and short methods support scanning, but the raw-style iterator, cast, fully qualified type, and inconsistent indentation in forEach disrupt the otherwise natural flow.
Run 3
Code Structure: The class is logically organized around cached reads, read-only views, and rejected mutations, though related methods could be grouped more consistently. Nesting: Most methods are flat; caching uses simple conditionals, while forEach adds an unnecessary block around its loop. Clarity of intent: Naming, overrides, and class documentation clearly establish the read-only purpose and caching caveat. Code length: Methods are short; repetitive mutation overrides are largely necessary, but redundant else branches and verbose iteration add avoidable length. Action granularity: Most lines perform one action, although the headerSet stream chain and forEach callback expression combine several transformations. Reading flow: Consistent method formatting supports scanning, but forEach breaks that consistency with unusual indentation, a fully qualified raw-looking iterator declaration, and an explicit cast. Overall, the code is readily understandable with localized stylistic distractions.