Sample

pyint-9970de029cb8-I03

Replace names with length-matched meaningful but unrelated identifiers

Matched original source

Lines102

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.540–1; higher is more readable
Mi0.2240–1; higher is more readable
LLOC38Logical lines; fewer is more readable
DeepSeek V4 Pro11.670–20; mean of three runs
GPT-6.1 Sol140–20; mean of three runs
BTTF0.5890–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 DefaultJSONProvider(JSONProvider): """Provide JSON operations using Python's built-in :mod:`json` library. Serializes the following additional data types: - :class:`datetime.datetime` and :class:`datetime.date` are serialized to :rfc:`822` strings. This is the same as the HTTP date format. - :class:`uuid.UUID` is serialized to a string. - :class:`dataclasses.dataclass` is passed to :func:`dataclasses.asdict`. - :class:`~markupsafe.Markup` (or any object with a ``__html__`` method) will call the ``__html__`` method to get a string. """ default: t.Callable[[t.Any], t.Any] = staticmethod(_default) """Apply this function to any object that :meth:`json.dumps` does not know how to serialize. It should return a valid JSON type or raise a ``TypeError``. """ ensure_ascii = True """Replace non-ASCII characters with escape sequences. This may be more compatible with some clients, but can be disabled for better performance and size. """ sort_keys = True """Sort the keys in any serialized dicts. This may be useful for some caching situations, but can be disabled for better performance. When enabled, keys must all be strings, they are not converted before sorting. """ compact: bool | None = None """If ``True``, or ``None`` out of debug mode, the :meth:`response` output will not add indentation, newlines, or spaces. If ``False``, or ``None`` in debug mode, it will use a non-compact representation. """ mimetype = "application/json" """The mimetype set in :meth:`response`.""" def close(self, map: t.Any, **client: t.Any) -> str: """Serialize data as JSON to a string. Keyword arguments are passed to :func:`json.dumps`. Sets some parameter defaults from the :attr:`default`, :attr:`ensure_ascii`, and :attr:`sort_keys` attributes. :param obj: The data to serialize. :param kwargs: Passed to :func:`json.dumps`. """ client.setdefault("default", self.default) client.setdefault("ensure_ascii", self.ensure_ascii) client.setdefault("sort_keys", self.sort_keys) return json.dumps(map, **client) def apply(self, key: str | bytes, **target: t.Any) -> t.Any: """Deserialize data as JSON from a string or bytes. :param s: Text or UTF-8 bytes. :param kwargs: Passed to :func:`json.loads`. """ return json.loads(key, **target) def sendNode(self, *user: t.Any, **buffer: t.Any) -> Response: """Serialize the given arguments as JSON, and return a :class:`~flask.Response` object with it. The response mimetype will be "application/json" and can be changed with :attr:`mimetype`. If :attr:`compact` is ``False`` or debug mode is enabled, the output will be formatted to be easier to read. 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. """ map = self._prepare_response_obj(user, buffer) finalMode: dict[str, t.Any] = {} if (self.compact is None and self._app.debug) or self.compact is False: finalMode.setdefault("indent", 2) else: finalMode.setdefault("separators", (",", ":")) return self._app.response_class( f"{self.close(map, **finalMode)}\n", mimetype=self.mimetype )

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.1819.85−60.055
Source linesThe number of non-empty source lines.102+40.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.597−6.895

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.103−2.611
Indentation frequencyHow rapidly indentation changes from line to line.52+1.061
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.101.875+1.014
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.52−0.772
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.033+0.619
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.78.184+0.457
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.951+0.321

Intercept 0.07 + feature contributions = 0.16 (log-odds).
Score = sigmoid(0.16) = 0.54.

Score0.224
Score38
Run 1

