Sample
pyint-18953b4eca5f-I12
Inline all eligible single-use intermediate local variables
Scores
| Method | Score | Scale |
|---|---|---|
| Posnett | 0 | 0–1; higher is more readable |
| Dorn | 0.58 | 0–1; higher is more readable |
| Mi | 0.443 | 0–1; higher is more readable |
| LLOC | 17 | Logical lines; fewer is more readable |
| DeepSeek V4 Pro | 17 | 0–20; mean of three runs |
| GPT-6.1 Sol | 18 | 0–20; mean of three runs |
| BTTF | 0.743 | 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. | 901.892 | −29.762 |
| Source linesThe number of non-empty source lines. | 24 | +9.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.562 | −6.843 |
Intercept 8.87 + feature contributions = -18.136 (log-odds).
Score = sigmoid(-18.136) = 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 |
| 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.058 | +0.383 |
| Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code. | 25 | +0.151 |
| 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 | +0.107 |
| Indentation frequencyHow rapidly indentation changes from line to line. | 24 | +0.093 |
| Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom. | 23.906 | −0.076 |
Intercept 0.07 + feature contributions = 0.322 (log-odds).
Score = sigmoid(0.322) = 0.58.
| Score | 0.443 |
|---|
| Score | 17 |
|---|
Run 1
The code demonstrates good readability. Structure is logical: imports are grouped, and the class has a clear purpose. Nesting is minimal—only one nested call inside `get_by_natural_key`, which is necessary and clearly formatted. Intent is clear: the manager retrieves a permission by its natural key components. Code length is concise; no extra methods or comments are needed. Action granularity is appropriate: one meaningful action per line, with keyword arguments kept on separate lines for clarity. Reading flow is natural—signature, return, and nested call follow a top-to-bottom order. Minor deductions: unused imports (`auth`, `AbstractBaseUser`, etc.) could confuse readers, and the `use_in_migrations = True` line lacks context for novices, but these are minor. Overall, the code is well-structured and easy to follow.
Run 2
The code is highly readable with a clear, logical structure. It begins with organized imports, grouping standard library, Django, and local modules, which aids navigation. The class PermissionManager is concise and purposeful, with a single method get_by_natural_key that clearly expresses its intent. Nesting is minimal: only one level inside the method, and the ContentType query is sensibly wrapped to avoid deep indentation. Action granularity is good—keyword arguments are on separate lines, improving clarity. The use of use_in_migrations = True is explicit and conventional. Reading flow is natural: imports lead to class definition, then method logic. Code length is appropriate; no unnecessary verbosity. Overall, the snippet is easy to understand and maintain for a Django developer.
Run 3
The code is generally well-structured and readable. It has clear imports, a single class with a straightforward method, and follows Django conventions. The nesting is minimal—only two levels in the method call. The intent is clear: retrieving a permission by natural key. However, the method chains multiple operations in a single expression, which slightly reduces readability and action granularity. Breaking the ContentType lookup into a separate variable would improve clarity and follow the 'one action per line' principle more strictly. Overall, the code is concise, logically organized, and easy to follow, but could be slightly refactored for even better readability.
Run 1
Code Structure: Imports are grouped at the top, followed by a focused manager class and method; many imports are unused in this snippet and add clutter. Nesting: Shallow class/method nesting, with a nested lookup that remains easy to follow. Clarity of intent: Descriptive names clearly communicate retrieval of a permission by its natural key, though understanding the lookup requires Django familiarity. Code length: The implementation is concise, but the import list is disproportionate to the shown functionality. Action granularity: Each statement has a clear role; the inner content-type lookup is embedded in the outer query but formatted distinctly. Reading flow: Conventional formatting and indentation provide a natural top-to-bottom flow, with slightly limited spacing between the imports and class.
Run 2
Code Structure: Imports and a focused manager class are logically organized, though many imports are unused in this snippet. Nesting: Shallow class and method nesting; the nested lookup is easy to follow. Clarity of intent: Descriptive names clearly communicate retrieving a permission by its natural key. Code length: The implementation is concise, but the extensive imports add visual overhead relative to the small method. Action granularity: Each import occupies its own line, and the return expression coherently combines related lookups. Reading flow: Consistent indentation and multiline argument formatting support natural reading, although additional spacing between the imports and class would improve separation.
Run 3
Code Structure: Imports and the manager class are logically organized, although many imports are unused in this snippet. Nesting: The code is shallow; the nested lookup is easy to follow. Clarity of intent: Descriptive class, method, and parameter names clearly communicate a permission lookup by natural key. Code length: The method is concise, but the large import block adds unnecessary length relative to the shown functionality. Action granularity: The return statement combines two related database lookups, with multiline formatting keeping them distinct and readable. Reading flow: Execution flows naturally from resolving the content type to retrieving the permission. An additional blank line before the class would improve visual separation.