Sample
pyint-0b47332e20fc-I13
Lower every eligible synchronous for loop to a while loop
Scores
| Method | Score | Scale |
|---|---|---|
| Posnett | 0 | 0–1; higher is more readable |
| Dorn | 0.921 | 0–1; higher is more readable |
| Mi | 0.444 | 0–1; higher is more readable |
| LLOC | 80 | Logical lines; fewer is more readable |
| DeepSeek V4 Pro | 4.33 | 0–20; mean of three runs |
| GPT-6.1 Sol | 11 | 0–20; mean of three runs |
| BTTF | 0.423 | 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. | 4447.792 | −146.777 |
| Source linesThe number of non-empty source lines. | 109 | +43.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.33 | −6.495 |
Intercept 8.87 + feature contributions = -100.802 (log-odds).
Score = sigmoid(-100.802) = 0.
Feature contributions
| Feature | Value | Contribution (log-odds) |
|---|---|---|
| Indentation frequencyHow rapidly indentation changes from line to line. | 107 | +2.964 |
| Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code. | 110 | −2.858 |
| Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom. | 108.782 | +1.111 |
| Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right. | 85.855 | +0.581 |
| Number layout frequencyHow rapidly the number of numeric values per line changes through the code. | 1 | +0.398 |
| Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *. | 0.08 | +0.162 |
| 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. | 85.955 | +0.025 |
Intercept 0.07 + feature contributions = 2.451 (log-odds).
Score = sigmoid(2.451) = 0.921.
| Score | 0.444 |
|---|
| Score | 80 |
|---|
Run 1
The code structure has some logical separation (explained vs fast paths, loader iteration), but it is severely undermined by bizarre, unidiomatic Python constructs. The manual while/next/except StopIteration loops using __import__('builtins') are extremely unreadable, obscure intent, and should be simple for loops. The repeated use of __import__('builtins') adds needless noise and confusion. Nesting is moderate but the artificial loop patterns worsen cognitive load. Clarity of intent is damaged: the variable names (trv, rv, srcobj) are short, and the control flow is convoluted. Code length is unnecessarily inflated due to the repeated manual iteration boilerplate. Action granularity is inconsistent; multiple operations are sometimes crammed into comprehensions or try blocks. Reading flow is very poor, as the reader must mentally decompile the transformed loops back into normal Python. While the broad purpose (dispatching Jinja template lookups) is discernible, the implementation choices make it nearly unreadable.
Run 2
The code has a clear purpose and some structure, but readability suffers greatly due to manually emulated iteration using __import__('builtins').iter/next and while loops instead of native for loops. This creates unnecessary nesting, verbosity, and obscures intent. The _get_source_explained method mixes multiple concerns (routing, error handling, logging) and uses confusing variable names (rv, trv). While type hints and docstrings help, the unnatural reading flow and redundant patterns (e.g., repeated StopIteration handling) make the code harder to follow than necessary. Concise refactoring with for loops and clearer state handling would significantly improve readability.
Run 3
The code is severely unreadable due to several major issues. The most glaring problem is the bizarre use of __import__('builtins').iter() and .next() instead of simple for loops, which obscures the intent and adds massive noise. This creates deep nesting and breaks natural reading flow. While the class structure and type hints show some organization, the implementation is unnecessarily verbose and convoluted. Actions are split across multiple lines where a single for loop would suffice, violating action granularity. The _get_source_explained and _get_source_fast methods duplicate logic with confusing variable names like loopIteratorA, loopIteratorB, loopIteratorC, and loopIteratorD. The core intent—searching app and blueprint loaders for templates—is buried under layers of obfuscated iteration. Basic Python idioms are completely bypassed, making the code nearly incomprehensible despite the straightforward task it performs. Only the docstring and method names provide any clarity.
Run 1
Code Structure: Methods logically separate loader discovery, fast lookup, diagnostic lookup, and template listing. Nesting: Explicit while/try/except iterator machinery adds unnecessary nesting, especially in list_templates. Clarity of intent: Method names, the docstring, and type hints help, but rv, trv, and arbitrary loopIterator suffixes obscure meaning; unused imports add noise. Code length: Repeated manual iteration and dynamic builtins imports substantially inflate code that ordinary for loops could express concisely. Action granularity: Most lines perform one action, although dynamic import expressions complicate simple operations. Reading flow: Method organization is natural, but repeated StopIteration handling interrupts the core template-loading logic. Overall, the design is understandable, but unnecessarily elaborate iteration significantly reduces readability.
Run 2
Code Structure: Methods logically separate loader dispatch, diagnostics, iteration, and template listing, though repetitive iteration machinery adds clutter. Nesting: Moderate overall, but list_templates introduces unnecessary nested while and try/except blocks. Clarity of intent: Descriptive method names, a class docstring, and type annotations explain the purpose; cryptic rv/trv variables and generic loopIterator names weaken clarity. Code length: Explicit iter/next/StopIteration handling and repeated __import__("builtins") calls are substantially longer than ordinary for loops; result.update could replace the innermost listing loop. Action granularity: Most lines perform one action, although dynamic imports embedded in iteration expressions make individual lines harder to parse. Reading flow: Method ordering and early returns are sensible, but mechanical loop scaffolding repeatedly interrupts the core template-loading logic.
Run 3
Code Structure: Methods logically separate loader dispatch, diagnostics, iteration, and template listing. Nesting: Repeated while/try/except blocks introduce unnecessary depth, especially in list_templates. Clarity of intent: Descriptive method names, the class docstring, and type annotations help, but rv, trv, and arbitrary iterator suffixes obscure meaning. Code length: Manual iteration and repeated dynamic builtins imports substantially inflate code that ordinary for loops could express concisely. Action granularity: Statements generally perform one action per line, although dynamic imports embedded in iterator operations add visual complexity. Reading flow: The overall method sequence is coherent, but repetitive StopIteration handling interrupts the domain logic; long tuple annotations and a mid-method import also slow scanning.