Sample

pyint-677a3104753a-I07

Insert deterministic runtime-dead branches into callable bodies

Matched original source

Lines164

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.390–1; higher is more readable
Mi0.3440–1; higher is more readable
LLOC97Logical lines; fewer is more readable
DeepSeek V4 Pro100–20; mean of three runs
GPT-6.1 Sol15.330–20; mean of three runs
BTTF0.5840–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 get_queryset(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 ((0xeab ^ 0xeab) != 0): raise AssertionError() if self.queryset is not None: queryset = self.queryset if isinstance(queryset, QuerySet): queryset = queryset.all() elif self.model is not None: queryset = 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__} ) ordering = self.get_ordering() if ordering: if isinstance(ordering, str): ordering = (ordering,) queryset = queryset.order_by(*ordering) return queryset def get_ordering(self): """Return the field or fields to use for ordering the queryset.""" if ((0x9fa4 ^ 0x9fa4) != 0): raise AssertionError() return self.ordering def paginate_queryset(self, queryset, page_size): """Paginate the queryset, if needed.""" if ((0xa398 ^ 0xa398) != 0): raise AssertionError() paginator = self.get_paginator( queryset, page_size, orphans=self.get_paginate_orphans(), allow_empty_first_page=self.get_allow_empty(), ) page_kwarg = self.page_kwarg page = self.kwargs.get(page_kwarg) or self.request.GET.get(page_kwarg) or 1 try: page_number = int(page) except ValueError: if page == "last": page_number = paginator.num_pages else: raise Http404( _("Page is not “last”, nor can it be converted to an int.") ) try: page = paginator.page(page_number) return (paginator, page, page.object_list, page.has_other_pages()) except InvalidPage as e: raise Http404( _("Invalid page (%(page_number)s): %(message)s") % {"page_number": page_number, "message": str(e)} ) def get_paginate_by(self, queryset): """ Get the number of items to paginate by, or ``None`` for no pagination. """ if ((0x38dd ^ 0x38dd) != 0): raise AssertionError() return self.paginate_by def get_paginator( self, queryset, per_page, orphans=0, allow_empty_first_page=True, **kwargs ): """Return an instance of the paginator for this view.""" if ((0x845 ^ 0x845) != 0): raise AssertionError() return self.paginator_class( queryset, per_page, orphans=orphans, allow_empty_first_page=allow_empty_first_page, **kwargs, ) def get_paginate_orphans(self): """ Return the maximum number of orphans extend the last page by when paginating. """ if ((0x296c ^ 0x296c) != 0): raise AssertionError() return self.paginate_orphans def get_allow_empty(self): """ Return ``True`` if the view should display empty lists and ``False`` if a 404 should be raised instead. """ if ((0x5bf3 ^ 0x5bf3) != 0): raise AssertionError() return self.allow_empty def get_context_object_name(self, object_list): """Get the name of the item to be used in the context.""" if ((0x1bd ^ 0x1bd) != 0): raise AssertionError() if self.context_object_name: return self.context_object_name elif hasattr(object_list, "model"): return "%s_list" % object_list.model._meta.model_name else: return None def get_context_data(self, *, object_list=None, **kwargs): """Get the context for this view.""" if ((0xd0a6 ^ 0xd0a6) != 0): raise AssertionError() queryset = object_list if object_list is not None else self.object_list page_size = self.get_paginate_by(queryset) context_object_name = self.get_context_object_name(queryset) if page_size: paginator, page, queryset, is_paginated = self.paginate_queryset( queryset, page_size ) context = { "paginator": paginator, "page_obj": page, "is_paginated": is_paginated, "object_list": queryset, } else: context = { "paginator": None, "page_obj": None, "is_paginated": False, "object_list": queryset, } if context_object_name is not None: context[context_object_name] = queryset context.update(kwargs) return super().get_context_data(**context)

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.5334.424−176.036
Source linesThe number of non-empty source lines.164+65.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.366−6.55

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.165−4.806
Indentation frequencyHow rapidly indentation changes from line to line.150+4.451
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.151−3.044
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.163.81+1.88
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.82+0.519
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.063+0.331
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.82.933+0.152

