Sample

pyint-fb63a9d58800-SRC

Unmodified source class

Lines60

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8690–1; higher is more readable
Mi0.3750–1; higher is more readable
LLOC40Logical lines; fewer is more readable
DeepSeek V4 Pro170–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.4630–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 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. """ 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): 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.2118.047−69.896
Source linesThe number of non-empty source lines.60+24
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.381−6.571

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

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.57+1.234
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.61−1.123
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.59.854+0.427
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.063+0.332
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.88−0.062

Intercept 0.07 + feature contributions = 1.891 (log-odds).
Score = sigmoid(1.891) = 0.869.

Score0.375
Score40
Run 1

This code demonstrates strong readability with clear structure and purpose. Each method has a single responsibility, and action granularity is well-maintained - one logical operation per line. The __init__ method handles optional parameters cleanly without unnecessary complexity. The __call__ method is concise and its intent is immediately clear through the docstring and variable naming (regex_matches, invalid_input). Nesting is minimal with no deep conditionals. Import organization is logical with standard library, Django, and local imports separated. Minor deductions: the __eq__ method could use slightly better formatting with fewer parentheses, and the conditional logic in __call__ could benefit from a brief comment explaining inverse_match behavior, though the variable names help mitigate this. Overall the code follows Django's established patterns and maintains a natural reading flow.

Run 2

The code is highly readable with clear structure, minimal nesting, and explicit intent. The class is well-organized with logical attribute defaults and a straightforward constructor that validates inputs. The __call__ method is concise and uses descriptive variable names (regex_matches, invalid_input) to clarify logic. Action granularity is appropriate—each step is on its own line. The __eq__ method is flat and readable, though it is slightly verbose. Overall, the code follows Django conventions, uses type-checking appropriately, and maintains a natural reading flow from imports to class definition to methods.

Run 3

The code demonstrates clear logical organization, with a single class focused on regex validation. The structure is clean: class attributes are defined upfront, followed by a well-organized __init__ method with sensible parameter handling. Nesting is minimal, with only one conditional inside __call__ and no deeply nested logic. Intent is clear from descriptive names like RegexValidator, regex_matches, and invalid_input. Code length is appropriate—concise but not overly compressed. Action granularity is mostly good, with one meaningful operation per line, though some lines like the __eq__ comparison chain could be split for readability. Reading flow is natural: imports are grouped, the class is well-documented, and methods follow logical order. The code maintains Django conventions and is largely self-explanatory. Minor deductions for the dense __eq__ method and slightly long __init__ signature, but overall it is highly readable.

Run 1

Code Structure: The class is logically organized into defaults, initialization, validation, and equality comparison, though several imports are unused in this snippet. Nesting: Control flow is shallow, with straightforward conditionals and no deeply nested blocks. Clarity of intent: Descriptive names, a useful validation docstring, and an explicit error message make the purpose clear; the inverse-match conditional requires slight extra thought. Code length: The implementation is appropriately concise, although initialization repeats similar assignment checks. Action granularity: Each statement performs a single clear action, and multiline expressions are formatted cleanly. Reading flow: Methods follow a natural sequence, with consistent indentation and spacing; an additional blank line before the class would improve separation from imports.

Run 2

Code Structure: Imports, class defaults, initialization, validation, and equality comparison are logically organized into focused methods. Nesting: Mostly flat, with simple conditionals and no deeply nested control flow. Clarity of intent: Descriptive names and the validation docstring make the purpose clear, though the inverse-match expression requires brief attention. Code length: Concise overall; repeated initialization checks are understandable, but several imports are unused in this snippet. Action granularity: Each statement performs one clear action, and multiline expressions are formatted consistently. Reading flow: The progression from configuration to validation to comparison is natural. Minor drawbacks include the unused imports, limited documentation of initialization options, and redundant parentheses in some equality checks.

Run 3

Code Structure: The class is logically organized into defaults, initialization, validation, and equality comparison, though unused imports add clutter. Nesting: Control flow is shallow, with straightforward conditionals and no deeply nested blocks. Clarity of intent: Descriptive names and the validation docstring make the purpose clear; the inverse-match expression requires slightly more attention. Code length: The implementation is appropriately concise, although repeated initialization checks add some verbosity. Action granularity: Each statement performs one clear action, and longer expressions are formatted across lines for readability. Reading flow: Methods follow a natural sequence, with consistent formatting and readable error handling. Minor distractions include unnecessary parentheses in parts of the equality comparison and imports unrelated to the displayed class.