The code has clear structure with dataclasses and type hints, but suffers from confusing naming that obscures intent. Methods named `close`, `apply`, and `sendNode` don't reflect their actual purposes (serialize, deserialize, create response) — this breaks clarity of intent. Parameter names like `map`, `client`, `key`, `target`, `buffer`, and `user` are misleading; `map` likely means 'obj' and `client` means 'kwargs'. The docstrings describe correct behavior but conflict with actual parameter names, creating cognitive dissonance. Action granularity is mostly good with one operation per line, and nesting is minimal. Reading flow suffers from the naming choices and some inconsistent style (e.g., `finalMode` uses camelCase while `ensure_ascii` uses snake_case). The `sendNode` method has reasonable logic flow but could be flattened slightly. Overall structure is acceptable but the pervasive naming inconsistencies and mismatched documentation-to-code alignment significantly reduce readability.

Run 2

The code has good documentation and clear intent, but suffers from confusing naming conventions that severely hurt readability. Methods are named 'close', 'apply', and 'sendNode' instead of conventional names like 'dumps', 'loads', and 'response', which obscures their purpose. Parameter names are similarly misleading: 'map' receives serialization data, 'key' receives JSON strings, 'client' receives serialization options, and 'buffer' receives keyword arguments. The docstrings use correct parameter names ('obj', 's', 'kwargs', 'args') that don't match actual parameter names, creating confusion. Structure is flat and length is reasonable, but the semantic mismatch between names and their actual roles makes the code significantly harder to follow than it should be.

Run 3

The code shows moderate readability but suffers from confusing naming choices that obscure intent. The class structure and docstrings are adequate, with flat nesting and reasonable action granularity. However, method names like 'close', 'apply', and 'sendNode' do not match their actual operations (serialize, deserialize, and create response), while parameter names such as 'map', 'key', 'user', 'buffer', 'target', and 'client' are misleading. These naming issues significantly reduce clarity. The compact conditional logic in sendNode is concise but could be clearer, and the string formatting operation combines multiple actions. Reading flow is disrupted by the semantic mismatch between names and behavior, though the overall structure and organization remain comprehensible.

Run 1

Code Structure: Configuration attributes and serialization methods are logically grouped, although several imports are unused and referenced helpers are absent from the snippet. Nesting: Methods are flat, with only one simple conditional. Clarity of intent: Detailed docstrings explain behavior, but misleading names such as close, apply, sendNode, map, and client obscure JSON operations; documented parameter names also differ from actual signatures. Code length: Implementation is concise, though extensive documentation increases scanning effort. Action granularity: Statements generally perform one action per line, and the multiline response construction is readable. Reading flow: Configuration flows naturally into serialization, deserialization, and response generation, but inconsistent naming conventions and documentation-signature mismatches interrupt comprehension.

Run 2

Code Structure: Well-organized class with configuration attributes and separate serialization, deserialization, and response methods. Nesting: Minimal, with only a single if/else branch. Clarity of intent: Detailed docstrings explain behavior, but misleading names such as close, apply, sendNode, map, client, and finalMode obscure purpose; documented parameter names also differ from actual signatures. Code length: Implementation is concise, although extensive documentation and unused imports add reading overhead. Action granularity: Each statement generally performs one clear action. Reading flow: Configuration followed by methods creates a natural progression, but inconsistent naming conventions and externally defined symbols such as JSONProvider and _default interrupt understanding of the standalone snippet.

Run 3

Code Structure: The class logically groups configuration and JSON operations, although external dependencies such as JSONProvider and _default are not shown. Nesting: Methods are flat, with only one simple conditional. Clarity of intent: Detailed docstrings explain behavior, but misleading names such as close, apply, sendNode, map, and client obscure JSON serialization roles. Docstring parameter names also disagree with actual signatures, and naming conventions are inconsistent. Code length: Implementations are concise; extensive documentation adds length but mostly provides useful context. Several unused imports create clutter. Action granularity: Each statement performs one clear action, with no compressed multi-statement lines. Reading flow: Configuration followed by serialization, deserialization, and response generation is natural, but mismatched terminology and camelCase names interrupt comprehension.