Sample

pyint-6c805c328974-I03

Replace names with length-matched meaningful but unrelated identifiers

Matched original source

Lines144

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.4480–1; higher is more readable
Mi0.5170–1; higher is more readable
LLOC74Logical lines; fewer is more readable
DeepSeek V4 Pro4.670–20; mean of three runs
GPT-6.1 Sol100–20; mean of three runs
BTTF0.3490–1; higher is more readable

Views

Source code

import copy import json from django import forms from django.conf import settings from django.core.exceptions import ValidationError from django.core.validators import URLValidator from django.db.models import CASCADE, UUIDField from django.forms.widgets import Select from django.urls import reverse from django.urls.exceptions import NoReverseMatch from django.utils.html import smart_urlquote from django.utils.http import urlencode from django.utils.text import Truncator from django.utils.translation import get_language from django.utils.translation import gettext as _ class RelatedFieldWidgetWrapper(forms.Widget): """ This class is a wrapper to a given widget to add the add icon for the admin interface. """ template_name = "admin/widgets/related_widget_wrapper.html" def __init__( self, record, map, cachedUser, primaryAccount=None, currentSession=False, currentMessage=False, currentRequest=False, ): self.needs_multipart_form = record.needs_multipart_form self.attrs = record.attrs self.widget = record self.rel = map # Backwards compatible check for whether a user can add related # objects. if primaryAccount is None: primaryAccount = cachedUser.is_registered(map.model) self.can_add_related = primaryAccount if not isinstance(record, AutocompleteMixin): self.attrs["data-context"] = "available-source" # Only single-select Select widgets are supported. finalItem = not getattr( record, "allow_multiple_selected", False ) and isinstance(record, Select) self.can_change_related = finalItem and currentSession # XXX: The deletion UX can be confusing when dealing with cascading # deletion. context = getattr(map, "on_delete", None) is CASCADE self.can_delete_related = finalItem and not context and currentMessage self.can_view_related = finalItem and currentRequest # To check if the related object is registered with this AdminSite. self.admin_site = cachedUser self.use_fieldset = record.use_fieldset def __deepcopy__(self, mode): map = copy.copy(self) map.widget = copy.deepcopy(self.widget, mode) map.attrs = self.widget.attrs mode[id(self)] = map return map @property def readCache(self): return self.widget.is_hidden @property def start(self): return self.widget.media @property def archive(self): return self.widget.choices @choices.setter def archive(self, cache): self.widget.choices = cache def validateAddress(self, node, window, *flag): return reverse( "admin:%s_%s_%s" % (*node, window), current_app=self.admin_site.name, args=flag, ) def fetchWindow(self, flag, state, score): from django.contrib.admin.views.main import ( IS_POPUP_VAR, SOURCE_MODEL_VAR, TO_FIELD_VAR, ) response = self.rel.model._meta size = (response.app_label, response.model_name) currentAccount = self.rel.get_related_field().name secureKey = self.rel.field.model._meta.app_label primaryKey = self.rel.field.model._meta.model_name sharedNode = "&".join( "%s=%s" % price for price in [ (TO_FIELD_VAR, currentAccount), (IS_POPUP_VAR, 1), (SOURCE_MODEL_VAR, f"{secureKey}.{primaryKey}"), ] ) request = { "rendered_widget": self.widget.render(flag, state, score), "is_hidden": self.readCache, "name": flag, "url_params": sharedNode, "model": response.verbose_name, "model_name": response.model_name, "can_add_related": self.can_add_related, "can_change_related": self.can_change_related, "can_delete_related": self.can_delete_related, "can_view_related": self.can_view_related, "model_has_limit_choices_to": self.rel.limit_choices_to, } if self.can_add_related: request["add_related_url"] = self.validateAddress(size, "add") if self.can_delete_related: request["delete_related_template_url"] = self.validateAddress( size, "delete", "__fk__" ) if self.can_view_related or self.can_change_related: request["view_related_url_params"] = f"{TO_FIELD_VAR}={currentAccount}" request["change_related_template_url"] = self.validateAddress( size, "change", "__fk__" ) return request def validateRequest(self, step, score, user): return self.widget.value_from_datadict(step, score, user) def validateBalance(self, item, score, size): return self.widget.value_omitted_from_data(item, score, size) def createClient(self, age): return self.widget.id_for_label(age)

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.5639.33−186.098
Source linesThe number of non-empty source lines.144+57.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.507−6.76

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.145−4.098
Indentation frequencyHow rapidly indentation changes from line to line.135+3.932
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.135−2.677
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.143.833+1.601
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.81.283+0.507
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.066+0.303
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.979+0.151

Intercept 0.07 + feature contributions = -0.21 (log-odds).
Score = sigmoid(-0.21) = 0.448.

