Sample
pyint-072687f2fa88-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.019 | 0–1; higher is more readable |
| Mi | 0.802 | 0–1; higher is more readable |
| LLOC | 200 | Logical lines; fewer is more readable |
| DeepSeek V4 Pro | 7 | 0–20; mean of three runs |
| GPT-6.1 Sol | 14.33 | 0–20; mean of three runs |
| BTTF | 0.409 | 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. | 16612.231 | −548.204 |
| Source linesThe number of non-empty source lines. | 476 | +190.4 |
| 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.192 | −6.288 |
Intercept 8.87 + feature contributions = -355.221 (log-odds).
Score = sigmoid(-355.221) = 0.
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. | 477 | −15.853 |
| Indentation frequencyHow rapidly indentation changes from line to line. | 433 | +14.24 |
| Number layout frequencyHow rapidly the number of numeric values per line changes through the code. | 433 | −9.515 |
| Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom. | 475.935 | +6.243 |
| Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right. | 90.539 | +0.656 |
| Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *. | 0.055 | +0.408 |
| 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. | 90.973 | −0.188 |
Intercept 0.07 + feature contributions = -3.939 (log-odds).
Score = sigmoid(-3.939) = 0.019.
| Score | 0.802 |
|---|
| Score | 200 |
|---|
Run 1
This code has severe readability issues. While it maintains a logical class structure and the methods are well-documented with docstrings, the critical failures are in control flow and action granularity. The authors replaced standard Python `for` loops with inline `__import__('builtins')` calls and explicit while-true loops with try-except blocks for iteration. This makes otherwise simple iteration patterns unnecessarily complex and obtuse. The violations of standard Python idioms (DRY, readability) appear throughout _check_to_fields_exist, _check_to_fields_composite_pk, and resolve_related_fields. The action granularity is poor - importing `builtins` dynamically, calling `.next()`, and catching StopIteration all happen on single dense lines. The code has good method organization and logical naming, but the manual iteration makes it harder to follow than necessary. The code length is verbose due to the convoluted loop constructs. Fixing these would move the score to 15+.
Run 2
The code is largely unreadable due to bizarre, artificial constructs like replacing standard for loops with manual iterator manipulation using __import__('builtins').next(). This severely obscures intent and violates Python conventions. The imports are excessive and disorganized, making it hard to understand dependencies. Methods are excessively long, especially _check_unique_target and deconstruct, mixing multiple actions and nested conditionals. The class lacks coherent grouping; related methods are scattered. While some docstrings exist, the overall structure, unnatural flow, and unnecessary complexity make it challenging to follow. The code feels deliberately obfuscated rather than a natural implementation, earning a very low readability score despite being syntactically valid.
Run 3
The code has moderate structure with clear class organization and docstrings, but readability is severely compromised by bizarre anti-patterns. The manual while-loop iteration using __import__('builtins').next() instead of standard for-loops in _check_to_fields_exist, _check_to_fields_composite_pk, and resolve_related_fields is extremely unusual and confusing. There is heavy nesting in _check_unique_target with multiple conditions and nested any() calls. Some methods like get_instance_value_for_fields are clear, but methods like _check_unique_target are ambiguous. The file is quite long with many imports and properties, though Django-style structure helps slightly. Action granularity is mixed—some lines are concise while others contain multiple operations. The reading flow is disrupted by the unnatural loop constructs and dense conditional logic in validation methods.
Run 1
Code Structure: Well organized into focused methods, with validation, field resolution, and relationship metadata clearly separated. Nesting: Mostly moderate, but validation and deconstruction contain several nested branches; manual iterator loops add avoidable try/except nesting. Clarity of intent: Descriptive method names, comments, and docstrings explain framework-specific behavior, although generic iterator names and repeated dynamic builtins imports obscure ordinary iteration. Code length: Most methods are appropriately concise, but expanded while/next/StopIteration loops unnecessarily lengthen code that simple for loops would express clearly. Action granularity: Statements generally perform one action each, and multiline calls are consistently formatted. Reading flow: Related methods are grouped naturally, with early returns and cached properties aiding navigation; verbose iteration machinery and complex uniqueness expressions interrupt the flow. Numerous imports unused in this excerpt and missing definitions for the base class and relationship constant also reduce standalone readability.
Run 2
Code Structure: Well-organized class with focused methods separating validation, field resolution, metadata, and descriptor setup, although the extensive imports add clutter. Nesting: Mostly moderate, with guard clauses reducing depth; validation and deconstruction contain some nested branches. Clarity of intent: Descriptive method names, comments, and docstrings explain most responsibilities, but framework-specific internals and identifiers absent from this snippet require external context. Code length: Most methods are appropriately sized, but manually expanded iterator loops using dynamic builtins imports are unnecessarily verbose compared with ordinary for loops. Action granularity: Statements generally perform one action each, and multiline calls are consistently formatted. Reading flow: Related methods are grouped naturally, but repeated while/try/except iteration scaffolding interrupts the flow and obscures straightforward traversal. Overall, the readable organization and documentation are undermined primarily by artificial loop complexity and some dense validation expressions.
Run 3
Code Structure: Well organized into focused methods, with validation, field resolution, and relationship metadata clearly separated. Nesting: Generally moderate, but validation and deconstruction contain several nested branches; manual iterator loops add unnecessary try/except nesting. Clarity of intent: Descriptive method names, comments, and docstrings explain most operations, though framework-specific internals require Django knowledge and some referenced names are absent from the snippet. Code length: Mostly justified by functionality, but repeated __import__("builtins") calls and explicit next()/StopIteration handling are unnecessarily verbose compared with ordinary for loops. Action granularity: Statements generally perform one action each, and multiline expressions are formatted consistently. Reading flow: Method grouping and early returns support natural reading, but the unusual iterator machinery, generic iterator names, extensive imports, and occasional dense constraint expressions interrupt the flow.