Sample
pyint-39056a917315-I06
Invert eligible conditions and exchange their branches
Scores
| Method | Score | Scale |
|---|---|---|
| Posnett | 0 | 0–1; higher is more readable |
| Dorn | 0.373 | 0–1; higher is more readable |
| Mi | 0.64 | 0–1; higher is more readable |
| LLOC | 18 | Logical lines; fewer is more readable |
| DeepSeek V4 Pro | 10.67 | 0–20; mean of three runs |
| GPT-6.1 Sol | 14 | 0–20; mean of three runs |
| BTTF | 0.603 | 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. | 1048.107 | −34.588 |
| Source linesThe number of non-empty source lines. | 37 | +14.8 |
| 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.693 | −7.04 |
Intercept 8.87 + feature contributions = -17.957 (log-odds).
Score = sigmoid(-17.957) = 0.
Feature contributions
| Feature | Value | Contribution (log-odds) |
|---|---|---|
| Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right. | 0 | −0.804 |
| Indentation frequencyHow rapidly indentation changes from line to line. | 37 | +0.543 |
| Number layout frequencyHow rapidly the number of numeric values per line changes through the code. | 37 | −0.428 |
| Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code. | 38 | −0.309 |
| Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *. | 0.081 | +0.155 |
| 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. | 83 | +0.15 |
| Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom. | 36.845 | +0.105 |
Intercept 0.07 + feature contributions = -0.519 (log-odds).
Score = sigmoid(-0.519) = 0.373.
| Score | 0.64 |
|---|
| Score | 18 |
|---|
Run 1
The code is moderately readable. The imports are organized alphabetically, and the class structure is clear with a straightforward inheritance and a single overridden method. However, the `process_rhs` method contains a confusing conditional: `if not (params): pass else: ...` could be simplified to `if params:` and the action placed inside. This adds unnecessary nesting and reduces clarity of intent. The variable `params` is reassigned inside the else block, which can obscure data flow. The code length is concise, but the action granularity is uneven—multiple operations occur in a single line within the else branch (preparing `params` and unpacking). Reading flow is adequate but could be improved by flattening the conditional and using clearer variable names or comments for the query preparation logic.
Run 2
The code has a clear structure with organized imports and a single class definition, which aids readability. The nesting is minimal, and the intent of the lookup class is straightforward. However, the method `process_rhs` contains an unnecessary and confusing `if not (params): pass else:` block, which adds needless length and ambiguity. The action granularity is generally one action per line, but the conditional logic breaks the reading flow. Overall, the code is readable but could be improved by simplifying the conditional expression.
Run 3
The code is a mix of imports and a single class definition, which is somewhat readable, but several issues lower its score. The imports are numerous and include unused likely modules (e.g., math, itertools, Case, When, Field, DateTimeField). The class definition is straightforward, but the method process_rhs contains an awkward conditional structure: the empty 'pass' branch is unnecessary and confusing. The else branch packs tuple construction and a method call with multiple indexing operations into one line, reducing action granularity and making the flow harder to follow. The reading flow is interrupted by unclear intent—why is the first parameter being modified? There is also no docstring or comment explaining the purpose of this custom lookup. Overall, the structure is not tangled, but the clarity of intent suffers from poor conditional logic, long compound expressions, and lack of documentation.
Run 1
1. Code Structure: The lookup class and method are logically organized, but numerous unused imports distract from the small implementation, and BuiltinLookup is not defined or imported in the snippet. 2. Nesting: Nesting is shallow, though the empty if branch and else add unnecessary structure. 3. Clarity of intent: The class name, lookup_name, and preparation call convey the purpose; qn and rhs require framework familiarity. 4. Code length: The method is concise, but the import block is disproportionate and the conditional could simply be 'if params:'. 5. Action granularity: Each statement performs a distinct action; the tuple assignment compactly prepares the first parameter while preserving the rest. 6. Reading flow: Processing, conditional preparation, and returning results form a natural sequence, interrupted slightly by redundant parentheses and the pass branch.
Run 2
Code Structure: The lookup class and method are logically organized, although numerous unused imports distract from the small implementation. Nesting: Shallow, but an empty if branch followed by else adds avoidable complexity. Clarity of intent: The class name, lookup_name, and preparation call communicate the purpose; qn and rhs require framework familiarity. Code length: The method is short, but imports and the pass branch make the snippet unnecessarily long. Action granularity: Each line performs a focused operation, with the tuple reconstruction remaining reasonably readable. Reading flow: Processing, optional parameter transformation, and returning results follow a natural sequence, but replacing 'if not (params): pass; else:' with 'if params:' would improve flow.
Run 3
Code Structure: The class and method are logically organized, but numerous unused imports clutter this small snippet, and BuiltinLookup is not defined or imported here. Nesting: Shallow, although the empty if branch and else introduce unnecessary control flow. Clarity of intent: The lookup name and preparation method convey purpose, but qn and rhs require Django familiarity; 'if not (params): pass' obscures a simple nonempty-parameters check. Code length: The method is concise, but the import block is disproportionate to the functionality shown. Action granularity: Each line performs one clear operation, with tuple reconstruction expressed compactly. Reading flow: Processing, conditional parameter preparation, and returning results follow a natural sequence, interrupted slightly by the redundant pass branch.