Sample
pyint-a166e64d8882-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.831 | 0–1; higher is more readable |
| Mi | 0.261 | 0–1; higher is more readable |
| LLOC | 17 | Logical lines; fewer is more readable |
| DeepSeek V4 Pro | 16.33 | 0–20; mean of three runs |
| GPT-6.1 Sol | 18 | 0–20; mean of three runs |
| BTTF | 0.621 | 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. | 578.587 | −19.093 |
| Source linesThe number of non-empty source lines. | 23 | +9.2 |
| 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.597 | −6.895 |
Intercept 8.87 + feature contributions = -7.918 (log-odds).
Score = sigmoid(-7.918) = 0.
Feature contributions
| Feature | Value | Contribution (log-odds) |
|---|---|---|
| Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right. | 86.917 | +0.598 |
| Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *. | 0.05 | +0.46 |
| 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. | 24 | +0.187 |
| Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom. | 22.784 | −0.091 |
| 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. | 86.958 | −0.018 |
| Indentation frequencyHow rapidly indentation changes from line to line. | 21 | −0.011 |
Intercept 0.07 + feature contributions = 1.592 (log-odds).
Score = sigmoid(1.592) = 0.831.
| Score | 0.261 |
|---|
| Score | 17 |
|---|
Run 1
The code is well-structured with clear separation of imports, class definition, and methods. It uses a frozen and slotted attrs class, which makes intent explicit and prevents runtime mutation. Nesting is minimal—only a single if-statements inside the __call__ method. The purpose is obvious from the class name and docstring. The __repr__ improves debugging. The only minor issue is that the __call__ method could have type hints for clarity, and the docstring is a bit redundant but acceptable. Overall, it is concise, readable, and follows idiomatic Python practices, earning a high readability score.
Run 2
The code is generally clear and well-structured. It uses a frozen attrs class for a validator, which is logical. The method is short, flat, and has a clear purpose. However, readability is slightly reduced by the unnecessary import block (operator, re, Pattern, contextmanager, get_run_validators, set_run_validators, _AndValidator, and_, default_if_none, NotCallableError) that is not used in this snippet, creating ambiguity about dependencies. The __call__ method mixes validation logic and error message construction, but it remains concise. The docstring is brief and clarifies why a callable class is used. Overall, the core logic is readable, but the extraneous imports and minor mixing of concerns prevent a higher score.
Run 3
The code is generally clear and well-structured. It uses a frozen attrs class for a validator, which makes intent clear and the logic concise. The __call__ method has a single level of nesting, and the error message is informative. The __repr__ method improves debuggability. However, readability is slightly reduced by unused imports (operator, re, Pattern, contextmanager, etc.) which are unnecessary noise, and the docstring inside __call__ could be moved to the class level for clarity. Overall, the code is readable but could be cleaner by removing dead imports and relocating the docstring.
Run 1
Code Structure: The validator is logically organized into configuration, validation, and representation methods, though numerous unused imports distract from the snippet. Nesting: A single conditional keeps control flow shallow. Clarity of intent: Descriptive names and a clear error message make the minimum-length check obvious; the __call__ docstring explains the callable-class design rather than the method's behavior. Code length: The implementation is concise, with little unnecessary code beyond unused imports. Action granularity: Each statement performs one clear action, and message construction is separated from raising the exception. Reading flow: The class reads naturally from its minimum-length field through validation to representation, although a blank line separating standard-library and local imports would improve visual organization.
Run 2
Code Structure: The validator is logically organized into configuration, validation, and representation methods, although several unused imports add clutter. Nesting: A single conditional keeps the code flat and easy to follow. Clarity of intent: Descriptive class and field names, a straightforward length check, and a clear error message communicate the purpose well; the __call__ docstring explains the callable-class design rather than the method's behavior. Code length: The implementation is concise, with little unnecessary code beyond the unused imports. Action granularity: Each line performs one clear action. Reading flow: The progression from minimum-length configuration to validation and representation is natural, though additional spacing between imports and the class would improve presentation.
Run 3
Code Structure: The validator is logically organized into configuration, validation, and representation methods, though numerous unused imports add clutter. Nesting: A single conditional keeps the code flat and easy to follow. Clarity of intent: Descriptive class and attribute names, a direct length check, and an informative error message clearly communicate the purpose. The callable-method docstring explains the class design rather than the method's validation behavior. Code length: The implementation is concise, with little unnecessary code beyond the imports. Action granularity: Each statement performs one clear action. Reading flow: The progression from minimum-length configuration to validation and representation is natural; additional spacing between imports and the class would improve visual separation.