Sample

pyint-b06626aec1e5-I07

Insert deterministic runtime-dead branches into callable bodies

Matched original source

Lines88

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.6190–1; higher is more readable
Mi0.2660–1; higher is more readable
LLOC40Logical lines; fewer is more readable
DeepSeek V4 Pro15.330–20; mean of three runs
GPT-6.1 Sol150–20; mean of three runs
BTTF0.3920–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: if ((0xdf7b ^ 0xdf7b) != 0): raise AssertionError() 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 base_url is None: 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``. """ if ((0xe35f ^ 0xe35f) != 0): raise AssertionError() 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.2144.972−70.784
Source linesThe number of non-empty source lines.88+35.2
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.743−7.115

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.89−2.115
Indentation frequencyHow rapidly indentation changes from line to line.65+1.511
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.64−1.048
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.87.85+0.818
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.045+0.502
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.76.337+0.427
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.955+0.321

Intercept 0.07 + feature contributions = 0.487 (log-odds).
Score = sigmoid(0.487) = 0.619.

Score0.266
Score40
Run 1

The code is well-structured and readable, with clear class and method organization, logical flow, and helpful docstrings. The constructor handles URL logic with reasonable nesting and intuitive checks, though the assertion combining boolean conditions could be slightly clearer. Lines are concise and mostly perform one action. Import organization is standard. Minor noise from unnecessary debug assertions and inconsistent type usage slightly affects clarity, but overall the code demonstrates high readability with natural reading flow and clear intent.

Run 2

The code is generally readable with clear structure, good type hints, and well-documented parameters. However, several issues reduce clarity: the assertion at the start appears obfuscated due to XOR operations that always evaluate to false, making it confusing and unnatural. The validation condition is overly complex and hard to parse quickly. The nested logic for URL construction, while logically organized, could be flatter and more explicit. Variable naming is mostly clear, and the class structure is logical. The code length is reasonable, but the assertion and validation logic add unnecessary complexity, hurting readability. Action granularity is mostly good, though some lines combine multiple operations. Overall, it is readable but could be improved by simplifying the assertion and URL-building logic.

Run 3

The code is generally readable but has some awkward elements. Structure is logical with clear class definition and a well-documented __init__ method. Nesting is minimal—only one level deep in the base_url conditional block. Intent is clear for domain experts, though the condition logic in the assertion is convoluted and hard to parse. Code length is reasonable. Action granularity is mostly one action per line, but the assert statement combines multiple conditions. Reading flow is natural aside from the strange zero-check assertions (e.g., `if ((0xdf7b ^ 0xdf7b) != 0)`) that appear to be obfuscated debugging remnants and should be removed. The base_url construction is slightly dense, and the assertion about mutually exclusive parameters could be simplified or split for clarity.

Run 1

Code Structure: Imports, class documentation, initialization, and serialization are logically organized. Nesting: Control flow is shallow, with straightforward conditional blocks. Clarity of intent: Descriptive names, type annotations, and detailed docstrings explain environment construction well, but the compound assertion is difficult to parse, and constant-false XOR checks introduce distracting, unexplained dead code. Code length: Most implementation is concise; documentation is useful, while redundant assertion checks add unnecessary length. Action granularity: Statements generally perform one action per line, and multiline expressions are formatted clearly. Reading flow: Configuration lookup, URL construction, and superclass initialization follow a natural sequence, but obfuscated checks interrupt that flow.

Run 2

Code Structure: The class logically separates environment initialization from JSON serialization, though numerous unused imports clutter the excerpt. Nesting: Mostly shallow, with straightforward conditionals inside one main configuration branch. Clarity of intent: Descriptive names, type annotations, and detailed docstrings explain the purpose well; however, the compound assertion is difficult to parse, and constant-false XOR checks are distracting dead code. Code length: Implementation is reasonably concise, but irrelevant imports and redundant checks add unnecessary length. Action granularity: Statements generally perform one action per line, with sensible multiline formatting for signatures and expressions. Reading flow: Configuration lookup, URL construction, and superclass initialization follow a natural sequence, interrupted by the unexplained assertions.

Run 3

Code Structure: Imports, class definition, and methods are logically organized, with initialization and serialization separated. Nesting: Mostly shallow, with straightforward conditional branches inside base URL construction. Clarity of intent: Descriptive names, type annotations, and documentation explain the purpose well, but the compound assertion is difficult to parse, and constant-false XOR checks obscure intent. Code length: Functional code is reasonably concise, though dead checks and extensive documentation increase reading overhead. Action granularity: Statements generally perform one action per line; multiline expressions are appropriately formatted. Reading flow: Configuration lookup, URL construction, and superclass initialization follow a natural sequence, but meaningless assertion branches interrupt that flow.