Sample
pyint-e8ea6259daac-SRC
Unmodified source class
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 | 14.33 | 0–20; mean of three runs |
| GPT-6.1 Sol | 17.33 | 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 and readable. The imports are organized logically with standard library, Django core, forms, and utils grouped separately. The class has a clear docstring explaining its purpose, and methods are concise with descriptive names. Nesting is minimal, with only a couple of if-else branches that remain flat and easy to follow. Clarity of intent is strong: variable names like parent_instance, pk_field, and to_field are self-explanatory, and error messages are explicit. Code length is appropriate—no unnecessary verbosity. Action granularity is generally one action per line, though a few lines combine operations (e.g., kwargs['initial'] = getattr(...)), which slightly reduces readability. Reading flow is natural, moving from initialization to validation to change detection. Minor deductions for some inline assignments and slightly dense if-else logic in clean(), but overall it's clean, maintainable code.
Run 2
The code has clear imports and class structure, but readability is reduced by several factors. The __init__ method contains multiple nested conditionals (if parent_instance is not None -> if to_field -> else) with kwargs mutation, making intent harder to follow. Action granularity is mixed: some lines combine multiple operations (e.g., kwargs with getattr in one line), while others are clean. The clean method has scattered logic: empty value handling, type comparison, field resolution, and validation all in one method without helper methods. Comments are sparse and don't clarify complex branching. Reading flow is interrupted by conditional blocks and string conversions that lack explanation. The class docstring is helpful but doesn't compensate for the method-level complexity. Overall, the code is maintainable but requires careful reading to understand the nested validation logic and kwarg manipulation.
Run 3
The code is generally well-structured and readable. It follows a logical organization with clear imports and a single class definition. The class methods are concise and maintain a flat nesting structure, mostly limiting indentation to two levels. Intent is clear from the docstring and method names, and action granularity is reasonable, with one major operation per line. The reading flow is natural. Minor deductions come from the `clean` method's inline comments and conditional blocks, which slightly interrupt flow, and the `__init__` method could be slightly more concise, but overall this is solid, maintainable code.
Run 1
Code Structure: The class is logically organized into initialization, validation, and change detection, though many imports are unused in this excerpt. Nesting: Conditional nesting is shallow and manageable, with early returns simplifying validation. Clarity of intent: Descriptive method names, a docstring, and comments explain the field's purpose; abbreviations such as 'pk' and 'orig' require some context, and the always-false has_changed() lacks explanation. Code length: The class is concise, but the extensive import block adds unnecessary reading overhead for the code shown. Action granularity: Statements generally perform one action per line, and multiline calls are cleanly formatted. Reading flow: Initialization naturally precedes validation and change detection, with consistent formatting and straightforward branching.
Run 2
Code Structure: The class is logically organized into initialization, validation, and change detection, with configuration defined upfront. Nesting: Conditional nesting is shallow and easy to follow; early returns simplify validation. Clarity of intent: Descriptive names, a class docstring, and comments clearly explain parent-instance validation, although the comment about acting 'as we did before' is vague. Code length: Methods are concise, but many imports are unused in the provided snippet and add clutter. Action granularity: Statements generally perform one action per line, with readable multiline formatting. Reading flow: Initialization naturally precedes validation and change detection, and validation proceeds from empty-value handling to comparison and return. Minor drawbacks include abbreviated 'orig' and the unexplained unconditional False in has_changed.
Run 3
Code Structure: The class is logically organized into initialization, validation, and change detection, although numerous unused imports clutter the snippet. Nesting: Conditional nesting is shallow and manageable, with early returns simplifying validation. Clarity of intent: The class docstring, descriptive attributes, and explicit validation error make its purpose clear; the variable name 'orig' and the comment referring to prior behavior are less informative. Code length: Methods are concise, but the import section is disproportionately long for the functionality shown. Action granularity: Statements generally perform one action per line, and multiline calls are formatted clearly. Reading flow: Initialization naturally precedes validation and change detection, with consistent formatting. The unconditional False return in has_changed is easy to read but would benefit from a brief explanation of why changes are intentionally ignored.