Sample
pyint-8c144b9b1dd8-I06
Invert eligible conditions and exchange their branches
Scores
| Method | Score | Scale |
|---|---|---|
| Posnett | 0 | 0–1; higher is more readable |
| Dorn | 0.423 | 0–1; higher is more readable |
| Mi | 0.655 | 0–1; higher is more readable |
| LLOC | 61 | Logical lines; fewer is more readable |
| DeepSeek V4 Pro | 7.33 | 0–20; mean of three runs |
| GPT-6.1 Sol | 15 | 0–20; mean of three runs |
| BTTF | 0.387 | 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. | 3088.903 | −101.934 |
| Source linesThe number of non-empty source lines. | 133 | +53.2 |
| 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.384 | −6.575 |
Intercept 8.87 + feature contributions = -46.439 (log-odds).
Score = sigmoid(-46.439) = 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. | 134 | −3.708 |
| Indentation frequencyHow rapidly indentation changes from line to line. | 103 | +2.826 |
| Number layout frequencyHow rapidly the number of numeric values per line changes through the code. | 103 | −1.943 |
| Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom. | 132.833 | +1.447 |
| Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right. | 88.851 | +0.629 |
| Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *. | 0.048 | +0.472 |
| 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. | 88.985 | −0.104 |
Intercept 0.07 + feature contributions = -0.312 (log-odds).
Score = sigmoid(-0.312) = 0.423.
| Score | 0.655 |
|---|
| Score | 61 |
|---|
Run 1
The code has clear documentation and logical class structure, but readability is severely hampered by several anti-patterns. The use of inverted conditionals like 'if not (not (user and token)): pass else: return False' is unnecessarily convoluted and should be simplified to 'if not user or not token: return False'. Similar issues appear with nested double negatives in the timestamp check. The _get_fallbacks method uses passive branching with pass statements instead of direct returns, obscuring the logic flow. While the class structure is sound and methods are well-separated, the inconsistent conditional style creates confusion. The code also violates the principle of clear intent by requiring readers to mentally simplify complex boolean expressions. Action granularity is generally acceptable, but the reading flow is disrupted by these contorted logical structures. Overall, despite good organization and documentation, the unnatural conditional patterns significantly reduce clarity.
Run 2
The code suffers from several readability issues. The use of convoluted 'if not (not (x)): pass else:' constructs instead of simple 'if not x: return False' severely obscures logic. The property getter for secret_fallbacks uses the same inverted pattern, making intent unclear. While the code is relatively flat and follows logical structure, these Pythonic violations break reading flow and add unnecessary nesting. Method lengths are reasonable, but check_token and _get_fallbacks are unnecessarily verbose for their simple logic. Action granularity is mostly good, but the inverted conditionals force readers to mentally invert conditions repeatedly. The docstrings are helpful, but the awkward control flow undermines overall readability. The code appears to be intentionally obfuscated or poorly refactored from standard Django code.
Run 3
The code suffers from severe readability issues due to bizarre conditional inversions like `if not (not (user and token)): pass else: return False` and `if not ((...)): pass else: return False`. These constructs are unnecessarily convoluted and obscure the actual logic. The `_get_fallbacks` method has similarly inverted logic. Nesting is acceptable but the unnatural boolean expressions destroy reading flow and clarity of intent. Some methods are well-documented with helpful comments, but the token-checking logic is barely comprehensible. Action granularity is mostly fine, but the unnatural conditionals force readers to mentally simplify expressions, increasing cognitive load. Code length is reasonable but wasted effort on these confusing patterns. The class structure is logical, but the overall readability is undermined by these anti-patterns.
Run 1
Code Structure: Well-organized class with focused methods separating configuration, token generation, validation, and hashing. Nesting: Mostly shallow, though redundant if/pass/else blocks add unnecessary branches. Clarity of intent: Descriptive names, docstrings, and comments explain the password-reset workflow, but double negations obscure simple conditions. Code length: Generally appropriate, with avoidable verbosity in fallback selection and validation checks. Action granularity: Most lines perform one clear action; the chained HMAC call and awkwardly split slice require extra effort to read. Reading flow: Validation follows a logical sequence from parsing to integrity checking and expiration, but pass branches and inverted conditions interrupt that flow. Overall, the code is understandable and well documented, yet simplifying conditionals and formatting would substantially improve readability.
Run 2
Code Structure: Well-organized class with focused methods separating configuration, token generation, validation, and hashing. Nesting: Mostly shallow, although unnecessary if/pass/else branches complicate otherwise simple guards. Clarity of intent: Descriptive names, docstrings, and comments explain the security logic well; double negations obscure validation conditions. Code length: Generally appropriate, but redundant branches and awkward multiline slicing add avoidable verbosity. Action granularity: Most statements perform one clear action; chained HMAC generation and slicing require slightly more effort to parse. Reading flow: Validation proceeds naturally through parsing, signature verification, and expiration checks, but inverted conditions and the less familiar for/else construct interrupt the flow.
Run 3
Code Structure: Well-organized class with focused methods separating configuration, token generation, validation, and hashing. Nesting: Generally shallow, although unnecessary if/pass/else branches add avoidable complexity; the for/else construct requires careful reading. Clarity of intent: Descriptive names, docstrings, and security-related comments explain the purpose well, but double negation and inverted conditions obscure simple checks. Code length: Mostly appropriate, with useful documentation, though redundant branches unnecessarily lengthen the implementation. Action granularity: Most lines perform one clear action; chained hashing and slicing remain understandable but have awkward formatting. Reading flow: Validation follows a logical sequence from input checks through parsing, signature verification, and expiration. However, pass branches, convoluted boolean expressions, and the split slice expression interrupt otherwise natural flow.