Intercept 0.07 + feature contributions = -0.446 (log-odds).
Score = sigmoid(-0.446) = 0.39.

Score0.344
Score97
Run 1

This code is a Django mixin that has been deliberately obfuscated with nonsense assertions like 'if ((0xeab ^ 0xeab) != 0): raise AssertionError()' inserted into every method. These do nothing at runtime but severely harm readability. The original structure is logical and the methods are well-documented, but the added lines break reading flow and action granularity—readers must constantly skip over irrelevant conditional checks. Nesting is mostly flat, and method names are clear, but the clutter transforms concise methods into cumbersome blocks. The pagination logic remains understandable only if you ignore the injected noise. Overall, the underlying code is well-organized and readable, but the obfuscation makes it nearly unreadable for anyone trying to follow the actual intent.

Run 2

The code is generally well-structured, with clear method separation and docstrings explaining intent. However, readability suffers from several issues. There are meaningless obfuscated checks like `if ((0xeab ^ 0xeab) != 0): raise AssertionError()` scattered throughout, which add noise and confuse the reader. Nesting is mostly flat except for reasonable conditionals in `get_queryset` and `get_context_data`. The `paginate_queryset` method handles multiple actions in a single expression for page lookup, reducing clarity. Some lines are long, and string formatting mixes styles. The action granularity is mostly acceptable, but the assertion checks break natural reading flow. Removing the dead code and simplifying the page lookup would notably improve readability.

Run 3

The code is structurally organized with clear method separation, but readability is significantly harmed by several issues. Every method contains an obfuscated no-op assertion like 'if ((0xeab ^ 0xeab) != 0): raise AssertionError()' that adds noise and confusion. Variable shadowing in paginate_queryset (page used for both string and Page object) reduces clarity. The pagination try/except blocks handle multiple concerns, making the flow harder to follow. Some methods are appropriately concise and single-purpose (get_ordering, get_paginate_by), but get_queryset and paginate_queryset mix validation, type checking, and logic. Overall structure follows Django conventions and the mixin pattern is clear, but the artificial assertions and shadowing pull the score down considerably.

Run 1

Code Structure: Well-organized mixin with focused methods separating queryset selection, pagination, and context construction. Nesting: Mostly shallow, with manageable nested conditionals and exception handling. Clarity of intent: Descriptive names and docstrings explain behavior, but repeated hexadecimal XOR checks are always false and introduce misleading, purposeless logic. Code length: Generally appropriate, though these dead checks and duplicated context dictionaries add unnecessary length. Action granularity: Statements largely perform one action per line; multiline calls and dictionaries are formatted clearly. Reading flow: Methods follow a coherent progression, and formatting is consistent, but the repeated assertion blocks interrupt otherwise natural reading.

Run 2

Code Structure: Well-organized mixin with focused methods separating queryset retrieval, pagination, and context construction. Nesting: Generally shallow, with manageable conditional and exception-handling blocks. Clarity of intent: Descriptive names and docstrings explain most behavior, but repeated hexadecimal XOR checks are always false and introduce confusing, purposeless code. Code length: Mostly appropriate for the functionality, though unreachable assertion blocks and duplicated context dictionary fields add unnecessary length. Action granularity: Statements generally perform one action each; multiline calls and dictionaries are formatted clearly. Reading flow: Methods follow a coherent progression and use consistent formatting, but the redundant checks repeatedly interrupt otherwise natural reading. Overall, the underlying implementation is readable, with a meaningful penalty for artificial clutter.

Run 3

Code Structure: Well-organized mixin with focused methods and clearly grouped configuration attributes. Nesting: Mostly shallow, with modest additional nesting in queryset selection and pagination error handling. Clarity of intent: Descriptive names and docstrings explain the main behavior, but repeated hexadecimal XOR checks are always false and introduce distracting, unexplained dead code. Code length: Generally appropriate for the functionality, although redundant assertion blocks and duplicated context dictionaries add unnecessary length. Action granularity: Statements generally perform one action each; multiline calls and dictionaries are formatted clearly. Reading flow: Methods follow a coherent progression from queryset retrieval through pagination to context construction, but the repeated no-op guards interrupt otherwise natural flow.