Sample
pyint-ff4a7ca07b91-I06
Invert eligible conditions and exchange their branches
Scores
| Method | Score | Scale |
|---|---|---|
| Posnett | 0 | 0–1; higher is more readable |
| Dorn | 0.863 | 0–1; higher is more readable |
| Mi | 0.326 | 0–1; higher is more readable |
| LLOC | 17 | Logical lines; fewer is more readable |
| DeepSeek V4 Pro | 13.33 | 0–20; mean of three runs |
| GPT-6.1 Sol | 12.67 | 0–20; mean of three runs |
| BTTF | 0.596 | 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. | 752.443 | −24.831 |
| Source linesThe number of non-empty source lines. | 31 | +12.4 |
| 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.241 | −6.362 |
Intercept 8.87 + feature contributions = -9.922 (log-odds).
Score = sigmoid(-9.922) = 0.
Feature contributions
| Feature | Value | Contribution (log-odds) |
|---|---|---|
| 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. | 70.969 | +0.659 |
| Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *. | 0.054 | +0.42 |
| 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. | 29 | +0.266 |
| Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right. | 55.969 | +0.099 |
| Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code. | 32 | −0.097 |
| Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom. | 30.889 | +0.022 |
Intercept 0.07 + feature contributions = 1.837 (log-odds).
Score = sigmoid(1.837) = 0.863.
| Score | 0.326 |
|---|
| Score | 17 |
|---|
Run 1
The code is generally clear and well-structured, with a logical import order and a single class definition. The validator class uses attrs decorators appropriately. The main readability issue is the awkward boolean logic: `if not (not callable(value))` is convoluted and should be `if callable(value)`. This creates an unnecessary nest with `else` handling the actual error case. The error message construction is clear but could be slightly more concise. The `__call__` method is reasonably flat, with only one conditional level. Overall, the code is readable and maintainable, but the double negative and inverted conditional structure reduce clarity.
Run 2
The code is generally readable, but a few issues reduce clarity. The if/else conditional is unnecessarily convoluted: `if not (not callable(value)): pass` is an awkward double negative and empty branch, making the intent harder to grasp. The validator's purpose is clear, but the structure could be simpler and more direct with a single `if not callable(value): raise ...`. Nesting is shallow and overall organization is logical, but the conditional snarl and slightly verbose message formatting reduce the reading flow and clarity of intent. Action granularity is reasonable, but the extra pass and inverted condition add unnecessary noise.
Run 3
The code has some positives but also notable readability issues. The structure is mostly logical, but the validator's __call__ method contains a confusing conditional: 'if not (not callable(value)): pass else: raise...' which is a double negative that obscures intent. This should be simplified to 'if not callable(value): raise...' for clarity. The error message construction is unnecessarily split across multiple lines with awkward formatting. The class decorator and imports are reasonable. Nesting is minimal, which is good. Action granularity is mostly one action per line, though the conditional logic makes the flow harder to follow than needed. The code's purpose is clear from context, and the length is appropriate, but the convoluted condition and message formatting reduce readability. Overall, this is functional but could be significantly improved with straightforward refactoring.
Run 1
Code Structure: The validator class cleanly separates validation from its representation, but numerous unused imports add clutter. Nesting: Nesting is modest, yet an unnecessary if/pass/else structure makes the validation harder to follow. Clarity of intent: Class and method names, the docstring, and the detailed exception communicate purpose, but the double negation obscures the callable check. Code length: The snippet is short, though unused imports and the redundant success branch make it longer than necessary. Action granularity: Statements generally perform one action per line, and the multiline exception construction is readable. Reading flow: Formatting is consistent and the error message flows naturally, but the inverted condition interrupts comprehension; a direct 'if not callable(value)' would substantially improve readability.
Run 2
Code Structure: The validator class logically separates validation and representation, but numerous unused imports add clutter. Nesting: The conditional and nested error construction are modest, though the pass/else branch adds unnecessary depth. Clarity of intent: Class naming and the error message communicate the purpose, but the double negation in `if not (not callable(value))` obscures a simple callable check. Code length: The implementation is short, yet could be simplified to `if not callable(value):` followed by the error construction. Action granularity: Statements generally perform one action per line, and multiline formatting makes the exception arguments easy to scan. Reading flow: The overall flow is coherent, but the redundant condition and empty success branch interrupt direct reading.
Run 3
Code Structure: The callable validator and its representation are logically separated into methods, but numerous unused imports add clutter. Nesting: Nesting is shallow overall, although the unnecessary if/pass/else structure adds avoidable indentation. Clarity of intent: Class naming and the descriptive error message communicate the purpose, but the double negation in the callable check obscures a simple condition. Code length: The implementation is short, yet unused imports and the empty success branch make it longer than necessary. Action granularity: Statements generally perform one action per line; multiline formatting keeps error construction readable. Reading flow: The flow is mostly coherent, but the inverted condition and pass branch interrupt the natural progression from checking invalid input to raising an exception. A direct 'if not callable(value)' would substantially improve readability.