Sample

pyint-ca6ec65cca0e-I01

Remove comments and docstrings

Matched original source

Lines29

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.7050–1; higher is more readable
Mi0.4950–1; higher is more readable
LLOC19Logical lines; fewer is more readable
DeepSeek V4 Pro150–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.740–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): return a < b def clean(self, x): 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.722.67−23.848
Source linesThe number of non-empty source lines.29+11.6
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.687−7.03

Intercept 8.87 + feature contributions = -10.409 (log-odds).
Score = sigmoid(-10.409) = 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
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.043+0.522
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.75.9+0.45
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Indentation frequencyHow rapidly indentation changes from line to line.29+0.266
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.30−0.026
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.28.896−0.006

Intercept 0.07 + feature contributions = 0.87 (log-odds).
Score = sigmoid(0.87) = 0.705.

Score0.495
Score19
Run 1

The code is concise and logically structured. Each method has a single, clear responsibility (compare, clean), and action granularity is one action per line, which enhances readability. Nesting is flat, and the class definition is minimal with clear imports. The use of Django's BaseValidator and deconstructible decorator implies a clear intent: creating a reusable min-length validator. The message attribute uses ngettext_lazy for correct pluralization, showing thoughtful design. The code is short and direct, with no ambiguity, making it easy to follow. Minor deductions for relying on inherited behavior (BaseValidator) without showing its implementation, which may require readers to check Django's source to fully understand how 'compare' and 'clean' are used in validation. Overall, very readable.

Run 2

The code is highly readable, with a clear structure and purpose. It follows Django validator conventions, using a deconstructible decorator and inheriting from BaseValidator. The class is concise and focuses on a single responsibility. However, the clean method's parameter 'x' is ambiguous—it would be clearer as 'value' or 'input_string'. The comparison logic 'a < b' is abstract without context, but this is consistent with the parent class design. Overall, the code is flat, concise, and follows natural reading flow, making it easy to understand for developers familiar with Django.

Run 3

The code is generally readable but has some organizational and clarity issues. The imports are numerous and include internal Django modules (_lazy_re_compile), which can confuse readers about which are used and why. The class MinLengthValidator inherits from BaseValidator, but that class is not imported or defined in this snippet, making the code incomplete and harder to evaluate. The message attribute uses ngettext_lazy correctly, but without context the logic is non-obvious. The methods compare and clean are concise and have clear intent, but they rely on understanding BaseValidator's contract. The code lacks comments explaining the validator's role or the lazy translation mechanism. Nesting is flat and action granularity is good. Overall, the piece is concise but requires external context to fully understand, reducing its standalone readability.

Run 1

Code Structure: The validator is logically organized, with class metadata followed by small methods. Nesting: Minimal nesting makes the code easy to scan. Clarity of intent: The class name, validation message, and straightforward comparisons clearly express minimum-length validation, though generic parameter names and the undefined BaseValidator reduce standalone clarity. Code length: The implementation is concise, but numerous unused imports add clutter. Action granularity: Each method performs one simple action, and statements are clearly separated. Reading flow: The progression from message and error code to comparison and length extraction is natural; the multiline message remains readable.

Run 2

Code Structure: The validator class is logically organized, with metadata followed by comparison and cleaning methods, though unrelated imports add clutter and BaseValidator is not defined or imported in the snippet. Nesting: Minimal nesting makes the code easy to scan. Clarity of intent: The class name, validation message, and error code clearly communicate minimum-length validation; generic parameter names a, b, and x are less descriptive. Code length: The implementation is concise, although several imports appear unused. Action granularity: Each statement performs a single clear action. Reading flow: The class reads naturally from configuration to behavior, and the multiline message is formatted consistently.

Run 3

Code Structure: A well-organized validator class separates configuration from comparison and length calculation, though BaseValidator is not defined or imported in the snippet. Nesting: Minimal nesting makes the code easy to scan. Clarity of intent: The class name, validation message, and method implementations clearly express minimum-length validation; generic parameter names are slightly less descriptive. Code length: The implementation is concise, but numerous unused imports add clutter. Action granularity: Each statement performs one clear action, and the multiline message remains readable. Reading flow: Configuration followed by short methods creates a natural progression, although import clutter and the missing base-class context slightly interrupt understanding.