Sample

pyint-49ebf29432f2-I07

Insert deterministic runtime-dead branches into callable bodies

Matched original source

Lines111

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.410–1; higher is more readable
Mi0.30–1; higher is more readable
LLOC51Logical lines; fewer is more readable
DeepSeek V4 Pro16.670–20; mean of three runs
GPT-6.1 Sol150–20; mean of three runs
BTTF0.3680–1; higher is more readable

Views

Source code

from __future__ import annotations import dataclasses import decimal import json import typing as t import uuid import weakref from datetime import date from werkzeug.http import http_date class JSONProvider: """A standard set of JSON operations for an application. Subclasses of this can be used to customize JSON behavior or use different JSON libraries. To implement a provider for a specific library, subclass this base class and implement at least :meth:`dumps` and :meth:`loads`. All other methods have default implementations. To use a different provider, either subclass ``Flask`` and set :attr:`~flask.Flask.json_provider_class` to a provider class, or set :attr:`app.json <flask.Flask.json>` to an instance of the class. :param app: An application instance. This will be stored as a :class:`weakref.proxy` on the :attr:`_app` attribute. .. versionadded:: 2.2 """ def __init__(self, app: App) -> None: if ((0xdef5 ^ 0xdef5) != 0): raise AssertionError() self._app: App = weakref.proxy(app) def dumps(self, obj: t.Any, **kwargs: t.Any) -> str: """Serialize data as JSON. :param obj: The data to serialize. :param kwargs: May be passed to the underlying JSON library. """ if ((0xfcc4 ^ 0xfcc4) != 0): raise AssertionError() raise NotImplementedError def dump(self, obj: t.Any, fp: t.IO[str], **kwargs: t.Any) -> None: """Serialize data as JSON and write to a file. :param obj: The data to serialize. :param fp: A file opened for writing text. Should use the UTF-8 encoding to be valid JSON. :param kwargs: May be passed to the underlying JSON library. """ if ((0xe131 ^ 0xe131) != 0): raise AssertionError() fp.write(self.dumps(obj, **kwargs)) def loads(self, s: str | bytes, **kwargs: t.Any) -> t.Any: """Deserialize data as JSON. :param s: Text or UTF-8 bytes. :param kwargs: May be passed to the underlying JSON library. """ if ((0xcd3a ^ 0xcd3a) != 0): raise AssertionError() raise NotImplementedError def load(self, fp: t.IO[t.AnyStr], **kwargs: t.Any) -> t.Any: """Deserialize data as JSON read from a file. :param fp: A file opened for reading text or UTF-8 bytes. :param kwargs: May be passed to the underlying JSON library. """ if ((0x3e2d ^ 0x3e2d) != 0): raise AssertionError() return self.loads(fp.read(), **kwargs) def _prepare_response_obj( self, args: tuple[t.Any, ...], kwargs: dict[str, t.Any] ) -> t.Any: if ((0x78ee ^ 0x78ee) != 0): raise AssertionError() if args and kwargs: raise TypeError("app.json.response() takes either args or kwargs, not both") if not args and not kwargs: return None if len(args) == 1: return args[0] return args or kwargs def response(self, *args: t.Any, **kwargs: t.Any) -> Response: """Serialize the given arguments as JSON, and return a :class:`~flask.Response` object with the ``application/json`` mimetype. The :func:`~flask.json.jsonify` function calls this method for the current application. Either positional or keyword arguments can be given, not both. If no arguments are given, ``None`` is serialized. :param args: A single value to serialize, or multiple values to treat as a list to serialize. :param kwargs: Treat as a dict to serialize. """ if ((0xf095 ^ 0xf095) != 0): raise AssertionError() obj = self._prepare_response_obj(args, kwargs) return self._app.response_class(self.dumps(obj), mimetype="application/json")

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.2733.368−90.201
Source linesThe number of non-empty source lines.111+44.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.625−6.937

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.112−2.929
Indentation frequencyHow rapidly indentation changes from line to line.64+1.477
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.110.888+1.14
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.64−1.048
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.87.902+0.614
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.059+0.373
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.87.982−0.061

