Sample

pyint-988ca5c2221c-I06

Invert eligible conditions and exchange their branches

Matched original source

Lines86

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8780–1; higher is more readable
Mi0.2660–1; higher is more readable
LLOC37Logical lines; fewer is more readable
DeepSeek V4 Pro140–20; mean of three runs
GPT-6.1 Sol15.330–20; mean of three runs
BTTF0.4660–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, app: Flask, path: str = "/", base_url: str | None = None, subdomain: str | None = None, url_scheme: str | None = None, *args: t.Any, **kwargs: t.Any, ) -> None: assert not (base_url or subdomain or url_scheme) or ( base_url is not None ) != bool(subdomain or url_scheme), ( 'Cannot pass "subdomain" or "url_scheme" with "base_url".' ) if not (base_url is None): pass else: http_host = app.config.get("SERVER_NAME") or "localhost" app_root = app.config["APPLICATION_ROOT"] if subdomain: http_host = f"{subdomain}.{http_host}" if url_scheme is None: url_scheme = app.config["PREFERRED_URL_SCHEME"] url = urlsplit(path) base_url = ( f"{url.scheme or url_scheme}://{url.netloc or http_host}" f"/{app_root.lstrip('/')}" ) path = url.path if url.query: path = f"{path}?{url.query}" self.app = app super().__init__(path, base_url, *args, **kwargs) def json_dumps(self, obj: t.Any, **kwargs: 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(obj, **kwargs)

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.1968.287−64.953
Source linesThe number of non-empty source lines.86+34.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.714−7.071

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.87−2.044
Indentation frequencyHow rapidly indentation changes from line to line.63+1.442
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.85.888+0.791
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.041+0.542
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.78.023+0.454
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.954+0.321

Intercept 0.07 + feature contributions = 1.974 (log-odds).
Score = sigmoid(1.974) = 0.878.

Score0.266
Score37
Run 1

The code is generally well-structured and readable. It has clear imports, logical class definition, and good use of type hints. The constructor has a complex boolean assertion that is hard to parse due to mixed operators and unclear intent, which slightly hurts readability. The if/else for base_url is awkward—it uses a negative condition with an empty 'pass' branch, then handles the actual logic in an else branch, which is backwards from typical flow. Nesting is shallow and action granularity is mostly one action per line. The docstring is thorough and helpful. The logic for URL construction could be extracted for clarity. Overall, the code is maintainable with minor clarity issues in the assertion and conditional structure.

Run 2

The code is well-structured with clear separation of concerns, following a logical flow through class definition, documentation, and method implementation. Imports are organized by source. Nesting remains flat—the if/else logic in the constructor has only one level. Type annotations and docstrings clearly communicate intent. Functionality is grouped into appropriate methods, each handling a single action per line in most cases. The unusual `if not (base_url is None): pass else:` pattern is slightly awkward and reduces readability compared to a simple `if base_url is None:`. Additionally, the assertion condition is complex and could be simplified with intermediate variables. Overall, the code reads naturally despite these minor issues.

Run 3

The code has reasonable structure and docstrings, but suffers from significant readability issues. The assertion in __init__ is deeply convoluted, mixing boolean logic with string formatting, making the intent unclear. The conditional block 'if not (base_url is None): pass else: ...' is an anti-pattern that should be inverted to avoid unnecessary nesting and the empty pass branch. The base_url construction mixes URL parsing and string concatenation in a way that obscures the logic. Type hints and imports are generally good, and method granularity is acceptable, but the overall flow is disrupted by awkward conditionals and complex expressions. The docstring is helpful but the code itself requires careful reading to understand the URL-building logic. The negation-heavy checks and mixed boolean operations reduce clarity significantly.

Run 1

Code Structure: Imports, the class, and its methods are logically organized, with thorough documentation and type annotations. Nesting: Mostly shallow, but the empty if branch and surrounding else unnecessarily indent the main initialization logic. Clarity of intent: Descriptive names and docstrings explain environment construction well; however, the compound assertion and double-negative condition obscure otherwise straightforward validation and default handling. Code length: Generally appropriate, though the pass branch is redundant and the documentation is lengthy relative to the implementation. Action granularity: Statements generally perform one action each, with clearly separated configuration lookup, URL parsing, and initialization. Reading flow: The progression from configuration defaults to URL construction and superclass initialization is natural, but the assertion and inverted conditional interrupt it. Flask is referenced without a visible import, leaving its type context incomplete in this snippet.

Run 2

Code Structure: Imports, class documentation, initialization, and serialization are logically organized. Nesting: Generally shallow, but the empty if branch and else unnecessarily indent the main initialization logic. Clarity of intent: Descriptive names, type hints, and detailed docstrings explain the purpose; however, the compound assertion and double-negative condition obscure straightforward validation and default handling. Code length: Mostly proportionate to functionality, though the pass branch is redundant and documentation dominates this small class. Action granularity: Statements generally perform one action per line, with clear intermediate variables. Reading flow: Configuration lookup, URL construction, and superclass initialization follow a natural sequence, interrupted slightly by awkward conditional phrasing and the dense assertion.

Run 3

Code Structure: Imports, a documented class, and two focused methods provide logical organization. Nesting: Mostly shallow, although the empty if branch and its else unnecessarily indent the main setup logic. Clarity of intent: Descriptive names, type hints, and detailed documentation clarify environment construction; the compound assertion and negated None check require extra interpretation. Code length: Reasonably concise for its functionality, but the pass branch adds avoidable code. Action granularity: Statements generally perform one action per line, with multiline expressions formatted clearly. Reading flow: Configuration lookup, URL construction, and superclass initialization follow a natural sequence, though the assertion and redundant conditional interrupt that flow.