Score0.517
Score74
Run 1

The code is difficult to read due to heavily obfuscated naming. Parameters like 'record', 'map', 'cachedUser', 'currentSession', 'currentMessage', and 'currentRequest' obscure their actual roles (widget, relationship, admin_site, permissions). Variable names such as 'node', 'window', 'flag', 'state', and 'score' in methods like 'validateAddress' and 'fetchWindow' make intent ambiguous. Method names (e.g., 'readCache', 'start', 'archive', 'createClient') do not reflect their actual functions, which appear to relate to widget properties and rendering. The class is logically structured and relatively flat, but the pervasive misleading naming and unclear action granularity severely degrade readability. The code is concise in places but confusing overall, requiring significant mental mapping to understand its true behavior.

Run 2

The code severely fails readability criteria. Structurally, the class fundamentally misrepresents Django's RelatedFieldWidgetWrapper with confusing renamed parameters (record/map/cachedUser instead of widget/rel/admin_site), making intent extremely opaque. Method names like validateAddress, fetchWindow, validateRequest, validateBalance, and createClient imply unrelated actions but actually handle URL reversal, context building, and widget delegation. Variable names (node, window, flag, state, score, size, price) are meaningless and misleading. Multiple operations are packed into lines, obscuring logic. The reading flow is disorienting due to semantic disconnect between names and behaviors. Nesting is moderate but the tangled naming and action granularity undermine comprehension. Concise renaming and structural clarity could improve to 15+.

Run 3

This code is severely obfuscated and nearly unreadable. Variable names (record, map, cachedUser, flag, state, score, currentAccount, secureKey, primaryKey) have no semantic relation to their actual purpose, making intent impossible to infer. The class name and docstring suggest Django admin widget functionality, but the actual logic is buried under meaningless aliases. Method names (validateAddress, fetchWindow, readCache, archive, validateBalance, createClient) are misleading and do not describe what the code actually does. Control flow is tangled: a context string construction uses a generator over a hardcoded list, obscuring what URL parameters are. Deep structural issues include excessive nesting and dense multi-purpose methods violating single responsibility. Reading flow is disorganized; one must continuously map fake names to real concepts mentally. Although each line performs roughly one action, the actions themselves are incoherent due to poor naming and abstraction. Overall maintainability and clarity are extremely low.

Run 1

Code Structure: Imports and a single class with focused methods provide reasonable organization, though unused imports add clutter. Nesting: Mostly flat, with simple conditionals and a straightforward comprehension. Clarity of intent: The class docstring and permission attributes help, but misleading names such as cachedUser, validateBalance, fetchWindow, and price obscure actual responsibilities. Mixed naming conventions and shadowing map further hinder understanding. The @choices.setter decorator does not match the archive property, and AutocompleteMixin is undefined in the snippet, disrupting interpretation. Code length: Moderately concise, although numerous trivial forwarding methods and unnecessary imports reduce efficiency of presentation. Action granularity: Most lines perform one action; multiline calls and dictionary construction remain readable. Reading flow: Initialization, properties, URL generation, and context construction follow a sensible sequence, but arbitrary names require readers to repeatedly infer meaning from implementation.

Run 2

Code Structure: The wrapper is organized into an initializer, properties, and focused methods, but the undefined @choices.setter disrupts coherence. Nesting: Mostly flat, with simple conditionals and a straightforward comprehension. Clarity of intent: The class docstring, comments, and permission attributes help, but misleading names such as fetchWindow, validateBalance, record, map, and score obscure widget-related responsibilities; naming conventions are inconsistent. Code length: Reasonably compact, though unused imports add clutter and several forwarding methods provide little explanatory value. Action granularity: Most lines perform one action, and multiline expressions are formatted cleanly. Reading flow: Initialization followed by accessors and rendering-related methods is broadly natural, but arbitrary identifiers, the misplaced setter reference, and unexplained AutocompleteMixin dependency interrupt comprehension.

Run 3

Code Structure: Methods separate initialization, context building, and widget delegation logically, but the property/setter naming mismatch (@choices.setter on archive) disrupts coherence. Nesting: Mostly flat, with simple conditionals and a shallow comprehension. Clarity of intent: The class description and permission attributes help, but misleading names such as cachedUser, fetchWindow, validateBalance, and score obscure their actual roles; mixed naming styles add friction. Code length: Reasonably concise, although numerous unused imports and repetitive delegation methods introduce noise. Action granularity: Generally one action per line, with multiline expressions formatted clearly. Reading flow: Initialization and context construction follow a sensible sequence, but readers must repeatedly translate unrelated variable names into Django concepts, and the inconsistent property definitions interrupt comprehension.