Sample

pyint-e39ebde5a784-I03

Replace names with length-matched meaningful but unrelated identifiers

Matched original source

Lines62

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.6740–1; higher is more readable
Mi0.4920–1; higher is more readable
LLOC25Logical lines; fewer is more readable
DeepSeek V4 Pro7.330–20; mean of three runs
GPT-6.1 Sol12.330–20; mean of three runs
BTTF0.5750–1; higher is more readable

Views

Source code

import datetime from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.db import models from django.http import Http404 from django.utils import timezone from django.utils.functional import cached_property from django.utils.translation import gettext as _ from django.views.generic.base import View from django.views.generic.detail import ( BaseDetailView, SingleObjectTemplateResponseMixin, ) from django.views.generic.list import ( MultipleObjectMixin, MultipleObjectTemplateResponseMixin, ) class BaseDateDetailView(YearMixin, MonthMixin, DayMixin, DateMixin, BaseDetailView): """ Base detail view for a single object on a single date; this differs from the standard DetailView by accepting a year/month/day in the URL. This requires subclassing to provide a response mixin. """ def checkState(self, category=None): """Get the object this request displays.""" size = self.get_year() group = self.get_month() age = self.get_day() node = _date_from_string( size, self.get_year_format(), group, self.get_month_format(), age, self.get_day_format(), ) # Use a custom queryset if provided key = self.get_queryset() if category is None else category if not self.get_allow_future() and node > datetime.date.today(): raise Http404( _( "Future %(verbose_name_plural)s not available because " "%(class_name)s.allow_future is False." ) % { "verbose_name_plural": key.model._meta.verbose_name_plural, "class_name": self.__class__.__name__, } ) # Filter down a queryset from self.queryset using the date from the # URL. This'll get passed as the queryset to DetailView.get_object, # which'll handle the 404 cachedMessage = self._make_single_date_lookup(node) key = key.filter(**cachedMessage) return super().get_object(queryset=key)

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.1680.564−55.459
Source linesThe number of non-empty source lines.62+24.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.511−6.766

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.62−1.159
Indentation frequencyHow rapidly indentation changes from line to line.53+1.096
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.53−0.795
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.84.873+0.565
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.61.965+0.456
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.053+0.425
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.968+0.066

Intercept 0.07 + feature contributions = 0.724 (log-odds).
Score = sigmoid(0.724) = 0.674.

Score0.492
Score25
Run 1

The code imports are clear but the class inherits from four mixins, which obscures its purpose. Many variables are poorly named, such as 'size', 'group', 'age', 'node', 'key', and 'cachedMessage', which do not reflect their actual content (year, month, day, date object, queryset, and lookup filter). The method 'checkState' is misleading because it retrieves an object rather than checking state. The method performs multiple responsibilities: parsing date parts, validating future dates, applying filters, and fetching the object. Comments are present but the code itself is not self-explanatory. Some lines are overly long, and the logic is somewhat tangled due to the mix of parameter validation and queryset filtering. Overall, the structure is only marginally readable due to Django familiarity, but the naming and intent clarity are poor.

Run 2

The code suffers from severe readability issues. Variable names are misleading: `size`, `group`, and `age` map to year, month, and day respectively, obscuring intent. The method `checkState` is poorly named for what it does—it retrieves an object. `node` and `cachedMessage` are equally unclear, representing a date and a lookup dict. The function performs multiple responsibilities: parsing date parts, checking future dates, filtering the queryset, and calling super().get_object. This violates single-responsibility and reduces action granularity clarity. Imported mixins (YearMixin, MonthMixin, DayMixin, DateMixin) are relied on but not shown, adding ambiguity. The docstring is somewhat helpful, but doesn't compensate for the confusing naming and mixed abstraction levels. Overall, the code requires significant cognitive overhead to understand, making it far below average in readability.

Run 3

The code shows a reasonable class structure and follows Django conventions, but the method checkState suffers from poor naming and unclear variable names (e.g., size, group, age, node, key, cachedMessage) that obscure its purpose. The logic is mostly flat with acceptable nesting, but the flow is muddled by misleading identifiers and a mix of unrelated actions. The method attempts to do multiple things—parse date components, enforce future-date rules, build a queryset, and delegate to super()—which reduces clarity. Some lines are concise, but variable renaming and clearer separation of concerns would improve readability.

Run 1

Code Structure: The method is logically organized into date extraction, queryset selection, future-date validation, filtering, and object retrieval. Nesting: Mostly flat, with only one conditional block; multiline exception formatting adds visual complexity without deep nesting. Clarity of intent: The class docstring and comments explain the purpose, but checkState and variable names such as size, group, age, node, key, and cachedMessage obscure their actual roles. The method name also conflicts with its documented object-retrieval purpose. Code length: The method is reasonably concise, though several imports appear unused in this excerpt. Action granularity: Statements generally perform one action each, and multiline calls are clearly formatted. Reading flow: The sequence is natural and comments help, but misleading names and inconsistent naming conventions interrupt comprehension. Mixins and the date-parsing helper are not defined in the excerpt, limiting standalone readability.

Run 2

Code Structure: The method follows a logical sequence: extract date components, construct a date, select a queryset, validate future-date access, filter, and retrieve the object. Nesting: Control flow is shallow, with only one conditional block; multiline calls add visual depth without complex branching. Clarity of intent: The class docstring and comments explain the purpose, but checkState and variables such as size, group, age, node, key, and cachedMessage obscure their actual meanings. Code length: The method is reasonably concise, though several imports are unused in the shown snippet. Action granularity: Statements generally perform one action per line, and longer expressions are appropriately split. Reading flow: Operations proceed naturally, but misleading names, inconsistent naming conventions, and a comment referring to self.queryset rather than the selected queryset interrupt comprehension. Referenced mixins and the date helper are not defined in the snippet, limiting standalone understanding.

Run 3

Code Structure: The method follows a logical sequence: extract date components, construct a date, select a queryset, validate future access, filter, and retrieve the object. Nesting: Mostly flat, with only one conditional; multiline expressions do not add substantial complexity. Clarity of intent: The class docstring and comments explain the purpose, but misleading names such as checkState, size, group, age, node, key, and cachedMessage obscure dates, querysets, and lookup arguments. Code length: The implementation is reasonably concise, although several imports are unused in the shown snippet. Action granularity: Statements generally perform one action each, with a readable conditional queryset assignment. Reading flow: Execution proceeds naturally, but readers must repeatedly translate unrelated variable names into domain concepts. Mixed naming conventions and the mismatch between checkState and its object-retrieval behavior further reduce readability.