Sample
pyint-8a66c1dd6dc3-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.775 | 0–1; higher is more readable |
| Mi | 0.377 | 0–1; higher is more readable |
| LLOC | 18 | Logical lines; fewer is more readable |
| DeepSeek V4 Pro | 12 | 0–20; mean of three runs |
| GPT-6.1 Sol | 17.33 | 0–20; mean of three runs |
| BTTF | 0.449 | 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. | 712.555 | −23.514 |
| Source linesThe number of non-empty source lines. | 24 | +9.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.726 | −7.088 |
Intercept 8.87 + feature contributions = -12.133 (log-odds).
Score = sigmoid(-12.133) = 0.
Feature contributions
| Feature | Value | Contribution (log-odds) |
|---|---|---|
| Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right. | 76.48 | +0.43 |
| 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. | 76.92 | +0.407 |
| Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *. | 0.064 | +0.319 |
| Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code. | 25 | +0.151 |
| Number layout frequencyHow rapidly the number of numeric values per line changes through the code. | 22 | −0.084 |
| Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom. | 23.795 | −0.077 |
| Indentation frequencyHow rapidly indentation changes from line to line. | 22 | +0.024 |
Intercept 0.07 + feature contributions = 1.239 (log-odds).
Score = sigmoid(1.239) = 0.775.
| Score | 0.377 |
|---|
| Score | 18 |
|---|
Run 1
The code is highly readable. It has clear imports, a single class with two small methods, and flat logic. The purpose is explicit: detect dictionaries and serialize them with tagged values. The comment clarifies a design decision about key handling. Variable names are concise and appropriate. Each method performs one logical action per line. The overall flow is natural and easy to follow.
Run 2
The code is moderately readable but incomplete as presented. The class `PassDict` inherits from `JSONTag`, which is not imported in the snippet, and `self.serializer` is referenced without definition. The structure is logical and flat, with clear intent: it serializes dictionary values by tagging each one. Nesting is minimal, and each line performs a single action, aiding readability. The `check` method clearly identifies dict instances, and `to_json` has an explanatory comment. However, the alias `tag = to_json` is slightly redundant but acceptable. The code is concise; however, the missing imports and undefined references create ambiguity. If the surrounding context defines `JSONTag` and `serializer`, readability would improve to around 17. Overall, the snippet shows good practices—flat structure, clear naming, and concise actions—but the incomplete context prevents a higher score.
Run 3
The code is syntactically incomplete and severely undermines readability. It attempts to define a class `PassDict` that inherits from `JSONTag`, but `JSONTag` is never imported, leaving the base class undefined. This breaks the code's functionality and obscures its intent. The method names (`check`, `to_json`, `tag`) are reasonably clear, and the logic within `to_json` is concise, iterating over dictionary items to tag values. However, the lack of an import for `JSONTag` introduces ambiguity about the class's role and relationships. The imports at the top include several unused modules (e.g., `b64decode`, `UUID`, `Markup`), which clutters the file and distracts from the core logic. Additionally, the `tag = to_json` assignment is redundant unless the base class defines `tag` differently, but without the base class definition, this intent is unclear. Overall, the code's structural incompleteness and unnecessary imports make it difficult to read and understand as presented.
Run 1
Code Structure: The class is logically organized into a type check, conversion method, and alias, though several imports are unused in this snippet. Nesting: Minimal nesting and a simple comprehension keep complexity low. Clarity of intent: Method names and the comment clearly explain dictionary handling, but the undefined JSONTag base class and external serializer require surrounding context; the tag alias is slightly less explicit than a method. Code length: The implementation is concise without unnecessary logic, although the import list adds clutter. Action granularity: Each statement performs one clear action, with the comprehension expressing a cohesive transformation. Reading flow: Imports followed by the class and short methods provide a natural progression; additional spacing between import groups and the class would improve presentation.
Run 2
Code Structure: The class logically groups type checking and serialization, although numerous unused imports and the unexplained JSONTag base class add clutter. Nesting: Methods are flat, with only a straightforward dictionary comprehension. Clarity of intent: Descriptive method names and the comment explain dictionary serialization, but the tag alias and serializer dependency require surrounding context. Code length: The implementation is concise; the import block is disproportionately long for the shown functionality. Action granularity: Each statement performs a single clear action, and the comprehension expresses one cohesive transformation. Reading flow: The class reads naturally from validation to conversion to aliasing, though limited spacing between imports and the class slightly weakens visual organization.
Run 3
Code Structure: The class is logically organized into a type check, conversion method, and alias, though numerous unused imports distract from the small implementation. Nesting: The code is flat, with only a straightforward dictionary comprehension. Clarity of intent: Method names, type annotations, and the comment make dictionary handling understandable, but JSONTag is not defined or imported in the snippet, and the purpose of aliasing tag to to_json requires contextual knowledge. Code length: The class is concise, although the import block is disproportionately long. Action granularity: Each line generally performs one clear action; the comprehension compactly expresses a single transformation. Reading flow: The methods follow a natural sequence, but limited spacing between imports and the class slightly reduces visual separation.