Sample
pyint-60965bca0178-I11
Split eligible integer literals into pairs of short-named intermediate variables
Scores
| Method | Score | Scale |
|---|---|---|
| Posnett | 0 | 0–1; higher is more readable |
| Dorn | 0.869 | 0–1; higher is more readable |
| Mi | 0.375 | 0–1; higher is more readable |
| LLOC | 40 | 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.463 | 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. | 2118.047 | −69.896 |
| Source linesThe number of non-empty source lines. | 60 | +24 |
| 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.381 | −6.571 |
Intercept 8.87 + feature contributions = -43.596 (log-odds).
Score = sigmoid(-43.596) = 0.
Feature contributions
| Feature | Value | Contribution (log-odds) |
|---|---|---|
| Indentation frequencyHow rapidly indentation changes from line to line. | 57 | +1.234 |
| Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code. | 61 | −1.123 |
| Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right. | 88 | +0.615 |
| Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom. | 59.854 | +0.427 |
| Number layout frequencyHow rapidly the number of numeric values per line changes through the code. | 1 | +0.398 |
| Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *. | 0.063 | +0.332 |
| 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. | 88 | −0.062 |
Intercept 0.07 + feature contributions = 1.891 (log-odds).
Score = sigmoid(1.891) = 0.869.
| Score | 0.375 |
|---|
| Score | 40 |
|---|
Run 1
The code is generally well-structured with clear intent, flat nesting, and good action granularity. Each validation step is separated logically. However, minor issues prevent a higher score: variable names like 'invalid_input' are slightly ambiguous, and the __init__ method uses repetitive conditional assignments that could be simplified. The docstring helps clarify purpose, and line length is reasonable. Overall, it maintains good readability patterns with only minor opportunities for improvement.
Run 2
The code is well-structured and readable. It follows a clear class-based approach with logical organization of attributes and methods. The RegexValidator class has clear intent - validating input against regex patterns with customizable options. Nesting is minimal with only one if-block in __call__. Action granularity is appropriate, with one main action per line. The reading flow is natural, progressing from initialization to validation. The __init__ method is slightly verbose with repetitive None checks, but clear. Type checking in __eq__ is well-implemented. The docstring effectively explains the inverse_match behavior. However, the code could be more concise in __init__ using conditional assignments, and the __eq__ method's multi-line boolean comparison, while readable, could benefit from helper methods for complex conditions.
Run 3
The code is well-structured, with clear class and method organization. Nesting is minimal, with only one conditional inside __call__. Intent is clear—this is a Django-style regex validator with explicit parameters and docstring. Code length is appropriate for its functionality. Action granularity is mostly one action per line, though some lines in __eq__ and __call__ could be split for even greater clarity. Reading flow is natural, from class definition to initialization, then validation logic, then equality comparison. Imports are all used and logically grouped. The use of lazy regex compilation and type checking is clear and purposeful. Overall, highly readable and maintainable.
Run 1
Code Structure: The class is logically organized into defaults, initialization, validation, and equality comparison. Nesting: Shallow conditionals and no nested loops make control flow easy to follow. Clarity of intent: Descriptive names, a validation docstring, and a clear error message communicate purpose; the inverse-match expression requires slight extra attention. Code length: The implementation is concise, though repetitive initialization checks and unused imports add minor clutter. Action granularity: Statements generally perform one action per line, with multiline formatting used appropriately for longer expressions. Reading flow: Methods follow a natural progression, and consistent formatting supports scanning. Minor drawbacks include limited import grouping and redundant parentheses in equality comparisons.
Run 2
Code Structure: The validator is logically organized into defaults, initialization, validation, and equality comparison, although several imports are unused in this snippet. Nesting: Control flow is shallow, with straightforward conditionals and no deeply nested blocks. Clarity of intent: Descriptive names and the validation docstring make the purpose clear; the inverse-match expression requires slight extra attention. Code length: The implementation is concise overall, though initialization repeats similar assignments and equality checks include unnecessary parentheses. Action granularity: Statements generally perform one action each, and multiline expressions improve scanning. Reading flow: Methods follow a natural lifecycle, formatting is consistent, and validation proceeds predictably. Minor import clutter and the lack of a blank line separating imports from the decorated class slightly reduce readability.
Run 3
Code Structure: The class is logically organized into defaults, initialization, validation, and equality comparison, though several imports are unused in this snippet. Nesting: Shallow conditionals keep control flow easy to follow. Clarity of intent: Descriptive names and the validation docstring clearly explain behavior; the inverse-match expression requires slight extra attention. Code length: Concise overall, with some repetitive but straightforward initialization checks. Action granularity: Each statement performs a distinct action, and multiline expressions are formatted cleanly. Reading flow: Methods follow a natural sequence, with consistent indentation and spacing. Minor distractions include redundant parentheses in equality comparisons and unused imports.