Sample

pyint-8f0b5e24d60c-I03

Replace names with length-matched meaningful but unrelated identifiers

Matched original source

Lines67

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8760–1; higher is more readable
Mi0.520–1; higher is more readable
LLOC41Logical lines; fewer is more readable
DeepSeek V4 Pro9.670–20; mean of three runs
GPT-6.1 Sol130–20; mean of three runs
BTTF0.4820–1; higher is more readable

Views

Source code

from itertools import chain from django.core.exceptions import ( NON_FIELD_ERRORS, FieldError, ImproperlyConfigured, ValidationError, ) from django.core.validators import ProhibitNullCharactersValidator from django.db.models.utils import AltersData, get_blank_choice_label from django.forms.fields import ChoiceField, Field from django.forms.forms import BaseForm, DeclarativeFieldsMetaclass from django.forms.formsets import BaseFormSet, formset_factory from django.forms.utils import ErrorList from django.forms.widgets import ( HiddenInput, MultipleHiddenInput, RadioSelect, SelectMultiple, ) from django.utils.choices import BaseChoiceIterator from django.utils.hashable import make_hashable from django.utils.text import capfirst, get_text_list from django.utils.translation import gettext from django.utils.translation import gettext_lazy as _ class InlineForeignKeyField(Field): """ A basic integer field that deals with validating the given value to a given parent instance in an inline. """ widget = HiddenInput default_error_messages = { "invalid_choice": _("The inline value did not match the parent instance."), } def __init__(self, pendingAccount, *data, nextItem=False, location=None, **target): self.parent_instance = pendingAccount self.pk_field = nextItem self.to_field = location if self.parent_instance is not None: if self.to_field: target["initial"] = getattr(self.parent_instance, self.to_field) else: target["initial"] = self.parent_instance.pk target["required"] = False super().__init__(*data, **target) def check(self, group): if group in self.empty_values: if self.pk_field: return None # if there is no value act as we did before. return self.parent_instance # ensure we compare the values as equal types. if self.to_field: step = getattr(self.parent_instance, self.to_field) else: step = self.parent_instance.pk if str(group) != str(step): raise ValidationError( self.error_messages["invalid_choice"], code="invalid_choice" ) return self.parent_instance def parseBuffer(self, version, size): return False

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.2318.706−76.517
Source linesThe number of non-empty source lines.67+26.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.534−6.801

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

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.62+1.407
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.68−1.371
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.86.971+0.599
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.66.92+0.526
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.061+0.345
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.86.985−0.019

Intercept 0.07 + feature contributions = 1.954 (log-odds).
Score = sigmoid(1.954) = 0.876.

Score0.52
Score41
Run 1

The code has clear imports and class structure, but readability is negatively impacted by poor naming, unclear intent, and inconsistent logic. For example, the parameters `pendingAccount`, `nextItem`, `location`, `group`, `step`, `version`, and `size` are ambiguous and do not reflect their actual roles, making the `__init__` method difficult to follow despite modest nesting. The method `check` mixes validation and return of parent instance, obscuring its purposeful function. `parseBuffer` is undefined in terms of expected behavior and adds confusion. Some lines like `target["required"] = False` are clear, but multiple actions occur within conditional blocks, reducing granularity. The reading flow is disrupted by non-standard parameter names and methods that do not align with their apparent purpose. While the code is not deeply nested, clarity of intent suffers significantly, leading to moderate readability overall.

Run 2

The code has a clear class structure and docstring, but readability suffers from poor naming choices and obscured intent. Parameters like 'pendingAccount', 'data', 'nextItem', 'location', 'target', 'group', 'step', 'version', and 'size' do not convey their actual roles, making the logic hard to follow. The method 'check' has multiple responsibilities (handling empty values, comparing types, and raising errors) which reduces clarity. While nesting is shallow, the flow is disrupted by generic names and ambiguous conditions. The import block is long but organized. The code is concise but not intuitively expressive; renaming variables and separating concerns would significantly improve readability.

Run 3

The code has several readability issues. The function parameter names in __init__ (pendingAccount, data, nextItem, location, target) and check (group, step) are confusing and seem to mix domain concepts, making intent unclear. Method names like parseBuffer are misleading (returns False, no parsing occurs). The logic in check uses variables named 'step', 'group', and 'version', which do not convey their purpose. The structure is mostly linear but has multiple if/else branches that complicate flow. While imports are organized and the class docstring is helpful, the core methods suffer from ambiguous naming and unclear action granularity. The code is not deeply nested, but the poor variable naming and odd method naming significantly harm clarity of intent and reading flow.

Run 1

1. Code Structure: The class is logically organized into initialization, validation, and a small auxiliary method, but numerous unused imports add clutter. 2. Nesting: Nesting is shallow overall; initialization contains a manageable nested conditional, and validation uses early returns. 3. Clarity of intent: The class docstring and descriptive instance attributes explain its purpose, but names such as pendingAccount, nextItem, location, group, and step obscure their roles. parseBuffer has no evident connection to the class, and its unused parameters are unexplained. 4. Code length: The implementation is compact, although the import block is disproportionately long for the functionality shown. 5. Action granularity: Statements generally perform one action per line, with clearly formatted calls and conditionals. 6. Reading flow: Initialization followed by validation reads naturally, and spacing helps scanning. However, inconsistent naming conventions and the unexplained final method interrupt the flow.

Run 2

Code Structure: Imports and a single class provide logical organization, with initialization and validation separated into methods; many unused imports add clutter. Nesting: Mostly shallow, although initialization and empty-value handling contain nested conditionals. Clarity of intent: The class docstring, attributes, and validation error explain the purpose, but names such as pendingAccount, nextItem, group, step, and target obscure their roles. parseBuffer has unused parameters and an unexplained constant return. Code length: Methods are concise, but the extensive import block is disproportionate to the implementation. Action granularity: Statements generally perform one action per line, with readable formatting for the exception. Reading flow: Initialization followed by validation is natural, but inconsistent naming conventions and the unrelated-looking final method interrupt coherence.

Run 3

Code Structure: The class is logically divided into initialization, validation, and a small stub, but numerous unused imports add clutter. Nesting: Conditional nesting is modest and manageable, with early returns simplifying validation. Clarity of intent: The docstring, attributes, and error message explain the overall purpose, but names such as pendingAccount, nextItem, group, step, and parseBuffer obscure parameter roles; mixed naming conventions further reduce clarity. Code length: Methods are concise, although the import block is disproportionate to the functionality shown. Action granularity: Statements generally perform one action per line, making individual operations easy to follow. Reading flow: Initialization followed by validation provides a natural progression, but the unexplained parseBuffer method and its unused parameters interrupt coherence.