Sample
pyint-51601d82735a-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.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 | 16.67 | 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 demonstrates good readability through clear structure and logical organization. The RegexValidator class is well-organized with class attributes defined at the top and methods properly separated. Nesting is minimal with only one level in the __init__ method and no deep conditional chains. Intent is clear - this is a Django-style validator that compiles and applies regex patterns. The code length is appropriate, not overly verbose or overly compressed. Action granularity is generally good with one logical operation per line, though the __eq__ method chains multiple comparisons on single lines. Reading flow is natural - imports, class definition, attributes, initialization, validation logic, then equality comparison. The docstring in __call__ adds helpful context. Minor deductions: the repeated if-statements in __init__ could use a cleaner pattern, and the __eq__ method's line breaks could be more consistent. Variable naming like 'invalid_input' clearly expresses intent.
Run 3
The code is well-structured with clear imports, a clean class definition, and logical method organization. The constructor is flat and readable, and __call__ uses a concise two-line validation flow. The __eq__ method is also clear. Minor deductions: the constructor has five optional params and repetitive if statements, which slightly reduces conciseness; the comment in __call__ is helpful but adds length. Overall, intent is clear and the flow is natural.
Run 1
Code Structure: The class is logically organized into defaults, initialization, validation, and equality comparison. Nesting: Shallow conditionals keep execution easy to follow. Clarity of intent: Descriptive names, a useful validation docstring, and explicit error messages clearly communicate purpose; the inverse-match expression requires slight extra attention. Code length: The implementation is concise, though several imports are unused in this snippet and initialization repeats similar assignments. Action granularity: Each statement performs one clear action, with long expressions appropriately split across lines. Reading flow: Methods follow a natural progression and consistent formatting supports scanning, although additional spacing between imports and the class would improve separation.
Run 2
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 make the purpose clear; the inverse-match expression requires a little extra thought. Code length: Concise overall, with some repetitive initialization checks that remain straightforward and readable. Action granularity: Each statement performs a focused action, with multiline expressions formatted clearly. Reading flow: Methods follow a natural progression, and consistent formatting supports scanning. Minor drawbacks include the unused imports, missing separation between import groups, and unnecessary parentheses around some equality comparisons.
Run 3
Code Structure: The validator class is logically organized into defaults, initialization, validation, and equality comparison, though several unused imports add clutter. Nesting: Control flow is shallow, with straightforward conditionals and no deeply nested blocks. Clarity of intent: Descriptive names and the validation docstring clearly communicate purpose; inverse-match logic requires slight extra attention. Code length: The implementation is concise overall, although repetitive initialization checks and unused imports slightly reduce economy. Action granularity: Statements generally perform one action per line, and longer expressions are formatted cleanly across lines. Reading flow: Methods follow a natural progression, with consistent formatting and readable error handling. Minor spacing improvements between imports and the class would improve visual separation.