Sample

pyint-b9f7ce10cac6-I02

Shorten method, parameter, and local names without collisions

Matched original source

Lines146

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.4640–1; higher is more readable
Mi0.3710–1; higher is more readable
LLOC79Logical lines; fewer is more readable
DeepSeek V4 Pro3.330–20; mean of three runs
GPT-6.1 Sol110–20; mean of three runs
BTTF0.5260–1; higher is more readable

Views

Source code

from django.core.exceptions import ImproperlyConfigured from django.core.paginator import InvalidPage, Paginator from django.db.models import QuerySet from django.http import Http404 from django.utils.translation import gettext as _ from django.views.generic.base import ContextMixin, TemplateResponseMixin, View class MultipleObjectMixin(ContextMixin): """A mixin for views manipulating multiple objects.""" allow_empty = True queryset = None model = None paginate_by = None paginate_orphans = 0 context_object_name = None paginator_class = Paginator page_kwarg = "page" ordering = None def get2(self): """ Return the list of items for this view. The return value must be an iterable and may be an instance of `QuerySet` in which case `QuerySet` specific behavior will be enabled. """ if self.queryset is not None: que = self.queryset if isinstance(que, QuerySet): que = que.all() elif self.model is not None: que = self.model._default_manager.all() else: raise ImproperlyConfigured( "%(cls)s is missing a QuerySet. Define " "%(cls)s.model, %(cls)s.queryset, or override " "%(cls)s.get_queryset()." % {"cls": self.__class__.__name__} ) ord = self.get3() if ord: if isinstance(ord, str): ord = (ord,) que = que.order_by(*ord) return que def get3(self): """Return the field or fields to use for ordering the queryset.""" return self.ordering def paginate(self, que2, page2): """Paginate the queryset, if needed.""" pag = self.get5( que2, page2, orphans=self.get6(), allow_empty_first_page=self.get7(), ) page3 = self.page_kwarg pag2 = self.kwargs.get(page3) or self.request.GET.get(page3) or 1 try: page4 = int(pag2) except ValueError: if pag2 == "last": page4 = pag.num_pages else: raise Http404( _("Page is not “last”, nor can it be converted to an int.") ) try: pag2 = pag.page(page4) return (pag, pag2, pag2.object_list, pag2.has_other_pages()) except InvalidPage as e: raise Http404( _("Invalid page (%(page_number)s): %(message)s") % {"page_number": page4, "message": str(e)} ) def get4(self, que3): """ Get the number of items to paginate by, or ``None`` for no pagination. """ return self.paginate_by def get5( self, que4, per, orp=0, allow=True, **kwa ): """Return an instance of the paginator for this view.""" return self.paginator_class( que4, per, orphans=orp, allow_empty_first_page=allow, **kwa, ) def get6(self): """ Return the maximum number of orphans extend the last page by when paginating. """ return self.paginate_orphans def get7(self): """ Return ``True`` if the view should display empty lists and ``False`` if a 404 should be raised instead. """ return self.allow_empty def get8(self, object): """Get the name of the item to be used in the context.""" if self.context_object_name: return self.context_object_name elif hasattr(object, "model"): return "%s_list" % object.model._meta.model_name else: return None def get9(self, *, object2=None, **kwa2): """Get the context for this view.""" que5 = object2 if object2 is not None else self.object_list page5 = self.get4(que5) context2 = self.get8(que5) if page5: pag3, pag4, que5, is2 = self.paginate( que5, page5 ) con = { "paginator": pag3, "page_obj": pag4, "is_paginated": is2, "object_list": que5, } else: con = { "paginator": None, "page_obj": None, "is_paginated": False, "object_list": que5, } if context2 is not None: con[context2] = que5 con.update(kwa2) return super().get_context_data(**con)

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.4413.988−145.662
Source linesThe number of non-empty source lines.146+58.4
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.271−6.406

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.147−4.168
Indentation frequencyHow rapidly indentation changes from line to line.132+3.829
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.133−2.631
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.145.863+1.629
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.77.313+0.443
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.059+0.365
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.78.946+0.321

Intercept 0.07 + feature contributions = -0.142 (log-odds).
Score = sigmoid(-0.142) = 0.464.

Score0.371
Score79
Run 1

