Sample
pyint-05d4d72b5dfa-I10
Deterministically remove some optional blank lines and bracketed line breaks
Scores
| Method | Score | Scale |
|---|---|---|
| Posnett | 0 | 0–1; higher is more readable |
| Dorn | 0.829 | 0–1; higher is more readable |
| Mi | 0.254 | 0–1; higher is more readable |
| LLOC | 17 | Logical lines; fewer is more readable |
| DeepSeek V4 Pro | 16.67 | 0–20; mean of three runs |
| GPT-6.1 Sol | 17.67 | 0–20; mean of three runs |
| BTTF | 0.616 | 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. | 22 | +8.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.609 | −6.913 |
Intercept 8.87 + feature contributions = -8.336 (log-odds).
Score = sigmoid(-8.336) = 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.913 | +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. | 23 | +0.222 |
| Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom. | 21.773 | −0.105 |
| Indentation frequencyHow rapidly indentation changes from line to line. | 20 | −0.045 |
| 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. | 87 | −0.02 |
Intercept 0.07 + feature contributions = 1.577 (log-odds).
Score = sigmoid(1.577) = 0.829.
| Score | 0.254 |
|---|
| Score | 17 |
|---|
Run 1
The code is well-structured and readable. It uses a frozen, slotted attrs class, which clearly signals immutability and performance intent. The validator follows a single-responsibility pattern: one class, one validation rule. Nesting is minimal—only one level inside the __call__ method. Intent is clear from the class name, attribute name, and docstring explaining the use of a callable class for repr customization. Line length is concise, and each statement occupies its own line. The reading flow is natural: imports, class definition, validation logic, then repr. Minor deductions: the docstring inside __call__ is somewhat buried, and the conditional could benefit from a blank line before raising the error for visual separation. Overall, maintainable and idiomatic for attrs-based validators.
Run 2
The code is generally readable with clear intent and logical structure. It defines a single validator class using the attrs library, with a clear purpose and concise implementation. The nesting is minimal (one conditional), and each line performs a single action, contributing to good granularity. The reading flow is natural: import statements, class definition, method implementations. The docstring explains the design choice for using a callable class. Minor deductions include the unused imports (operator, re, Pattern, contextmanager, etc.) which add clutter and could confuse readers about dependencies, and the slightly redundant f-string in the error message (could use the max_length variable directly). Overall, it is a clean, well-structured snippet with only small areas for improvement.
Run 3
The code is well-structured and highly readable. It uses clear imports, a frozen slots-based attrs class, and a single-purpose validator with a concise method. Nesting is minimal (one if statement), intent is explicit through naming and type hints are implicit via attrs. The __repr__ method aids debugging. Length is appropriate for the functionality—no unnecessary verbosity. Each action is on its own line, and the reading flow follows a natural top-down order: class definition, callable logic, then repr. The only minor deduction is the docstring placed inside __call__ rather than at class level, slightly interrupting flow, and the unused imports (operator, re, Pattern, contextmanager, etc.) which could confuse readers about dependencies.
Run 1
Code Structure: The small validator class logically groups configuration, validation, and representation, although numerous unused imports add clutter. Nesting: A single conditional keeps nesting shallow. Clarity of intent: Descriptive class and attribute names, a straightforward length check, and an informative error message make the purpose clear; the __call__ docstring explains implementation rationale rather than validation behavior. Code length: The implementation is concise, but unused imports and repeated len(value) slightly reduce economy. Action granularity: Each statement performs one clear action, and message construction is separated from raising the exception. Reading flow: Execution reads naturally from the length check to the error, though missing blank lines between imports and the class, and between the attribute and method, weaken visual separation.
Run 2
Code Structure: The validator is logically organized into state, validation, and representation methods, though several imports are unused in this snippet. Nesting: A single conditional keeps the code flat and easy to follow. Clarity of intent: Descriptive class and attribute names, a straightforward length check, and an informative error message clearly communicate the purpose; the docstring explains the callable-class design rather than validation behavior. Code length: The implementation is concise, with little unnecessary code beyond the unused imports. Action granularity: Each line generally performs one clear action. Reading flow: Imports followed by the class and its methods form a natural sequence, although additional blank lines around the class and before __call__ would improve visual separation.
Run 3
Code Structure: The validator is logically organized into configuration, validation, and representation methods, though several imports are unused in this snippet. Nesting: A single conditional keeps the code flat and easy to follow. Clarity of intent: Descriptive names and the error message clearly communicate the maximum-length constraint; the docstring explains the callable-class design rather than validation behavior. Code length: The implementation is concise, with only minor redundancy from calling len(value) twice. Action granularity: Each line performs one clear action. Reading flow: The sequence is natural, although additional blank lines between imports, the class, its attribute, and methods would improve visual separation.