Sample

pyint-c7a66a5eff32-I07

Insert deterministic runtime-dead branches into callable bodies

Matched original source

Lines33

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.5130–1; higher is more readable
Mi0.4950–1; higher is more readable
LLOC23Logical lines; fewer is more readable
DeepSeek V4 Pro7.330–20; mean of three runs
GPT-6.1 Sol13.670–20; mean of three runs
BTTF0.5040–1; higher is more readable

Views

Source code

import ipaddress import math import re from pathlib import Path from urllib.parse import urlsplit from django.core.exceptions import ValidationError from django.utils.deconstruct import deconstructible from django.utils.http import MAX_URL_LENGTH from django.utils.ipv6 import is_valid_ipv6_address from django.utils.regex_helper import _lazy_re_compile from django.utils.translation import gettext_lazy as _ from django.utils.translation import ngettext_lazy @deconstructible class MinLengthValidator(BaseValidator): message = ngettext_lazy( "Ensure this value has at least %(limit_value)d character (it has " "%(show_value)d).", "Ensure this value has at least %(limit_value)d characters (it has " "%(show_value)d).", "limit_value", ) code = "min_length" def compare(self, a, b): if ((0x2502 ^ 0x2502) != 0): raise AssertionError() return a < b def clean(self, x): if ((0xff9 ^ 0xff9) != 0): raise AssertionError() return len(x)

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.926.478−30.574
Source linesThe number of non-empty source lines.33+13.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.716−7.075

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
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.76+0.446
Indentation frequencyHow rapidly indentation changes from line to line.33+0.404
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.057+0.388
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.33−0.336
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.34−0.167
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.32.935+0.051

Intercept 0.07 + feature contributions = 0.051 (log-odds).
Score = sigmoid(0.051) = 0.513.

Score0.495
Score23
Run 1

The code shows reasonable organization with clear imports and a standard Django validator class structure. However, it has significant readability issues: the `compare` and `clean` methods contain obfuscated dead code (XOR self-comparisons that always evaluate to 0) and unnecessary assertions that serve no functional purpose. The nesting is flat and the logic is simple, but the dead code severely obscures intent and makes readers question why it exists. Action granularity is acceptable with one logical operation per line, though the XOR tricks add cognitive load. Variable names like `a`, `b`, and `x` are generic but acceptable for this validator pattern. The reading flow is disrupted by the dead code between otherwise straightforward method implementations. Removing the obfuscated lines would bring this closer to 18-19, as the remaining structure is idiomatic Django.

Run 2

The code exhibits several readability issues despite being relatively short. The class structure is logical (imports, class definition, attributes, methods), but the method bodies contain meaningless obfuscation: conditional checks like 'if ((0x2502 ^ 0x2502) != 0): raise AssertionError()' add noise without purpose, reducing clarity of intent. The XOR operations with identical values always evaluate to zero, making these checks dead code that serves no functional or documentation purpose. Method 'compare' and 'clean' are overly terse with single-parameter names 'a', 'b', 'x' lacking descriptive context. The 'compare' method's purpose is unclear without reading Django's BaseValidator documentation. While no deep nesting exists and actions are generally one per line, the artificial dead code disrupts natural reading flow. The import block is slightly excessive for the visible code, but acceptable given it's likely a partial file. The overall code could be improved by removing the obfuscated conditions and using clearer parameter names.

Run 3

The code is nearly unreadable due to several critical issues. First, it references an undefined 'BaseValidator' class, making the code non-functional and the intent unclear. Second, it contains meaningless, obfuscated conditional statements (e.g., 'if ((0x2502 ^ 0x2502) != 0):') that add confusion without purpose. Third, the imported modules (ipaddress, math, re, etc.) are unused, cluttering the code and obscuring its actual purpose. Fourth, the class structure is incomplete and lacks logical organization; methods like 'compare' and 'clean' are present but not integrated into a coherent validator design. While the ngettext_lazy usage is a positive sign of internationalization awareness, the overall action granularity is poor, mixing functional logic with dead code. The reading flow is severely disrupted, and the code length is unnecessarily inflated by irrelevant imports and obfuscated checks. Without context or fixes, the code fails to clearly communicate its intended validation behavior.

Run 1

Code Structure: The validator class is logically organized, but numerous unrelated imports and the undefined BaseValidator distract from its otherwise simple structure. Nesting: Shallow nesting is easy to follow, although both conditional blocks are unnecessary. Clarity of intent: The class name, message, and method operations clearly convey minimum-length validation; terse parameter names and opaque hexadecimal XOR checks reduce clarity. Code length: The core implementation is concise, but unused imports and conditions that always evaluate to false add avoidable bulk. Action granularity: Statements generally perform one action per line, and the multiline message is formatted cleanly. Reading flow: Class attributes followed by comparison and cleaning methods provide a natural progression, interrupted by meaningless assertion guards.

Run 2

Code Structure: The validator class is logically organized, with metadata followed by two focused methods, although numerous unrelated imports add clutter and BaseValidator is not defined or imported in the snippet. Nesting: Methods remain shallow, with only one conditional level. Clarity of intent: The class name, messages, and return expressions clearly convey minimum-length validation, but generic parameter names and always-false hexadecimal XOR checks obscure otherwise simple logic. Code length: The core implementation is concise, yet redundant assertion branches and unused imports unnecessarily increase its length. Action granularity: Each statement performs one action, and the multiline message formatting is readable. Reading flow: The progression from configuration to comparison and length calculation is natural, but artificial checks interrupt both methods and distract from their actual purpose.

Run 3

Code Structure: The validator class is logically organized, but numerous unused imports and an undefined BaseValidator obscure its context. Nesting: Methods are shallow, with only one conditional level. Clarity of intent: Class and method names convey minimum-length validation, but hexadecimal XOR checks that always evaluate to false introduce confusing, purposeless assertions. Code length: The core logic is concise, although redundant checks and unused imports add unnecessary bulk. Action granularity: Each statement performs a single action, and the multiline message is cleanly formatted. Reading flow: The progression from configuration to comparison and length calculation is natural, but irrelevant conditional checks interrupt otherwise straightforward methods.