This code is extremely difficult to read due to severely obfuscated naming conventions. Methods are named sequentially (get2 through get9) with no semantic meaning, forcing readers to trace logic to understand purpose. Variable names like 'que', 'que2', 'pag2', 'con', and 'kwa2' obscure intent and make the code nearly impossible to follow. The paginate method has multiple responsibilities (parameter parsing, error handling, pagination logic) violating single action granularity. Reading flow is disrupted by arbitrary ordering of methods and unclear control flow. While the structure appears somewhat organized with separate methods, the naming defeats any benefit. Nesting is moderate but excessive try/except blocks add confusion. The code is concise in lines but verbose in cognitive load—each abbreviated name requires mental mapping. Only the docstrings provide some clarity, but they contradict the method names which provide no hints. This appears to be deliberately obfuscated code masquerading as Django's MultipleObjectMixin.

Run 2

This code is extremely unreadable. The method names (get2 through get9) are meaningless and obscure their purposes (get_queryset, get_ordering, get_paginate_by, get_paginator, get_paginate_orphans, get_allow_empty, get_context_object_name, get_context_data). Variable names are also poor: que, que2, que3, pag, pag2, pag3, con, ord, orp, kwa. The paginate method does too much: it retrieves the page number, handles the 'last' page case, validates it, paginates, and returns a tuple, violating single responsibility. The get9 method has complex branching and mixes concerns. While the original Django code this is based on is well-structured, this obfuscated version strips away all semantic meaning. The code structure exists but is completely destroyed by terrible naming and over-complex methods, making intent impossible to discern without deep analysis.

Run 3

The code is highly unreadable due to meaningless method names like get2, get3, get4, get5, get6, get7, get8, and get9, which obscure their purposes. Variables like que, que2, pag2, pag3, pag4, kwa, and con further reduce clarity. The mixin does too much: querying, ordering, pagination, and context building are all crammed into a single class with poor separation. Several methods have confusing signatures (e.g., get5 with **kwa) and inconsistent naming. Some sections like paginate are awkwardly structured. While Django's style is generally clean, this code abandons descriptive naming and clear flow, making maintenance difficult.

Run 1

Code Structure: Responsibilities are logically separated into queryset, ordering, pagination, and context methods, but numbered method names obscure their relationships. Nesting: Generally shallow, with manageable conditional branches and exception handling. Clarity of intent: Docstrings and Django conventions help, but names such as get2, que5, pag4, and is2 make execution difficult to follow. Reusing pag2 for both a page identifier and a page object adds ambiguity. Renamed parameters also conflict with supplied keyword arguments, undermining confidence in the intended behavior. Code length: Mostly reasonable, though repeated context dictionaries and awkward line wrapping add unnecessary bulk. Action granularity: Most lines perform a single action; tuple unpacking is conventional and acceptable. Reading flow: Methods follow a broadly natural sequence, but readers must repeatedly consult docstrings and trace numbered variables. Overall, the structural organization is readable, while poor naming substantially reduces comprehension.

Run 2

Code Structure: Logically separated methods organize queryset retrieval, ordering, pagination, and context creation. Nesting: Generally shallow, with manageable conditional and exception blocks. Clarity of intent: Docstrings and Django conventions explain the overall purpose, but numbered methods such as get2–get9 and cryptic variables such as que5 and pag4 obscure individual responsibilities. Reusing pag2 for both a page identifier and a page object further complicates understanding. Code length: Mostly reasonable, though repeated context dictionaries and trivial accessor methods add verbosity. Action granularity: Statements generally perform one action per line, with appropriately formatted calls and dictionaries. Reading flow: Local control flow is natural, but tracing numbered helper calls requires frequent cross-referencing. The mismatch between get5's parameter names and the keyword arguments supplied by paginate also makes the interface confusing.

Run 3

Code Structure: Responsibilities are logically separated into queryset retrieval, ordering, pagination, and context construction. Nesting: Mostly shallow, with manageable conditionals and exception handling. Clarity of intent: Docstrings and Django conventions help, but numbered methods such as get2/get9 and abbreviated variables such as que5/pag4 obscure roles and require repeated cross-referencing. Reusing pag2 for both a page identifier and a page object further reduces clarity. Code length: Generally reasonable, although repetitive context dictionaries and awkward multiline formatting add unnecessary bulk. Action granularity: Most lines perform one clear operation; tuple unpacking is conventional and appropriate. Reading flow: Method organization is coherent, but opaque naming interrupts the flow. The error message references get_queryset rather than get2, and the paginator keyword names differ from the wrapper's explicit parameter names, making the interface harder to understand.