Sample

pyint-f81aae7a02f9-I02

Shorten method, parameter, and local names without collisions

Matched original source

Lines84

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8720–1; higher is more readable
Mi0.2660–1; higher is more readable
LLOC36Logical lines; fewer is more readable
DeepSeek V4 Pro9.670–20; mean of three runs
GPT-6.1 Sol12.330–20; mean of three runs
BTTF0.4460–1; higher is more readable

Views

Source code

from __future__ import annotations import importlib.metadata import typing as t from contextlib import contextmanager from contextlib import ExitStack from copy import copy from types import TracebackType from urllib.parse import urlsplit import werkzeug.test from click.testing import CliRunner from click.testing import Result from werkzeug.test import Client from werkzeug.wrappers import Request as BaseRequest from .cli import ScriptInfo from .sessions import SessionMixin class EnvironBuilder(werkzeug.test.EnvironBuilder): """An :class:`~werkzeug.test.EnvironBuilder`, that takes defaults from the application. :param app: The Flask application to configure the environment from. :param path: URL path being requested. :param base_url: Base URL where the app is being served, which ``path`` is relative to. If not given, built from :data:`PREFERRED_URL_SCHEME`, ``subdomain``, :data:`SERVER_NAME`, and :data:`APPLICATION_ROOT`. :param subdomain: Subdomain name to append to :data:`SERVER_NAME`. :param url_scheme: Scheme to use instead of :data:`PREFERRED_URL_SCHEME`. :param json: If given, this is serialized as JSON and passed as ``data``. Also defaults ``content_type`` to ``application/json``. :param args: other positional arguments passed to :class:`~werkzeug.test.EnvironBuilder`. :param kwargs: other keyword arguments passed to :class:`~werkzeug.test.EnvironBuilder`. """ def __init__( self, app2: Flask, pat: str = "/", base: str | None = None, sub: str | None = None, url2: str | None = None, *arg: t.Any, **kwa: t.Any, ) -> None: assert not (base or sub or url2) or ( base is not None ) != bool(sub or url2), ( 'Cannot pass "subdomain" or "url_scheme" with "base_url".' ) if base is None: http = app2.config.get("SERVER_NAME") or "localhost" app3 = app2.config["APPLICATION_ROOT"] if sub: http = f"{sub}.{http}" if url2 is None: url2 = app2.config["PREFERRED_URL_SCHEME"] url3 = urlsplit(pat) base = ( f"{url3.scheme or url2}://{url3.netloc or http}" f"/{app3.lstrip('/')}" ) pat = url3.path if url3.query: pat = f"{pat}?{url3.query}" self.app = app2 super().__init__(pat, base, *arg, **kwa) def json2(self, obj2: t.Any, **kwa2: t.Any) -> str: """Serialize ``obj`` to a JSON-formatted string. The serialization will be configured according to the config associated with this EnvironBuilder's ``app``. """ return self.app.json.dumps(obj2, **kwa2)

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.1933.604−63.809
Source linesThe number of non-empty source lines.84+33.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.739−7.108

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.85−1.973
Indentation frequencyHow rapidly indentation changes from line to line.61+1.373
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.83.912+0.763
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.043+0.529
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.77.165+0.441
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
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.78.953+0.321

Intercept 0.07 + feature contributions = 1.921 (log-odds).
Score = sigmoid(1.921) = 0.872.

Score0.266
Score36
Run 1

This code is difficult to read due to multiple serious problems. Variable names are severely mangled (app2, pat, base, sub, url2, arg, kwa, url3, http, app3, obj2, kwa2, json2), making the purpose of each parameter and local variable opaque despite the docstring. The boolean logic in the assertion is convoluted and nearly impossible to parse mentally. Several lines chain multiple actions, reducing clarity. The `http` variable actually holds a server name or hostname, not an HTTP protocol or request object, confusing intent. The overall flow jumps between parameter aliases, config lookups, and string formatting with little organizational structure. The function signature forces readers to constantly map abbreviations back to the docstring. While the method is short, the heavy use of obscure aliases, cryptic boolean expressions, and misleading variable names significantly harms readability.

Run 2

The code exhibits several readability issues. Variable names like app2, pat, sub, url2, json2 are arbitrary and hurt clarity. The constructor's boolean logic for validation is convoluted and hard to parse. The base_url construction contains multiple nested conditionals and string formatting that could be simplified. However, the structure is generally logical with clear separation of concerns, and the docstring is thorough. The nesting is moderate but not excessive. The method signatures use type hints which aid understanding. The validation assertion message is clear. Overall, while the code follows some good practices, the confusing variable names and complex conditional logic significantly reduce readability.

Run 3

The code has some good structure and documentation, but several readability issues reduce its overall clarity. Naming of parameters and variables like 'app2', 'pat', 'sub', 'url2', 'url3' is confusing and non-descriptive, making the logic harder to follow. The constructor contains a complex boolean assertion that is difficult to parse at a glance. The use of 'assert' for input validation is also questionable for production code. The code is reasonably flat and the docstring is informative, but the flow inside __init__ could be clearer. The helper method 'json2' is concise but also suffers from the same naming issues. Overall, the code is functional and documented, but the unclear variable naming and complex conditional logic lower its readability score significantly.

Run 1

Code Structure: Imports, class documentation, initialization, and serialization are logically organized. Nesting: Mostly shallow, with manageable conditional blocks. Clarity of intent: The overall purpose is documented, but names such as app2, app3, pat, url2, and kwa obscure meaning; documented parameter names also differ from the actual signature. The compound assertion is difficult to interpret quickly, and json2 is an unclear method name. Code length: Implementation is reasonably concise, although the extensive documentation loses value because of naming inconsistencies. Action granularity: Statements generally perform one action per line, with readable multiline formatting. Reading flow: URL construction follows a sensible sequence, but cryptic identifiers and the assertion interrupt comprehension. Flask is referenced without a visible import, creating additional uncertainty in this standalone snippet.

Run 2

Code Structure: Imports and methods are logically organized, with environment setup contained in the constructor. Nesting: Mostly shallow, although several conditionals inside base-URL construction add complexity. Clarity of intent: The class docstring explains the purpose well, but names such as app2, app3, pat, url2, and kwa obscure meaning. Documented parameter names differ from actual names, and json2 does not clearly communicate serialization. The compound assertion is difficult to parse. Code length: Implementation is reasonably concise, but many imports are unused in this snippet and documentation is lengthy relative to the implementation. Action granularity: Statements generally perform one action per line; multiline expressions remain appropriately grouped. Reading flow: Setup proceeds naturally from configuration to URL construction and superclass initialization, but cryptic identifiers and mismatched documentation repeatedly interrupt comprehension.

Run 3

Code Structure: Imports and class methods are logically organized, with environment construction separated from JSON serialization. Nesting: Conditional nesting is shallow and manageable. Clarity of intent: Type hints and documentation help, but cryptic names such as app2, app3, pat, url2, and kwa obscure roles. The docstring uses parameter names that differ from the signature, adding confusion. Code length: The implementation is reasonably concise, though the documentation is lengthy relative to the code. Action granularity: Most lines perform one action; the compound assertion packs several conditions into a difficult-to-parse expression. Reading flow: Configuration lookup, URL construction, and superclass initialization follow a natural sequence, but inconsistent naming and awkward assertion formatting interrupt comprehension.