Sample
pyint-30be819b3f32-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.791 | 0–1; higher is more readable |
| Mi | 0.329 | 0–1; higher is more readable |
| LLOC | 26 | Logical lines; fewer is more readable |
| DeepSeek V4 Pro | 6 | 0–20; mean of three runs |
| GPT-6.1 Sol | 10 | 0–20; mean of three runs |
| BTTF | 0.663 | 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. | 977.364 | −32.253 |
| Source linesThe number of non-empty source lines. | 45 | +18 |
| 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.6 | −6.9 |
Intercept 8.87 + feature contributions = -12.283 (log-odds).
Score = sigmoid(-12.283) = 0.
Feature contributions
| Feature | Value | Contribution (log-odds) |
|---|---|---|
| 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. | 67.913 | +0.789 |
| Indentation frequencyHow rapidly indentation changes from line to line. | 43 | +0.75 |
| Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code. | 46 | −0.592 |
| Number layout frequencyHow rapidly the number of numeric values per line changes through the code. | 43 | −0.566 |
| Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *. | 0.059 | +0.372 |
| Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right. | 68 | +0.293 |
| Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom. | 44.884 | +0.218 |
Intercept 0.07 + feature contributions = 1.334 (log-odds).
Score = sigmoid(1.334) = 0.791.
| Score | 0.329 |
|---|
| Score | 26 |
|---|
Run 1
The code has significant readability issues. The import section is overly verbose with unused imports (abc, enum, linecache, sys, types, unicodedata, etc.) cluttering the namespace. The _AndValidator class shows poor implementation choices - using __import__('builtins') repeatedly instead of direct language constructs is obfuscated and unnecessarily complex. The loop structure for iterating validators is convoluted; a simple for loop would be clearer. The class decorator and _validators attribute reference functions not shown in the snippet, creating ambiguity about their origin and purpose. Type hints are inconsistently applied. The code appears to be from the attrs library but the implementation deviates from clean Python practices, making it harder to understand than necessary. While the class docstring is helpful, the method body undermines clarity with its indirect builtins access and manual iterator management.
Run 2
The code has a reasonable top-level structure with imports and a class definition, but several issues hurt readability. The presence of `__import__("builtins")` calls inside `__call__` is highly unusual and breaks reading flow, creating confusion about intent. The manual `while True: try/except StopIteration` loop is unnecessarily verbose when a simple `for` loop would be clearer. The class uses `@attrs` and `attrib()` decorators but those are not imported in the visible snippet, causing ambiguity. Action granularity is mostly okay but the loop could be one line. Nesting is shallow, which is good, but the unnatural iteration pattern undermines clarity of intent. The code is concise overall, but the chosen implementation obscures what should be a simple validation delegation loop.
Run 3
The code is quite unreadable due to several major issues. First, it is incomplete and missing key definitions like `attrs` and `attrib` that are referenced but never imported or defined. The `__call__` method uses a bizarre manual iteration pattern with direct `__import__('builtins')` calls instead of using normal Python constructs like `for v in self._validators:` or importing `iter`/`next` properly. This creates unnecessary complexity and obscures the simple intent of sequentially applying validators. The imports are excessive and disorganized, mixing unused stdlib modules (`abc`, `contextlib`, `enum`, etc.) with partially-used third-party imports. The class itself is well-named but the implementation detracts from clarity. The lack of type annotations on the `__call__` method reduces readability. The structure has unnecessary nesting in the try/except loop. Overall, the author appears to be working against Python conventions rather than with them, making the code significantly harder to understand than necessary.
Run 1
Code Structure: The class is logically organized, but the large import block is mostly unrelated to the shown functionality. Nesting: The while/try/except structure adds unnecessary nesting compared with a simple for loop. Clarity of intent: The class name, docstring, and validator invocation clearly express composition, although attrs and attrib are not defined or imported in the snippet. Code length: Iteration is unnecessarily verbose, and unused imports increase visual clutter. Action granularity: Each line generally performs one action, which helps readability. Reading flow: The class itself flows naturally from documentation to state to behavior, but repeated dynamic builtins imports and manual StopIteration handling interrupt straightforward reading.
Run 2
Code Structure: The validator class is logically organized, but the large, unrelated import block distracts from the small implementation. Nesting: The while/try/except structure introduces unnecessary nesting compared with a simple for loop. Clarity of intent: The class name and docstring clearly explain validator composition, but repeated dynamic builtins imports obscure ordinary iteration, and attrs/attrib are not defined in the excerpt. Code length: Manual iterator management makes a straightforward operation unnecessarily long. Action granularity: Most lines perform one action, although dynamic imports combine lookup and invocation in individual expressions. Reading flow: Class layout is conventional, but exception-driven iteration and the inconsistent loopIterator naming interrupt an otherwise simple flow.
Run 3
Code Structure: The validator is organized into a small class, but the large, mostly unrelated import block distracts from its purpose. Nesting: The while/try/except structure adds unnecessary nesting to straightforward iteration. Clarity of intent: The class name, docstring, and validator call communicate the purpose, although loopIterator and v are less descriptive than validators and validator. Code length: The method is unnecessarily long; a simple for loop would express the same behavior more clearly. Action granularity: Statements generally perform one action per line, but repeated dynamic builtins imports complicate individual expressions. Reading flow: Explicit iterator creation, exception-driven termination, and repeated __import__ calls interrupt the natural flow of applying each validator. The unexplained attrs and attrib names also require outside context.