Sample
pyint-b92cb1b73c57-I06
Invert eligible conditions and exchange their branches
Scores
| Method | Score | Scale |
|---|---|---|
| Posnett | 0 | 0–1; higher is more readable |
| Dorn | 0.779 | 0–1; higher is more readable |
| Mi | 0.511 | 0–1; higher is more readable |
| LLOC | 18 | Logical lines; fewer is more readable |
| DeepSeek V4 Pro | 11.67 | 0–20; mean of three runs |
| GPT-6.1 Sol | 12.33 | 0–20; mean of three runs |
| BTTF | 0.522 | 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. | 675.895 | −22.305 |
| Source linesThe number of non-empty source lines. | 30 | +12 |
| 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.374 | −6.562 |
Intercept 8.87 + feature contributions = -7.996 (log-odds).
Score = sigmoid(-7.996) = 0.
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.05 | +0.458 |
| 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. | 28 | +0.231 |
| Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code. | 31 | −0.061 |
| Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom. | 29.769 | +0.006 |
Intercept 0.07 + feature contributions = 1.262 (log-odds).
Score = sigmoid(1.262) = 0.779.
| Score | 0.511 |
|---|
| Score | 18 |
|---|
Run 1
The code is hard to read due to its confusing structure and logic. The `_InstanceOfValidator.__call__` method uses an awkward `if not (not isinstance(...)): pass else:` construct instead of a simple `if not isinstance(...): raise ...`, obscuring intent. The error message is excessively long and uses f-string expressions that are hard to parse. The class includes an unnecessary docstring explaining a design choice rather than the action. The `__call__` method combines type checking and error construction with multiple actions, reducing clarity. The `__repr__` is straightforward, but the overall readability suffers from tangled conditional logic, poor action granularity, and unclear intent.
Run 2
The code is generally readable with a clear structure and intent. Imports are organized logically, and the class is well-defined with attrs. The validator's purpose is clear, and the error message is descriptive. However, the nesting and flow are slightly awkward due to the inverted condition: 'if not (not isinstance(...))' followed by 'else' is unnecessarily convoluted. A direct 'if not isinstance(value, self.type):' would improve clarity and reduce nesting. Action granularity is mostly one action per line, but the conditional structure disrupts the natural reading flow. Overall, the code is understandable but could be simplified for better readability.
Run 3
The code is generally readable but has a few notable issues. The most problematic part is the inverted conditional in `__call__`: `if not (not isinstance(value, self.type)): pass else: ...` is unnecessarily convoluted and could be simplified to `if not isinstance(value, self.type): ...`. This hurts clarity of intent. The class structure is logical and the use of `@attrs` decorator is appropriate. The nesting level is shallow (one level), which is good. The docstring provides helpful context. The error message construction and `__repr__` are readable. Overall, the code would be significantly improved by simplifying the conditional logic, but it otherwise follows good structural patterns and maintains clear separation of concerns.
Run 1
Code Structure: Imports and a small validator class are logically organized, but several imports are unused in this snippet. Nesting: Depth is shallow, although the empty success branch and else add unnecessary structure. Clarity of intent: The class name, isinstance check, and detailed error message convey the purpose, but the double negation obscures the failure condition; the docstring explains implementation rather than validation behavior. Code length: Mostly concise, but unused imports, the pass branch, and the expanded exception call add visual overhead. Action granularity: Each statement performs one clear action, with message construction separated from raising the exception. Reading flow: The class reads naturally overall, but the inverted conditional interrupts comprehension. A direct 'if not isinstance(value, self.type):' followed by the error would substantially improve readability.
Run 2
Code Structure: Imports and a small validator class are logically organized, but unused imports add clutter. Nesting: Depth is shallow, although the empty pass branch and else introduce unnecessary control flow. Clarity of intent: Class naming, isinstance, and the error message explain the validation purpose, but the double negation obscures a straightforward type check. The docstring explains the callable-class design rather than the method's validation behavior. Code length: Mostly concise, but the redundant branch and multiline exception arguments make a simple operation longer than necessary. Action granularity: Statements generally perform one action each, with message construction separated from raising the exception. Reading flow: Familiar class organization and a clear repr help, but readers must mentally simplify the condition before understanding when validation fails.
Run 3
Code Structure: The validator class is logically organized, with separate validation and representation methods, but numerous unused imports add clutter. Nesting: Nesting is shallow, although the empty pass branch and else introduce unnecessary structure. Clarity of intent: Class and method names convey the purpose, and the error message is informative; however, the double negation obscures a straightforward isinstance check, and the call-method docstring explains representation customization rather than validation. Code length: The snippet is short, but redundant branching and unused imports make it longer than necessary. Action granularity: Statements generally perform one action each, and the multiline exception construction is easy to scan. Reading flow: The overall flow is recognizable, but readers must untangle the negated condition before understanding when validation fails.