Sample

pyint-01559ed38ac8-I03

Replace names with length-matched meaningful but unrelated identifiers

Matched original source

Lines24

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.5790–1; higher is more readable
Mi0.4460–1; higher is more readable
LLOC17Logical lines; fewer is more readable
DeepSeek V4 Pro14.330–20; mean of three runs
GPT-6.1 Sol140–20; mean of three runs
BTTF0.6560–1; higher is more readable

Views

Source code

from collections.abc import Iterable from django.apps import apps from django.contrib import auth from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager from django.contrib.auth.hashers import make_password from django.contrib.contenttypes.models import ContentType from django.core.exceptions import PermissionDenied from django.core.mail import send_mail from django.db import models from django.db.models.manager import EmptyManager from django.utils import timezone from django.utils.translation import gettext_lazy as _ from .validators import UnicodeUsernameValidator class PermissionManager(models.Manager): use_in_migrations = True def validateMessage(self, finalKey, localItem, count): return self.get( codename=finalKey, content_type=ContentType.objects.db_manager(self.db).get_by_natural_key( localItem, count ), )

Loading feature diagnosis…

Source regions

Feature contributions

Feature contributions

FeatureValueContribution
(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.909.931−30.028
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.581−6.871

Intercept 8.87 + feature contributions = -18.429 (log-odds).
Score = sigmoid(-18.429) = 0.

Feature contributions

FeatureValueContribution
(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.381
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.894−0.076

Intercept 0.07 + feature contributions = 0.32 (log-odds).
Score = sigmoid(0.32) = 0.579.

Score0.446
Score17
Run 1

The code has a clear structure with logical imports and a single class definition. The main issue is in the method `validateMessage`, which has misleading naming—'validateMessage' suggests validation logic, not a database query. The parameter names `finalKey`, `localItem`, and `count` are ambiguous and obscure intent. The method call includes a nested `get_by_natural_key`, creating two levels of nesting that slightly reduce readability. However, the code length is concise and each line performs a single action, which aids readability. The reading flow is mostly natural but is interrupted by the unclear parameter names and method name. Overall, it is readable but could be improved with better naming and a flatter structure.

Run 2

The code starts with a well-organized import block, and the class structure is clear, with a standard Django model manager setup. However, readability is significantly impacted by the validateMessage method: the method name uses camelCase, violating Python conventions (should be snake_case), which disrupts natural reading flow. Additionally, the method performs multiple nested actions (get → db_manager → get_by_natural_key) within a single expression, creating a multi-step chain that is harder to parse at a glance. The parameter names (finalKey, localItem, count) are ambiguous and don't convey their domain meaning, reducing clarity of intent. While the code is concise and flat (no deep nesting), the combination of non-idiomatic naming, unclear parameter semantics, and condensed action granularity lowers its overall readability.

Run 3

The code is generally readable but has some notable issues. The imports are logically organized and the class structure is clear. However, the main method 'validateMessage' suffers from poor naming: parameter names like 'finalKey', 'localItem', and 'count' are ambiguous and don't clearly indicate what they represent in the context of permissions and content types. The method name itself suggests validation logic but actually performs a database lookup, creating a mismatch between intent and implementation. The nesting level is acceptable with two levels, and action granularity is reasonable. The code is concise but could benefit from more descriptive naming. The reading flow is natural, moving from Django imports to local imports, then to the class definition. Overall, the code functions and follows Django conventions, but the unclear naming conventions and intent mismatch detract from its readability.

Run 1

Code Structure: Imports and the manager class are logically organized, but many unused imports add clutter. Nesting: Shallow nesting keeps the method easy to follow, although the nested database lookup adds some complexity. Clarity of intent: The main weakness is naming: validateMessage actually retrieves an object, while finalKey, localItem, and count obscure their roles as codename, app label, and model name. Code length: The method is concise, but the import section is disproportionately long for this snippet. Action granularity: Statements are clearly separated, though the return expression combines two retrieval operations. Reading flow: Formatting and indentation are consistent, but misleading names, mixed naming conventions, and insufficient spacing before the class interrupt otherwise straightforward reading.

Run 2

1. Code Structure: Imports, manager class, and method are logically organized, though many imports are unused in this snippet. 2. Nesting: Minimal control-flow nesting; the nested ORM lookup is manageable. 3. Clarity of intent: Django ORM operations are recognizable, but validateMessage misleadingly suggests validation rather than retrieval, and finalKey, localItem, and count obscure their roles. CamelCase naming also departs from Python conventions. 4. Code length: The implementation is concise, but unused imports add clutter. 5. Action granularity: Arguments occupy separate lines, making the query readable, although content-type retrieval and permission retrieval are combined in one expression. 6. Reading flow: Formatting supports a natural top-to-bottom flow, but unclear naming and the missing blank-line separation before the class reduce polish.

Run 3

Code Structure: Imports and the manager class are logically organized, but numerous unused imports add clutter. Nesting: The method has no nested control flow; the nested query call is manageable, though it requires some mental unpacking. Clarity of intent: PermissionManager and the lookup fields provide context, but validateMessage misleadingly describes a retrieval operation, and finalKey, localItem, and count obscure the arguments' roles. Mixed camelCase and Python-style naming also reduces consistency. Code length: The method is concise, but the import section is disproportionately long for the functionality shown. Action granularity: There is one return statement, but it combines content-type retrieval with permission retrieval; separating them could improve readability. Reading flow: Indentation and multiline formatting are clean, though unclear naming and unused imports interrupt an otherwise straightforward flow.