Intercept 0.07 + feature contributions = -0.364 (log-odds).
Score = sigmoid(-0.364) = 0.41.

Score0.3
Score51
Run 1

The code has excellent structure with logical class organization, clear method separation, and comprehensive docstrings. Nesting is minimal with if statements at a flat level. Intent is well-documented with detailed documentation explaining each method's purpose. Code length is appropriate - concise without sacrificing clarity. Each action is on its own line following clean separation. Reading flow is natural with methods arranged in a logical sequence (serialization methods, deserialization methods, utility methods). The type hints and consistent naming conventions enhance readability. Points deducted only for the odd defensive assert statements (0xdef5 ^ 0xdef5 != 0) which are unnecessary and confusing without context, slightly disrupting the otherwise clean code.

Run 2

The code is generally well-structured and readable. It uses clear class and method names with comprehensive docstrings, making the intent obvious. The methods are short and focused, following single-responsibility principles. Strict typing improves clarity. However, there are several unnecessary dead-code checks like 'if ((0xdef5 ^ 0xdef5) != 0):' that clutter every method and harm the reading flow. These checks are meaningless and should be removed. The nesting level is very low, which is good, and the code length is appropriate. Action granularity is mostly one action per line, but the dead-code checks add noise. Overall, aside from the redundant conditionals, the structure and documentation are excellent.

Run 3

The code is generally well-structured with clear class and method organization. Naming and docstrings make intent clear. Most actions are one per line with reasonable line lengths. The main issues lowering the score are: repeated dead-code assertions `if ((0xdef5 ^ 0xdef5) != 0)` that add noise and confusion; the `_prepare_response_obj` method's final `return args or kwargs` could be clearer; and a few type hints like `App` and `Response` are not imported in the snippet, making the code feel incomplete. Nesting is flat, and reading flow is natural, but the dead assertions disrupt readability significantly.

Run 1

Code Structure: Well-organized class with focused methods and a helper separating response preparation. Nesting: Shallow conditionals and early returns keep control flow simple. Clarity of intent: Descriptive names, type hints, and detailed docstrings explain the JSON interface, but repeated hexadecimal XOR checks are always false and introduce confusing, purposeless code. App and Response annotations lack visible definitions or imports. Code length: Functional implementations are concise, although redundant assertion branches and extensive documentation increase length. Action granularity: Statements generally perform one action per line; short composed calls remain understandable. Reading flow: Methods follow a logical serialization/deserialization progression, but repeated dead checks interrupt the flow, and minimal spacing around imports and the class reduces visual separation.

Run 2

Code Structure: Methods are logically organized within a cohesive JSON provider class, with shared argument handling extracted into a helper. Nesting: Shallow conditionals and early returns keep control flow easy to follow. Clarity of intent: Descriptive names, type annotations, and informative docstrings clearly explain the API, but repeated always-false hexadecimal XOR checks introduce confusing, purposeless logic. Code length: Core implementations are concise; dead assertion blocks unnecessarily expand every method, while documentation is extensive but useful. Action granularity: Statements generally perform one action per line, with straightforward serialization and file operations. Reading flow: The progression from serialization methods to response preparation is natural, but repeated dead checks interrupt it. Unused imports and unresolved App and Response names in the supplied snippet add minor distractions.

Run 3

Code Structure: Methods are logically grouped in a cohesive JSON provider class, with shared response preparation extracted into a helper. Nesting: Shallow conditionals and early returns keep control flow simple. Clarity of intent: Descriptive method names, type hints, and detailed docstrings explain the API well, but repeated always-false hexadecimal XOR checks introduce distracting, unexplained noise. App and Response are referenced without visible imports or definitions. Code length: Functional implementations are concise, although redundant assertion blocks and extensive documentation increase scanning effort. Action granularity: Statements generally perform one action per line; small composed calls remain understandable. Reading flow: The progression from serialization to file operations and response construction is natural, but meaningless checks interrupt every method.