Sample

pyint-032f4fafe8d9-I06

Invert eligible conditions and exchange their branches

Matched original source

Lines83

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.5890–1; higher is more readable
Mi0.6150–1; higher is more readable
LLOC44Logical lines; fewer is more readable
DeepSeek V4 Pro17.330–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.6770–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.""" 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.2844.331−93.863
Source linesThe number of non-empty source lines.83+33.2
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.669−7.004

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.84−1.938
Indentation frequencyHow rapidly indentation changes from line to line.76+1.892
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.76−1.323
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.82.918+0.749
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.82.024+0.519
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.068+0.283
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.952+0.109

Intercept 0.07 + feature contributions = 0.361 (log-odds).
Score = sigmoid(0.361) = 0.589.

Score0.615
Score44
Run 1

The code is well-structured and highly readable. It follows Django model conventions with clear separation of concerns. The class is organized logically: fields are grouped together, followed by the manager, constants, Meta class, and methods. Nesting is minimal — the main indentation comes from field definition arguments, which is idiomatic for Django models. Each model field and method has a clear purpose, enhanced by descriptive names and docstrings. The code is concise but not overly compressed; field definitions are multi-line for readability. Action granularity is good, with one logical operation per line. Reading flow is natural, moving from field definitions to class constants to methods. Minor issues include the unused imports at the top (e.g., `Iterable`, `apps`, `ContentType`, `PermissionDenied`, `EmptyManager`) which could be removed, and a slight inconsistency in using string formatting (`"%s %s"`) versus f-strings, but these don't significantly impact readability.

Run 2

The code is highly readable. It has a logical, flat structure with clear separation of concerns: imports, class definition, model fields, manager, Meta, and methods. Nesting is minimal, with only one level inside methods and field definitions. Intent is explicit through meaningful names, help_text, and docstrings. Code length is appropriate but could be slightly reduced by condensing some field help_texts. Each line performs a single action, and the reading flow is natural, moving from general class setup to specific behaviors. Minor deductions: some verbose field definitions and a few repetitive patterns slightly increase length, and the 'email_user' method could have a more specific docstring.

Run 3

The code is highly readable with clear structure and organization. It follows Django conventions, groups imports logically, and separates model fields, Meta options, and methods cleanly. Nesting is minimal—only one level deep in field definitions and methods. Intent is explicit through descriptive field names, help texts, and docstrings. Code length is appropriate, with each field and method concisely defined without unnecessary repetition. Action granularity is well-maintained, with each model field, method, and operation on its own line or logically grouped. Reading flow is natural, moving from imports to class definition, fields, Meta, and methods. Minor deductions for the slightly verbose username field with nested parameters, but overall this is exemplary Django model code.

Run 1

Code Structure: Fields, manager, constants, metadata, and methods are logically grouped in a conventional Django model layout. Nesting: Shallow nesting; multiline field declarations remain easy to follow. Clarity of intent: Descriptive names, docstrings, and field help text clearly explain behavior, though PermissionsMixin and UserManager are undefined in the supplied snippet. Code length: Appropriate for the model, but several unused imports add clutter. Action granularity: Statements generally perform one action each, with cleanly separated method steps. Reading flow: Natural progression from model configuration to small utility methods; consistent formatting supports scanning.

Run 2

Code Structure: Fields, manager, configuration, metadata, and methods are logically grouped. Nesting: Shallow nesting keeps the class easy to scan; multiline field declarations remain clear. Clarity of intent: Descriptive names, docstrings, and field help text explain the model well, though PermissionsMixin and UserManager are not defined or imported in the snippet. Code length: Mostly concise and appropriate for a declarative Django model, but several unused imports add clutter. Action granularity: Each statement performs one clear action, with no compressed multi-action lines. Reading flow: The progression from model fields to configuration and behavior is natural, supported by consistent formatting and spacing.

Run 3

Code Structure: Fields, manager, configuration, metadata, and methods are logically grouped. Nesting: Minimal nesting; multiline field declarations remain easy to follow. Clarity of intent: Descriptive names, docstrings, and help text clearly communicate the model's purpose, although PermissionsMixin and UserManager are not defined or imported in the snippet. Code length: Appropriately concise for a Django model, but several unused imports add clutter. Action granularity: Statements generally perform one action each, with complex field settings cleanly separated across lines. Reading flow: The progression from model fields to configuration and behavior is natural and consistent. Overall, highly readable with minor dependency and import distractions.