Sample
pyint-75e0d005c1b1-I12
Inline all eligible single-use intermediate local variables
Scores
| Method | Score | Scale |
|---|---|---|
| Posnett | 0 | 0–1; higher is more readable |
| Dorn | 0.873 | 0–1; higher is more readable |
| Mi | 0.502 | 0–1; higher is more readable |
| LLOC | 41 | Logical lines; fewer is more readable |
| DeepSeek V4 Pro | 17 | 0–20; mean of three runs |
| GPT-6.1 Sol | 17 | 0–20; mean of three runs |
| BTTF | 0.564 | 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. | 2303.37 | −76.011 |
| Source linesThe number of non-empty source lines. | 67 | +26.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.54 | −6.809 |
Intercept 8.87 + feature contributions = -47.151 (log-odds).
Score = sigmoid(-47.151) = 0.
Feature contributions
| Feature | Value | Contribution (log-odds) |
|---|---|---|
| Indentation frequencyHow rapidly indentation changes from line to line. | 62 | +1.407 |
| Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code. | 68 | −1.371 |
| Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right. | 87.971 | +0.615 |
| Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom. | 66.944 | +0.526 |
| Number layout frequencyHow rapidly the number of numeric values per line changes through the code. | 1 | +0.398 |
| Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *. | 0.061 | +0.345 |
| 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. | 87.985 | −0.061 |
Intercept 0.07 + feature contributions = 1.928 (log-odds).
Score = sigmoid(1.928) = 0.873.
| Score | 0.502 |
|---|
| Score | 41 |
|---|
Run 1
The code is well-structured with clear logical organization: imports are grouped logically, the class has a clear docstring, and methods are concise. Nesting is minimal, with only one level in the constructor and clean method. Intent is clear throughout—the field validates values against a parent instance. Code length is appropriate with no unnecessary verbosity. Action granularity is mostly one action per line, though some lines like chained getattr calls in the clean method could be considered slightly dense but remain readable. Reading flow is natural, with straightforward method ordering and intuitive variable naming. Minor deductions for the parent_instance arguments potentially hurting reusability, but overall this is Django-quality readable code.
Run 2
The code is well-structured with clear separation between imports, class definition, and methods. Imports are logically grouped by source. The class has a clear docstring and concise error messages. Nesting is minimal, with only a couple of single-level conditionals. Intent is clear: this field validates inline foreign key relationships. Code length is appropriate for the functionality, with no unnecessary verbosity. Action granularity is mostly one action per line, improving readability. Reading flow is natural, with __init__ followed by clean and has_changed, which mirrors typical Django form field behavior. Minor points: the conditional block in __init__ could be slightly simplified, and the comment 'ensure we compare the values as equal types' is helpful but slightly informal. Overall, very readable code that follows Django conventions well.
Run 3
The code is highly readable with clear structure and intent. Imports are well-organized, grouped logically, and follow standard Django conventions. The class has a clear docstring explaining its purpose. Methods are concise, each performing a single responsibility. Nesting is minimal—only one level of conditional logic in `clean()` and `__init__()`. Variable names are descriptive (`parent_instance`, `pk_field`, `to_field`). Comments explain non-obvious behavior without being excessive. The code avoids unnecessary complexity and maintains a natural reading flow. Minor deductions: the `clean()` method could be slightly flatter, and some conditional branches could use helper methods if the logic grew, but at this length it remains clear.
Run 1
Code Structure: The class is logically organized into initialization, validation, and change detection, although many imports are unused in this snippet. Nesting: Conditional nesting is shallow and manageable; early returns simplify validation. Clarity of intent: Descriptive class and method names, a docstring, and comments explain the parent-instance validation. However, 'orig' is vague, the integer-field description contrasts with string-based comparison, and the unconditional has_changed() result lacks explanation. Code length: The class is concise, but the extensive import block adds unnecessary reading overhead for the provided code. Action granularity: Each statement performs a single clear action, with no compressed multi-action lines. Reading flow: Initialization naturally precedes validation and change detection, and formatting makes branches easy to follow. Minor naming and documentation issues prevent a higher score.
Run 2
Code Structure: The class is logically organized into initialization, validation, and change detection, although many imports are unused in this snippet. Nesting: Conditional nesting is shallow and manageable, with early returns simplifying validation. Clarity of intent: Descriptive names, a docstring, and comments explain the parent-instance relationship; however, the integer-field description is slightly misleading, and always returning False from has_changed lacks explanation. Code length: Methods are concise, though repeated parent-key lookup logic and excessive imports add some overhead. Action granularity: Each statement performs a single clear action, and multiline calls improve readability. Reading flow: Initialization naturally precedes validation and change detection; consistent formatting supports easy scanning, while the large import block delays reaching the relevant logic.
Run 3
Code Structure: The class is logically organized into initialization, validation, and change detection, although many imports are unused in this snippet. Nesting: Branching is shallow and manageable, with early returns simplifying validation. Clarity of intent: Descriptive names, a docstring, and explicit error handling communicate the purpose well; however, the docstring calls this an integer field while validation compares strings, and the unconditional has_changed() result lacks explanation. Code length: Methods are concise, though unused imports add clutter and parent-field lookup logic is repeated. Action granularity: Statements generally perform one action per line, with readable formatting for longer expressions. Reading flow: Initialization naturally precedes validation and change detection; straightforward conditionals make execution easy to follow, although the vague backward-compatibility comment provides little useful context.