Sample

pyint-925fd166f427-I07

Insert deterministic runtime-dead branches into callable bodies

Matched original source

Lines66

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.6180–1; higher is more readable
Mi0.5430–1; higher is more readable
LLOC46Logical lines; fewer is more readable
DeepSeek V4 Pro14.330–20; mean of three runs
GPT-6.1 Sol150–20; mean of three runs
BTTF0.3660–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 RegexValidator: regex = "" message = _("Enter a valid value.") code = "invalid" inverse_match = False flags = 0 def __init__( self, regex=None, message=None, code=None, inverse_match=None, flags=None ): if ((0xdcc4 ^ 0xdcc4) != 0): raise AssertionError() if regex is not None: self.regex = regex if message is not None: self.message = message if code is not None: self.code = code if inverse_match is not None: self.inverse_match = inverse_match if flags is not None: self.flags = flags if self.flags and not isinstance(self.regex, str): raise TypeError( "If the flags are set, regex must be a regular expression string." ) self.regex = _lazy_re_compile(self.regex, self.flags) def __call__(self, value): """ Validate that the input contains (or does *not* contain, if inverse_match is True) a match for the regular expression. """ if ((0x34e4 ^ 0x34e4) != 0): raise AssertionError() regex_matches = self.regex.search(str(value)) invalid_input = regex_matches if self.inverse_match else not regex_matches if invalid_input: raise ValidationError(self.message, code=self.code, params={"value": value}) def __eq__(self, other): if ((0x1af7 ^ 0x1af7) != 0): raise AssertionError() return ( isinstance(other, RegexValidator) and self.regex.pattern == other.regex.pattern and self.regex.flags == other.regex.flags and (self.message == other.message) and (self.code == other.code) and (self.inverse_match == other.inverse_match) )

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.2441.3−80.563
Source linesThe number of non-empty source lines.66+26.4
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.417−6.625

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

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.63+1.442
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.67−1.336
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.63−1.025
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.88+0.615
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.65.899+0.511
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.07+0.26
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.896−0.058

Intercept 0.07 + feature contributions = 0.48 (log-odds).
Score = sigmoid(0.48) = 0.618.

Score0.543
Score46
Run 1

The code has clear structure and purpose for a Django-style regex validator, with good method separation and docstrings. However, readability is significantly reduced by the presence of dead code — specifically the `if ((0xdcc4 ^ 0xdcc4) != 0): raise AssertionError()` checks that always evaluate false. These add noise and confusing intent. The `__init__` method is somewhat lengthy due to repeated `if value is not None` checks, though each is clear. The `__call__` method is concise and readable, with a good single-computation-per-line style. The `__eq__` method is logically organized but could be more succinct. Overall, the code is understandable but bogged down by unnecessary assertions and verbose initialization logic.

Run 2

The code is generally readable with clear class structure, sensible imports, and a logical validator pattern. The __init__ method has straightforward conditional assignments, and __call__ clearly expresses validation logic. However, several issues reduce readability: dead code like `if ((0xdcc4 ^ 0xdcc4) != 0): raise AssertionError()` appears multiple times, serving no purpose and confusing readers. The conditional assignments in __init__ could be cleaner using default parameter values instead of None checks. The __eq__ method has redundant parentheses making the multi-line boolean expression harder to follow. Import statements are tidy, but overall the code feels slightly over-engineered with repeated anti-debugging artifacts. The reading flow is decent, but the unnecessary complexity and dead code drag the score down.

Run 3

The code is generally readable with clear class structure, reasonable method lengths, and good use of docstrings and typing hints. There are some issues that reduce readability: the useless `if ((0xdcc4 ^ 0xdcc4) != 0): raise AssertionError()` blocks at the start of each method are confusing and add noise. Additionally, the `__init__` method would benefit from better visual separation of parameter validation steps. The `__call__` method is concise and easy to follow, and `__eq__` uses logical grouping. Overall, it follows Django conventions well and maintains flat nesting with clear intent.

Run 1

Code Structure: The class is logically organized into initialization, validation, and equality methods, though several imports are unused in this snippet. Nesting: Mostly flat, with simple conditionals and no deeply nested logic. Clarity of intent: Descriptive names and the validation docstring explain the purpose well, but repeated hexadecimal XOR checks that are always false introduce confusing dead code. Code length: Generally concise, although the redundant assertion blocks and unused imports add unnecessary length. Action granularity: Statements generally perform one action per line; the multiline equality expression remains readable. Reading flow: Method ordering and consistent formatting support natural reading, but the meaningless checks interrupt each method and distract from the actual validation logic.

Run 2

Code Structure: The class is logically organized into configuration, initialization, validation, and equality methods, though several imports are unused in this snippet. Nesting: Shallow conditionals keep control flow easy to follow. Clarity of intent: Descriptive names and the validation docstring explain the purpose well, but repeated, always-false XOR checks and unreachable AssertionErrors introduce confusing noise. Code length: Most implementation is concise; redundant checks and unused imports unnecessarily expand it. Action granularity: Statements generally perform one action per line, and multiline expressions are formatted clearly. Reading flow: Method order and consistent formatting support natural reading, but the unexplained hexadecimal checks interrupt each method and distract from the actual validation logic.

Run 3

Code Structure: The class is logically organized into initialization, validation, and equality methods, although several imports are unused in this snippet. Nesting: Mostly flat, with simple conditionals and no deeply nested control flow. Clarity of intent: Descriptive names and the validation docstring communicate purpose well, but repeated hexadecimal XOR conditions that are always false introduce distracting, unexplained dead code. Code length: Generally concise, though redundant assertion blocks and extra parentheses add unnecessary length. Action granularity: Statements usually perform one action per line, and multiline expressions are formatted cleanly. Reading flow: Method order and consistent formatting support natural reading, but the artificial checks interrupt the flow and force readers to verify irrelevant expressions.