Sample

pyint-87c251fedd57-I08

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

Matched original source

Lines32

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.5430–1; higher is more readable
Mi0.4950–1; higher is more readable
LLOC22Logical lines; fewer is more readable
DeepSeek V4 Pro11.330–20; mean of three runs
GPT-6.1 Sol14.670–20; mean of three runs
BTTF0.5980–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): running_total = 0 for current_number in range(1, 6): running_total += current_number 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.846−27.918
Source linesThe number of non-empty source lines.32+12.8
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.657−6.986

Intercept 8.87 + feature contributions = -13.234 (log-odds).
Score = sigmoid(-13.234) = 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.046+0.5
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.97+0.447
Indentation frequencyHow rapidly indentation changes from line to line.32+0.37
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.32−0.313
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.33−0.132
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.31.974+0.037

Intercept 0.07 + feature contributions = 0.174 (log-odds).
Score = sigmoid(0.174) = 0.543.

Score0.495
Score22
Run 1

The code imports appear organized but contain unused imports (math, re, Path, urlsplit, MAX_URL_LENGTH, is_valid_ipv6_address, _lazy_re_compile), reducing clarity. The class structure is logical, but the 'clean' method contains an unnecessary loop that computes a running total never used in the return value, making the intent confusing and the code longer than needed. Nesting is flat, which is good, but action granularity is mixed; most lines are single-action, yet the loop body adds irrelevant logic. The reading flow is disrupted by this dead code. While the validator pattern is recognizable, the extraneous loop and unused imports lower overall readability.

Run 2

The code has clear imports and a straightforward class structure, but the MinLengthValidator's clean method contains an unexplained loop that calculates a running_total variable which is never used, making the intent ambiguous. The validator logic itself is simple and readable, with proper use of Django's BaseValidator patterns. However, the unused loop creates confusion about the purpose of the clean method, detracting from overall readability. The class organization is good with logical grouping of message, code, and methods, but the dead code reduces clarity and efficiency.

Run 3

The code has reasonable imports and a conventional Django validator class structure with clear class attributes, a simple compare method, and a clear return in clean(). However, it includes a completely unrelated loop inside clean() that calculates a running_total but never uses it, which seriously breaks clarity of intent and readability. The clean() method performs multiple unrelated actions (unnecessary loop and the actual length calculation) without separation. While there is no deep nesting and the reading flow is mostly natural, the dead code introduces confusion, making the purpose ambiguous. Additionally, several imported modules (ipaddress, math, re, etc.) appear unused, adding noise. Concise in length but flawed in structure and intent due to the extraneous loop and unused imports.

Run 1

Code Structure: The validator class logically groups its message, error code, comparison, and length calculation, but numerous unused imports add clutter, and BaseValidator is not defined or imported in the snippet. Nesting: Shallow nesting makes the methods easy to scan. Clarity of intent: The class name and comparison clearly express minimum-length validation, but the unrelated running_total loop obscures the purpose of clean(). Code length: The core implementation is concise, yet the unused imports and ineffective loop unnecessarily lengthen it. Action granularity: Statements generally perform one action per line. Reading flow: Imports followed by class configuration and methods provide a natural progression, although the irrelevant calculation interrupts the otherwise direct flow.

Run 2

Code Structure: The validator class is logically organized with message metadata and separate comparison and cleaning methods, but numerous unused imports and the undefined BaseValidator obscure its context. Nesting: Shallow nesting makes the code easy to follow. Clarity of intent: The class name, message, and comparison clearly express minimum-length validation; however, the unused running_total calculation distracts from clean's actual purpose. Code length: The core validator is concise, but irrelevant imports and an unnecessary loop add clutter. Action granularity: Each statement performs one clear action, and the multiline message is formatted sensibly. Reading flow: Class members follow a natural order, but the unrelated arithmetic interrupts the straightforward path to returning len(x).

Run 3

Code Structure: Imports, class attributes, and methods are logically organized, but numerous unused imports and the unshown BaseValidator definition add noise. Nesting: Minimal nesting makes the code easy to scan. Clarity of intent: The class name, validation message, and comparison clearly convey minimum-length validation; however, the unused running_total calculation obscures the purpose of clean(), and parameter names a, b, and x are vague. Code length: The validator is short, but the unnecessary loop and imports make it longer than needed. Action granularity: Each statement performs one action, and the multiline message is formatted clearly. Reading flow: The progression from metadata to comparison to length extraction is natural, except for the irrelevant arithmetic loop interrupting clean().