Sample
pyint-abf79745baba-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.828 | 0–1; higher is more readable |
| Mi | 0.182 | 0–1; higher is more readable |
| LLOC | 20 | Logical lines; fewer is more readable |
| DeepSeek V4 Pro | 15 | 0–20; mean of three runs |
| GPT-6.1 Sol | 18 | 0–20; mean of three runs |
| BTTF | 0.528 | 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. | 1252.248 | −41.324 |
| Source linesThe number of non-empty source lines. | 32 | +12.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.732 | −7.098 |
Intercept 8.87 + feature contributions = -26.752 (log-odds).
Score = sigmoid(-26.752) = 0.
Feature contributions
| Feature | Value | Contribution (log-odds) |
|---|---|---|
| Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right. | 85 | +0.567 |
| Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *. | 0.052 | +0.435 |
| Number layout frequencyHow rapidly the number of numeric values per line changes through the code. | 1 | +0.398 |
| Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code. | 33 | −0.132 |
| Indentation frequencyHow rapidly indentation changes from line to line. | 25 | +0.128 |
| 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. | 84.939 | +0.068 |
| Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom. | 31.837 | +0.035 |
Intercept 0.07 + feature contributions = 1.569 (log-odds).
Score = sigmoid(1.569) = 0.828.
| Score | 0.182 |
|---|
| Score | 20 |
|---|
Run 1
The code is moderately readable. Structure is logical with a clear single-method class. Nesting is shallow with only one try/except block, and action granularity is mostly one action per line. However, the intent is somewhat obscured by domain-specific Django/MySQL knowledge and a dense explanatory comment. Variable names like 'result' and 'params' are generic, and the mixed string formatting styles (%s and f-strings) slightly disrupt flow. The conditional logic requires understanding of SQL compiler internals, making it less accessible to non-specialists.
Run 2
The code is moderately readable. It has a clear structure with a single class and method, and the logic is sequential. However, the intent of the override is somewhat obscured by a long explanatory comment and the conditional logic. The nesting is shallow (one if, one try/except), which is good. Action granularity is mostly one action per line, though the list-building and string formatting add slight density. The code is concise overall. The main readability drawbacks are the domain-specific complexity of the SQL compilation logic and the need for background knowledge about Django's compiler internals, which makes the purpose less immediately clear to a general reader.
Run 3
The code is generally readable with clear logical structure and purpose. The comment explains why the custom implementation exists, which aids intent. Nesting is shallow (one if-else block), and action granularity is reasonable, though some lines combine multiple operations. Variable names like `where_sql`, `where_params`, and `from_sql` are descriptive. However, the string formatting using `%` and the manual list assembly slightly reduce clarity. The `try/except FullResultSet` block is a bit abrupt without accompanying explanation, and the conditional logic around when to fall back to `super().as_sql()` could be clearer. Overall, the code is concise and follows a natural reading flow, but minor improvements in formatting and inline comments would enhance readability.
Run 1
Code Structure: A single focused method follows a logical sequence: check compatibility, build SQL, compile filtering, and return SQL with parameters. Nesting: Minimal nesting and an early return keep control flow flat; the try/except/else is straightforward. Clarity of intent: Descriptive names and useful comments explain both the optimization and its limitations, though Django compiler internals require domain knowledge. Code length: Concise for its responsibilities, with comments adding necessary context rather than redundancy. Action granularity: Statements generally perform one action each; SQL formatting expressions remain manageable. Reading flow: Execution proceeds naturally from setup to output. Minor readability drawbacks include imports unused within this snippet, the silent FullResultSet exception handling, and limited visual separation between imports and the class.
Run 2
Code Structure: A single focused method follows a logical sequence: inspect query constraints, select a fallback, construct SQL, and return parameters. Nesting: Shallow conditionals and a try/except/else keep complexity low; the early return avoids additional nesting. Clarity of intent: Descriptive names and useful comments explain both the optimization and its limitations, though Django compiler knowledge is needed to understand the details. Code length: Concise for its functionality, with comments proportionate to the non-obvious behavior. Action granularity: Statements generally perform one action each; tuple unpacking naturally groups related outputs. Reading flow: SQL construction proceeds naturally from DELETE through FROM to WHERE. Minor readability drawbacks include unused imports in this snippet, limited spacing before the class declaration, and the implicit meaning of the empty FullResultSet handler.
Run 3
Code Structure: The method is logically organized into eligibility checking, SQL construction, optional filtering, and return. Nesting: An early return keeps the flow flat, with only a shallow try/except/else block. Clarity of intent: Descriptive names and comments explain both the database optimization and fallback conditions, though Django compiler internals require domain knowledge. Code length: The implementation is concise; comments are substantial but justify non-obvious behavior. Action granularity: Each statement generally performs one action, and tuple unpacking naturally groups related results. Reading flow: Execution proceeds naturally from validation to assembly, although the silent FullResultSet handler and SQL fragment construction require some interpretation.