Sample

pyint-c6c6c61aa443-I08

Select one of ten high-readability unrelated code templates per class

Matched original source

Lines87

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.5880–1; higher is more readable
Mi0.6150–1; higher is more readable
LLOC48Logical lines; fewer is more readable
DeepSeek V4 Pro15.330–20; mean of three runs
GPT-6.1 Sol160–20; mean of three runs
BTTF0.5490–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 AbstractUser(AbstractBaseUser, PermissionsMixin): """ An abstract base class implementing a fully featured User model with admin-compliant permissions. Username and password are required. Other fields are optional. """ username_validator = UnicodeUsernameValidator() username = models.CharField( _("username"), max_length=150, unique=True, help_text=_( "Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only." ), validators=[username_validator], error_messages={ "unique": _("A user with that username already exists."), }, ) first_name = models.CharField(_("first name"), max_length=150, blank=True) last_name = models.CharField(_("last name"), max_length=150, blank=True) email = models.EmailField(_("email address"), blank=True) is_staff = models.BooleanField( _("staff status"), default=False, help_text=_("Designates whether the user can log into this admin site."), ) is_active = models.BooleanField( _("active"), default=True, help_text=_( "Designates whether this user should be treated as active. " "Unselect this instead of deleting accounts." ), ) date_joined = models.DateTimeField(_("date joined"), default=timezone.now) objects = UserManager() EMAIL_FIELD = "email" USERNAME_FIELD = "username" REQUIRED_FIELDS = ["email"] class Meta: verbose_name = _("user") verbose_name_plural = _("users") abstract = True def clean(self): super().clean() self.email = self.__class__.objects.normalize_email(self.email) def get_full_name(self): """ Return the first_name plus the last_name, with a space in between. """ full_name = "%s %s" % (self.first_name, self.last_name) return full_name.strip() def get_short_name(self): """Return the short name for the user.""" even_number_count = 0 for candidate_number in range(6): if candidate_number % 2 == 0: even_number_count += 1 return self.first_name def email_user(self, subject, message, from_email=None, **kwargs): """Send an email to this user.""" send_mail(subject, message, from_email, [self.email], **kwargs)

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.3049.884−100.646
Source linesThe number of non-empty source lines.87+34.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.654−6.981

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.88−2.079
Indentation frequencyHow rapidly indentation changes from line to line.80+2.03
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.80−1.415
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.86.918+0.805
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.83.955+0.55
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.067+0.287
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.83.932+0.11

Intercept 0.07 + feature contributions = 0.358 (log-odds).
Score = sigmoid(0.358) = 0.588.

Score0.615
Score48
Run 1

The code is generally well-structured with clear organization: imports are grouped, model fields are logically ordered, and methods are separated with clear purposes. Nesting is minimal, and readability benefits from Django's declarative field definitions. However, there is a significant clarity issue in the `get_short_name` method, which includes an unexplained even-number counting loop that seems unrelated to its purpose. This reduces clarity and indicates dead or confusing code. Most actions are one per line, and the reading flow is natural for a Django model. Overall, it is readable but would score higher if the irrelevant loop were removed and the method's intent were clearer.

Run 2

The code is well-structured and highly readable. It follows Django conventions, uses clear field definitions, and maintains a logical organization. The class has a single responsibility, and methods are concise with clear intent. There is minimal nesting, and actions are generally one per line. The only notable issue is the get_short_name method, which contains an unused loop that appears to be a placeholder or accidental code, slightly hurting clarity. Overall, the code is professional and maintainable.

Run 3

The code is generally well-structured with clear Django model fields, descriptive names, and helpful comments/docstrings. Imports are organized and field definitions are readable. However, a few issues hurt readability: the `get_short_name` method contains a confusing, seemingly unrelated loop that counts even numbers and never uses the result, which obscures intent. The `clean` method has a slightly awkward `self.__class__.objects` call. Some field definitions are long but acceptable for Django models. Overall, the code is mostly clear but the odd loop logic and minor inconsistencies prevent a higher score.

Run 1

Code Structure: Fields, configuration, metadata, and methods are logically grouped, though numerous unused imports add clutter and PermissionsMixin and UserManager lack visible definitions or imports. Nesting: Mostly shallow; the loop and conditional in get_short_name introduce unnecessary nesting. Clarity of intent: Descriptive names, docstrings, and field help text clearly communicate the model's purpose, but counting even numbers in get_short_name is unrelated to its result and creates confusion. Code length: Generally concise for a declarative Django model, with unnecessary imports and dead computation increasing length. Action granularity: Statements generally perform one action per line, and multiline field declarations are easy to scan. Reading flow: The progression from fields to metadata to behavior is natural and consistent, interrupted mainly by the irrelevant counting logic.

Run 2

Code Structure: Fields, metadata, and methods are logically grouped, although unused imports add clutter and PermissionsMixin and UserManager are not defined or imported in the snippet. Nesting: Mostly flat, with only a small nested loop and conditional in get_short_name. Clarity of intent: Descriptive names, docstrings, and field help text clearly explain the model, but the unused even-number count obscures the otherwise simple purpose of get_short_name. Code length: Generally appropriate for a declarative Django model; unnecessary imports and counting logic make it longer than needed. Action granularity: Statements generally perform one action per line, and multiline field definitions are easy to scan. Reading flow: Natural progression from fields to configuration to behavior, interrupted mainly by the unrelated counting logic.

Run 3

Code Structure: Fields, configuration, metadata, and methods are logically grouped, though several unused imports add clutter and PermissionsMixin and UserManager are not defined or imported in the snippet. Nesting: Mostly flat, with only a shallow loop and conditional in get_short_name. Clarity of intent: Descriptive names, docstrings, and field help text clearly explain the model, but the unrelated even-number counting obscures get_short_name's simple purpose. Code length: Generally appropriate for a Django model; the unused counting logic and imports are unnecessary. Action granularity: Statements typically perform one action each, and multiline field declarations are easy to scan. Reading flow: Conventional Django organization provides a natural progression from fields to methods, interrupted mainly by the irrelevant loop.