Sample
pyint-c9f1fcd5b1a3-I05
Rewrite eligible decimal integer literals in hexadecimal notation
Scores
| Method | Score | Scale |
|---|---|---|
| Posnett | 0 | 0–1; higher is more readable |
| Dorn | 0.885 | 0–1; higher is more readable |
| Mi | 0.662 | 0–1; higher is more readable |
| LLOC | 20 | Logical lines; fewer is more readable |
| DeepSeek V4 Pro | 16 | 0–20; mean of three runs |
| GPT-6.1 Sol | 17.67 | 0–20; mean of three runs |
| BTTF | 0.67 | 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. | 664.856 | −21.94 |
| Source linesThe number of non-empty source lines. | 27 | +10.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.504 | −6.755 |
Intercept 8.87 + feature contributions = -9.026 (log-odds).
Score = sigmoid(-9.026) = 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. | 73.929 | +0.534 |
| Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *. | 0.051 | +0.446 |
| Number layout frequencyHow rapidly the number of numeric values per line changes through the code. | 1 | +0.398 |
| Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right. | 74 | +0.39 |
| Indentation frequencyHow rapidly indentation changes from line to line. | 26 | +0.162 |
| Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code. | 27 | +0.08 |
| Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom. | 26.773 | −0.036 |
Intercept 0.07 + feature contributions = 2.045 (log-odds).
Score = sigmoid(2.045) = 0.885.
| Score | 0.662 |
|---|
| Score | 20 |
|---|
Run 1
The code is well-structured with clear imports and a single, focused class definition. It uses the attrs library effectively to reduce boilerplate. The _OrValidator class has a logical organization with distinct methods for call logic and representation. Nesting is minimal with only one loop and try/except block inside the __call__ method. Intent is clear: validate if any validator in a list passes. Code length is concise and appropriately sized for the functionality. Action granularity is generally good, though the try/except/else block could be slightly clearer. Reading flow is natural with a clear progression from class definition to method implementations. The main readability concerns are the single-letter variable 'v' and the dense try/except/else block in __call__, which could benefit from a helper method or more explicit control flow. Overall, this is readable code that follows common Python patterns.
Run 2
The code is well-structured and readable. It uses clear imports, a concise class definition with attrs, and a straightforward logical flow in the __call__ method. Nesting is minimal—only one loop with a try/except/else block. Intent is clear: validate that at least one validator passes. The code is concise and each line performs a single action. The reading flow is natural, moving from imports to class definition and method logic. Minor deductions could be made for the broad exception handling (BLE001) and slightly dense error message construction, but overall it is highly readable and maintainable.
Run 3
The code is generally readable with clear structure and purpose. It defines a validator class using attrs, with a straightforward __call__ method implementing OR logic. The nesting is minimal (one for loop, one try/except), and each action is on its own line. However, readability is slightly reduced by the broad exception handling with multiple noqa suppressions, which obscures the intent of catching all exceptions. The import of `operator` is unused, and the from-imports for contextmanager, Pattern, get_run_validators, set_run_validators, _AndValidator, and_, and default_if_none are not used in this snippet, adding visual noise. The f-string in the error message is clear but verbose. Overall the code is concise and logically organized, but the unused imports and permissive exception handling prevent a higher score.
Run 1
Code Structure: The class cleanly separates validation logic from representation, though several unused imports add clutter. Nesting: A loop containing try/except/else introduces moderate but manageable nesting. Clarity of intent: The class name, validators attribute, and error message clearly express OR-style validation; the short variable name v and broad exception handling slightly obscure details. Code length: The implementation is concise, with little unnecessary logic beyond the imports. Action granularity: Each line generally performs one action. Reading flow: Validation attempts, successful early return, and final failure follow a natural sequence; the noqa annotation adds minor visual noise.
Run 2
Code Structure: A small, logically organized class separates validation and representation. Nesting: The loop and try/except/else introduce moderate but manageable nesting. Clarity of intent: The class name, error message, and early return clearly express that any validator may succeed; the abbreviated name 'v' and broad exception handling slightly obscure details. Code length: The implementation is concise, although numerous unused imports distract within this snippet. Action granularity: Each line performs one clear action, with no compressed statements. Reading flow: Validation proceeds naturally from trying alternatives to reporting failure, followed by a straightforward representation method. The suppression comment adds some visual noise but does not significantly hinder readability.
Run 3
Code Structure: The class logically groups validator state, validation behavior, and representation, although several imports are unused in this snippet. Nesting: The loop and try/except/else introduce moderate nesting, but continue and return keep control flow manageable. Clarity of intent: The class name, error message, and representation clearly communicate OR-style validation; the abbreviated name v and broad exception handling slightly obscure details. Code length: The implementation is concise without unnecessary repetition. Action granularity: Each line generally performs one action, with no compressed multi-statement expressions. Reading flow: Validation proceeds naturally from trying alternatives to reporting failure, with helpful whitespace separating the failure path.