Sample
pyint-24ba436ab337-I06
Invert eligible conditions and exchange their branches
Scores
| Method | Score | Scale |
|---|---|---|
| Posnett | 0 | 0–1; higher is more readable |
| Dorn | 0.833 | 0–1; higher is more readable |
| Mi | 0.729 | 0–1; higher is more readable |
| LLOC | 18 | Logical lines; fewer is more readable |
| DeepSeek V4 Pro | 14 | 0–20; mean of three runs |
| GPT-6.1 Sol | 15 | 0–20; mean of three runs |
| BTTF | 0.604 | 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. | 621.528 | −20.51 |
| Source linesThe number of non-empty source lines. | 25 | +10 |
| 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.56 | −6.84 |
Intercept 8.87 + feature contributions = -8.48 (log-odds).
Score = sigmoid(-8.48) = 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.923 | +0.598 |
| Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *. | 0.051 | +0.444 |
| 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. | 26 | +0.116 |
| Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom. | 24.818 | −0.063 |
| Indentation frequencyHow rapidly indentation changes from line to line. | 23 | +0.058 |
| 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. | 86.923 | −0.016 |
Intercept 0.07 + feature contributions = 1.605 (log-odds).
Score = sigmoid(1.605) = 0.833.
| Score | 0.729 |
|---|
| Score | 18 |
|---|
Run 1
The code is generally readable with clear intent and good structure. The class has a single responsibility and uses attrs decorators effectively. However, the conditional logic in __call__ is awkward: 'if not (condition): pass else: raise' is an anti-pattern that obscures intent. A direct 'if condition: raise' would be clearer. The docstring explains the design choice well. Imports are organized, though some imports (operator, re, Pattern, get_run_validators, set_run_validators, AndValidator, and_, default_if_none, NotCallableError) appear unused in this snippet, suggesting this is part of a larger module. The __repr__ is concise. Overall, readable but could benefit from simplifying the validation logic.
Run 2
The code is reasonably structured with a clear class definition and a logical import block. The validator's purpose is evident from its name and docstring. However, readability is hurt by the inverted conditional: 'if not (len(value) > self.max_length): pass else: raise'. This is awkward and non-idiomatic compared to a direct 'if len(value) > self.max_length: raise'. The action granularity is acceptable but could be more concise. Nesting is flat, which is good, and the reading flow is natural except for the conditional inversion. Overall, the code is understandable but includes unnecessary complexity in its conditional logic and a slightly verbose error message construction.
Run 3
The code is generally readable but has a major flaw in the validator logic. The if/else structure with a pass statement in the first branch is awkward and should be inverted to check if len(value) > self.max_length and raise immediately. This unnecessary nesting and empty branch hurts clarity. The class structure is clean with clear naming, one action per line, and good intent. The frozen/slots decorators are understandable. The type hints are missing which slightly reduces clarity. The __repr__ method is clean. Overall, the code is concise but the logic flow needs inversion for better readability.
Run 1
Code Structure: The validator class is logically organized, with separate validation and representation methods, but numerous unused imports add clutter. Nesting: Nesting is shallow, though the inverted condition and empty pass branch introduce unnecessary control flow. Clarity of intent: Class and attribute names clearly convey maximum-length validation, and the error message is informative; however, the __call__ docstring explains representation design rather than validation behavior. Code length: The implementation is short but could be more concise by directly checking len(value) > self.max_length and removing unused imports. Action granularity: Each line generally performs one action, making individual operations easy to follow. Reading flow: The class reads naturally overall, but the negated comparison followed by pass and else forces readers to mentally invert the validation logic.
Run 2
Code Structure: The validator class logically groups its configuration, validation behavior, and representation, but numerous unused imports add clutter. Nesting: Shallow and easy to follow, though the empty conditional branch and else are unnecessary. Clarity of intent: Class and field names clearly communicate maximum-length validation; the negated comparison obscures an otherwise simple check, and the call-method docstring explains implementation rationale rather than validation behavior. Code length: Compact overall, but unused imports and the pass branch unnecessarily increase length. Action granularity: Each line generally performs one action, with error-message construction separated from raising the exception. Reading flow: Methods follow a natural order, but the inverted conditional interrupts the flow; directly checking whether the length exceeds the maximum would be clearer.
Run 3
Code Structure: The validator is logically organized into initialization, validation, and representation, but numerous unused imports add clutter. Nesting: Nesting is shallow, though the empty pass branch and else are unnecessary; a direct length-exceeded check would be clearer. Clarity of intent: Class and attribute names, along with the error message, communicate the purpose well. However, the negated condition adds mental overhead, and the __call__ docstring explains representation rather than validation. Code length: The class is concise, but redundant branching and imports inflate the snippet. Action granularity: Each line performs a single clear action. Reading flow: Methods follow a natural order, but the inverted condition and no-op branch interrupt otherwise straightforward reading.