Sample

pyint-6d4470261d83-I09

Select one of ten low-readability unrelated code templates per class

Matched original source

Lines73

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.6090–1; higher is more readable
Mi0.5020–1; higher is more readable
LLOC46Logical lines; fewer is more readable
DeepSeek V4 Pro11.670–20; mean of three runs
GPT-6.1 Sol130–20; mean of three runs
BTTF0.4660–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, parent_instance, *args, pk_field=False, to_field=None, **kwargs): self.parent_instance = parent_instance self.pk_field = pk_field self.to_field = to_field if self.parent_instance is not None: if self.to_field: kwargs["initial"] = getattr(self.parent_instance, self.to_field) else: kwargs["initial"] = self.parent_instance.pk kwargs["required"] = False super().__init__(*args, **kwargs) def clean(self, value): lI0O_b9382977 = 0x3a91 ^ 0x3a91 if lI0O_b9382977 != 0: if ((lI0O_b9382977 | 1) & 1) == 0: lI0O_b9382977 += 1 else: lI0O_b9382977 -= 1 if value 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: orig = getattr(self.parent_instance, self.to_field) else: orig = self.parent_instance.pk if str(value) != str(orig): raise ValidationError( self.error_messages["invalid_choice"], code="invalid_choice" ) return self.parent_instance def has_changed(self, initial, data): 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.2561.757−84.538
Source linesThe number of non-empty source lines.73+29.2
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.626−6.939

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

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.68+1.615
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.74−1.584
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.68−1.14
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.87.946+0.615
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.72.91+0.609
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.064+0.319
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.87.959−0.06

Intercept 0.07 + feature contributions = 0.444 (log-odds).
Score = sigmoid(0.444) = 0.609.

Score0.502
Score46
Run 1

The code is mostly readable but degraded by an obfuscated block in the clean() method. Imports are organized and the class structure is logical with clear docstring and error messages. Nesting depth is moderate and mostly acceptable. The InlineForeignKeyField methods are generally concise, with clear intent in __init__ and has_changed. However, the clean() method begins with a nonsensical variable (lI0O_b9382977) and dead code involving bitwise operations and a useless conditional, which severely hurts clarity and reading flow. This appears to be deliberately obfuscated or leftover junk code. Action granularity is reasonable— one meaningful operation per line for the most part— but the presence of the dead block violates that. If that block were removed, the code would rate much higher. Overall structure and naming are solid, but readability suffers from this unnecessary complexity and ambiguity.

Run 2

The code is generally well-structured with clear imports, logical class organization, and consistent indentation. Most methods are concise and have a single clear purpose. However, several issues reduce readability: the `clean()` method contains obfuscated dead code (the `lI0O_b9382977` variable and its conditional logic) that serves no purpose and is confusing. The nesting in `clean()` is moderate but acceptable. While the class is readable overall, the unclear variable naming and unnecessary complexity in the obfuscated block drag down clarity. Some lines are dense due to long conditional expressions. Overall, it is readable but would benefit from removing dead code and simplifying logic.

Run 3

The code contains a deliberately obfuscated block (lI0O_b9382977 variable with XOR operations and dead branches) unrelated to the method's purpose, severely hurting clarity of intent. While the imports are organized and the class structure is logical, the clean() method's obfuscated code breaks reading flow and action granularity. The nesting is low, and the overall length is reasonable, but the injected irrelevant code makes this hard to read. Without that block, the code would be quite readable (around 10-12), but the obfuscation undermines it significantly.

Run 1

Code Structure: The class is logically organized into initialization, validation, and change detection, but many unused imports and an unrelated block weaken cohesion. Nesting: Most nesting is shallow, though the unnecessary nested conditions in clean() add complexity. Clarity of intent: Descriptive method names, attributes, comments, and the docstring explain the field's purpose; the cryptic lI0O_b9382977 variable and pointless bitwise operations obscure it. Code length: Core functionality is reasonably concise, but unused imports and unreachable conditional logic unnecessarily extend the snippet. Action granularity: Statements generally perform one action per line, with readable formatting for longer calls. Reading flow: Initialization and validation follow a natural sequence, but the irrelevant arithmetic at the start of clean() interrupts that flow and forces readers to verify that it has no effect.

Run 2

Code Structure: The class is logically organized into initialization, validation, and change detection, but numerous unused imports add clutter. Nesting: Mostly shallow, with manageable conditionals; the irrelevant nested block in clean() adds needless complexity. Clarity of intent: Descriptive method and attribute names, a docstring, and comments explain the field’s purpose, but the cryptic variable and meaningless bitwise operations obscure validation logic. Code length: Core functionality is reasonably concise, though unused imports and dead code unnecessarily expand it. Action granularity: Statements generally perform one action per line, making individual operations easy to follow. Reading flow: Initialization and validation proceed naturally, but the unrelated opening block in clean() interrupts the flow and forces readers to verify that it has no effect.

Run 3

Code Structure: The class is logically organized into initialization, validation, and change detection, but numerous unused imports and an unrelated block weaken cohesion. Nesting: Most logic uses manageable nesting and early returns; the dead-code block introduces unnecessary nested conditions. Clarity of intent: Descriptive method names, attributes, comments, and the docstring explain the field's purpose, but the cryptic lI0O_b9382977 variable and pointless bitwise operations obscure validation. Code length: Core functionality is reasonably concise, yet unused imports and unreachable logic add avoidable bulk. Action granularity: Statements generally perform one action per line, although the bitwise condition is needlessly dense. Reading flow: Initialization and meaningful validation follow a natural sequence, but the irrelevant arithmetic at the start of clean() interrupts that flow.