Sample

pyint-495589ef950f-I11

Split eligible integer literals into pairs of short-named intermediate variables

Matched original source

Lines24

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.580–1; higher is more readable
Mi0.4430–1; higher is more readable
LLOC17Logical lines; fewer is more readable
DeepSeek V4 Pro170–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.7430–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 get_by_natural_key(self, codename, app_label, model): return self.get( codename=codename, content_type=ContentType.objects.db_manager(self.db).get_by_natural_key( app_label, model ), )

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.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

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.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.

Score0.443
Score17
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 overall. It has a clear, flat structure with a single class and one method, avoiding unnecessary nesting. The purpose is explicit: it defines a custom model manager for permissions with natural key lookup. The method name 'get_by_natural_key' clearly communicates intent, and parameters are descriptive. The one action in the method is split across multiple lines for readability, with the nested call to get_by_natural_key cleanly formatted. Imports are standard and well-organized. Minor deductions: the long chained call (`ContentType.objects.db_manager(self.db).get_by_natural_key(...)`) could be slightly more readable with intermediate variables, and there is a lack of type hints or docstrings which would improve clarity for maintainers. Overall, excellent adherence to style guides (PEP8) and consistent formatting.

Run 3

The code is well-structured with logical import grouping and a single, clearly named class. Nesting is minimal—the only slightly deeper call is within get_by_natural_key, where content type retrieval wraps across three lines but reads clearly. Intent is unambiguous: a custom manager for natural key lookups. Length is concise; no unnecessary code exists. Action granularity is good—arguments are laid out one per line in the final call, enhancing scanability. Reading flow is natural: imports, class declaration, then method definition with a straightforward return. Deductions come from minor density in the nested get_by_natural_key call and lack of a docstring clarifying the method’s role beyond its name.

Run 1

Code Structure: Imports precede a focused manager class, providing logical organization, although many imports are unused in this snippet. Nesting: Minimal class/method nesting; the nested lookup remains easy to follow. Clarity of intent: Descriptive names clearly communicate retrieving a permission by its natural key, though understanding the lookup requires Django familiarity. Code length: The implementation is concise, but the extensive import list adds unnecessary length relative to the shown functionality. Action granularity: Assignments and return logic are separated appropriately, and keyword arguments appear on individual lines. Reading flow: Conventional formatting and indentation guide the reader naturally from the manager configuration to the lookup method.

Run 2

Code Structure: Imports precede a clearly organized manager class and its method, though most imports are unused in this snippet. Nesting: Shallow structural nesting; the nested lookup adds only modest complexity. Clarity of intent: Descriptive class, method, and parameter names clearly convey a natural-key permission lookup, although Django knowledge helps. Code length: The implementation is concise, but excess imports add clutter. Action granularity: Operations are cleanly formatted; embedding the content-type lookup within self.get combines two lookups in one expression but remains understandable. Reading flow: Conventional organization and consistent indentation make the code easy to follow, with the multiline return accommodating the longer lookup naturally.

Run 3

Code Structure: Imports and the manager class are logically organized, although many imports are unused in this snippet. Nesting: The method has no nested control flow; the nested lookup call is shallow and well formatted. Clarity of intent: Descriptive class, method, and parameter names clearly communicate retrieval of a permission by its natural key. Code length: The implementation is concise, but the unused imports add unnecessary length. Action granularity: The method combines a content-type lookup with permission retrieval, yet multiline formatting makes both operations easy to distinguish. Reading flow: The code reads naturally from imports to class configuration to lookup implementation; an additional blank line before the top-level class would improve visual separation.