Sample
pyint-c63662bc16d1-I06
Invert eligible conditions and exchange their branches
Scores
| Method | Score | Scale |
|---|---|---|
| Posnett | 0 | 0–1; higher is more readable |
| Dorn | 0.668 | 0–1; higher is more readable |
| Mi | 0.513 | 0–1; higher is more readable |
| LLOC | 26 | Logical lines; fewer is more readable |
| DeepSeek V4 Pro | 14 | 0–20; mean of three runs |
| GPT-6.1 Sol | 15.67 | 0–20; mean of three runs |
| BTTF | 0.627 | 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. | 1711.55 | −56.481 |
| Source linesThe number of non-empty source lines. | 64 | +25.6 |
| 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.49 | −6.735 |
Intercept 8.87 + feature contributions = -28.746 (log-odds).
Score = sigmoid(-28.746) = 0.
Feature contributions
| Feature | Value | Contribution (log-odds) |
|---|---|---|
| Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code. | 64 | −1.23 |
| Indentation frequencyHow rapidly indentation changes from line to line. | 55 | +1.165 |
| Number layout frequencyHow rapidly the number of numeric values per line changes through the code. | 55 | −0.841 |
| Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right. | 84.954 | +0.566 |
| Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom. | 63.93 | +0.484 |
| Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *. | 0.054 | +0.418 |
| 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. | 84.938 | +0.068 |
Intercept 0.07 + feature contributions = 0.7 (log-odds).
Score = sigmoid(0.7) = 0.668.
| Score | 0.513 |
|---|
| Score | 26 |
|---|
Run 1
The code is generally clear with sensible docstrings and comments, and the class hierarchy is logical. However, readability is undermined by an awkward conditional with a no-op branch ('if not (...) pass else raise') which should be inverted, and by the get_object method doing multiple tasks (parsing date, checking future, filtering, delegating). The date lookup construction is concise but obscures the actual filter logic. Nesting is acceptable and imports are well-structured.
Run 2
The code is generally well-organized with clear imports, docstrings, and a logical flow. Structure is decent: it follows Django class-based view patterns and separates date parsing, queryset filtering, and future-date validation. However, readability suffers in a few places. The conditional 'if not (not self.get_allow_future() and date > datetime.date.today()): pass else: raise...' is a double negative that obscures intent and violates clarity of intent and action granularity. It should be rewritten as a simple positive check. The inline template string for the 404 message is verbose and hard to scan. Nesting is shallow, and line lengths are mostly reasonable. Variable names like 'qs' are conventional but slightly terse. Overall, the code is understandable for experienced Django developers but could be more concise and direct in its conditional logic.
Run 3
The code is reasonably structured but has readability issues that prevent a higher score. The conditional logic using `if not (not self.get_allow_future() and date > datetime.date.today()): pass else: raise Http404` is unnecessarily convoluted and violates clarity of intent. A simple `if not allow_future and date > today: raise Http404` would be far clearer. The nesting is minimal and flat, which is good, and actions are mostly one per line. However, the double negative in the conditional hurts reading flow, and the `pass` statement adds noise. The method is concise but could be improved with early returns and clearer boolean logic. The docstring helps clarify purpose, but the implementation doesn't match that clarity. Overall, the code structure is sound, but the confusing conditional pattern and unnecessary negation make it harder to read than it should be.
Run 1
Code Structure: The method is logically organized into date extraction, queryset selection, validation, filtering, and retrieval. Nesting: Mostly flat, with only one conditional, although its empty pass branch is unnecessary. Clarity of intent: Descriptive method names, a helpful docstring, and comments explain the purpose, but the double-negative future-date condition obscures otherwise simple validation. Code length: Reasonably concise; removing the pass/else construction would shorten and clarify it. Action granularity: Statements generally perform one action each, and multiline calls and mappings are formatted clearly. Reading flow: The sequence is natural, but the inverted conditional interrupts comprehension. Mixins and the date-parsing helper are not defined in the snippet, requiring external context.
Run 2
Code Structure: The class and method are logically organized around parsing a date, validating it, filtering a queryset, and retrieving an object. Nesting: Mostly flat, with only a shallow conditional. Clarity of intent: Descriptive method names, a docstring, and comments explain the purpose, but the double-negated future-date condition and empty pass branch obscure straightforward validation. External mixins and helpers require context. Code length: The method is reasonably concise, though the conditional could be simplified and several imports appear unused in this snippet. Action granularity: Statements generally perform one action each, and multiline arguments and error formatting are legible. Reading flow: The sequence is natural, but the inverted if/else interrupts it; directly raising when future dates are disallowed would improve readability.
Run 3
Code Structure: The method is logically organized into date extraction, queryset selection, future-date validation, filtering, and object retrieval. Nesting: Mostly flat, with only one conditional, although its empty pass branch is unnecessary. Clarity of intent: Descriptive method names, a class docstring, and comments explain the purpose well; the double-negative condition obscures the future-date restriction. Code length: Generally concise, but the pass/else construction and several imports unused in this snippet add clutter. Action granularity: Each statement performs a distinct action, and multiline calls and dictionary formatting remain readable. Reading flow: Execution follows a natural sequence, but the inverted conditional interrupts comprehension. Referenced mixins and helper functions are not shown, requiring external context.