Sample
pyint-4338fa678893-I05
Rewrite eligible decimal integer literals in hexadecimal notation
Scores
| Method | Score | Scale |
|---|---|---|
| Posnett | 0.001 | 0–1; higher is more readable |
| Dorn | 0.777 | 0–1; higher is more readable |
| Mi | 0.076 | 0–1; higher is more readable |
| LLOC | 17 | Logical lines; fewer is more readable |
| DeepSeek V4 Pro | 17 | 0–20; mean of three runs |
| GPT-6.1 Sol | 18 | 0–20; mean of three runs |
| BTTF | 0.538 | 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. | 635.312 | −20.965 |
| Source linesThe number of non-empty source lines. | 28 | +11.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.417 | −6.626 |
Intercept 8.87 + feature contributions = -7.521 (log-odds).
Score = sigmoid(-7.521) = 0.001.
Feature contributions
| Feature | Value | Contribution (log-odds) |
|---|---|---|
| Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right. | 103 | +0.857 |
| 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. | 103 | −0.697 |
| Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *. | 0.048 | +0.472 |
| Number layout frequencyHow rapidly the number of numeric values per line changes through the code. | 1 | +0.398 |
| Indentation frequencyHow rapidly indentation changes from line to line. | 26 | +0.162 |
| Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom. | 27.779 | −0.022 |
| Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code. | 29 | +0.01 |
Intercept 0.07 + feature contributions = 1.25 (log-odds).
Score = sigmoid(1.25) = 0.777.
| Score | 0.076 |
|---|
| Score | 17 |
|---|
Run 1
The code is highly readable with a clear, single-purpose class. It has a flat structure with minimal nesting—only a single conditional inside the __call__ method. The intent is explicit: a validator that checks if a value is an instance of a specified type, raising a descriptive TypeError otherwise. The code is concise, with no unnecessary lines. Action granularity is appropriate; each line performs one logical step, such as constructing the error message or raising the exception. Reading flow is natural, following a top-down progression from imports to class definition and methods. The use of attrs for class definition and f-strings for error messages enhances clarity. Minor deductions only because the type annotation (type = attrib()) could be more explicit, and the error message construction is slightly verbose, but overall it's clean and maintainable.
Run 2
The code is generally readable with clear intent and logical structure. It defines a validator class using attrs, with a straightforward __call__ method and a repr method. The code is flat with minimal nesting, one action per line, and a natural reading flow. However, it could be improved by simplifying the error message construction, which is spread over multiple lines and contains redundant information, making it slightly verbose. The import block includes unused imports (_AndValidator, and_, default_if_none, etc.), which adds clutter and reduces clarity. The use of a callable class is justified, but the __call__ method could be more concise. Overall, the code is readable but not exemplary due to minor verbosity and unnecessary imports.
Run 3
The code is a concise, well-structured validator class using the attrs library. Imports are minimal and clear, with unused ones (operator, re, Pattern, contextmanager) all imported—this slightly affects clarity. The class is logically organized with a clear __call__ method that performs a single validation action, and the error message is explicit. Nesting is flat, with only one conditional check. Action granularity is appropriate: each line performs a distinct action, improving readability. Reading flow is natural—validation logic, error raising, and __repr__ definition are separated cleanly. The docstring succinctly explains the design choice of using a callable class. Minor drawbacks: the function could be broken into smaller helpers for complex type-checking scenarios, and the unused imports could confuse maintainers. Overall, highly readable and maintainable.
Run 1
Code Structure: The validator class logically separates its field, validation behavior, and representation, though several imports are unused in the snippet. Nesting: A single conditional keeps control flow shallow. Clarity of intent: Descriptive names and the explicit isinstance check clearly convey type validation; the docstring explains the callable-class design rather than the method's behavior. Code length: The implementation is concise, although the multiline exception arguments add minor verbosity. Action granularity: Each statement performs one clear action, with message construction separated from raising the exception. Reading flow: Imports, class declaration, validation, and representation follow a natural sequence. The long error-message line and framework-specific decorators slightly reduce immediate readability.
Run 2
Code Structure: Imports, class configuration, validation logic, and representation are logically organized, though several imports are unused in this snippet. Nesting: A single conditional keeps the code shallow and easy to follow. Clarity of intent: The class name, isinstance check, and descriptive error message clearly communicate the validation purpose; the generic type attribute and framework-specific decorators require some context. Code length: The implementation is concise, although the multiline exception construction adds modest visual overhead. Action granularity: Each statement performs one clear action, with message construction separated from raising the exception. Reading flow: The code progresses naturally from configuration to validation and representation. The docstring explains the callable-class design rather than the method's validation behavior, slightly reducing clarity.
Run 3
Code Structure: Imports and a compact validator class are logically organized, although several imports are unused in this snippet. Nesting: Only one conditional appears, keeping control flow shallow. Clarity of intent: The class name, isinstance check, descriptive error message, and custom representation clearly communicate type validation; abbreviated parameters and the decorator's implicit behavior require some familiarity. Code length: Concise overall, though the multiline exception construction is slightly verbose. Action granularity: Each statement performs one clear action, with message construction separated from raising the exception. Reading flow: The code progresses naturally from configuration to validation and representation. The docstring explains the callable-class design rather than the method's validation behavior, which slightly weakens local documentation.