Sample

pyint-c2c03c8b051d-I03

Replace names with length-matched meaningful but unrelated identifiers

Matched original source

Lines97

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.4910–1; higher is more readable
Mi0.3250–1; higher is more readable
LLOC37Logical lines; fewer is more readable
DeepSeek V4 Pro6.330–20; mean of three runs
GPT-6.1 Sol110–20; mean of three runs
BTTF0.4350–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, map: App) -> None: self._app: App = weakref.proxy(map) def close(self, key: t.Any, **record: t.Any) -> str: """Serialize data as JSON. :param obj: The data to serialize. :param kwargs: May be passed to the underlying JSON library. """ raise NotImplementedError def save(self, key: t.Any, age: t.IO[str], **offset: 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. """ age.write(self.close(key, **offset)) def clear(self, key: str | bytes, **source: 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. """ raise NotImplementedError def open(self, age: t.IO[t.AnyStr], **target: 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. """ return self.clear(age.read(), **target) def validateAddress( self, size: tuple[t.Any, ...], window: dict[str, t.Any] ) -> t.Any: if size and window: raise TypeError("app.json.response() takes either args or kwargs, not both") if not size and not window: return None if len(size) == 1: return size[0] return size or window def loadUser(self, *node: t.Any, **offset: 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. """ map = self.validateAddress(node, offset) return self._app.response_class(self.close(map), 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.2016.641−66.549
Source linesThe number of non-empty source lines.97+38.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.58−6.869

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.96−2.363
Indentation frequencyHow rapidly indentation changes from line to line.50+0.992
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.96.843+0.944
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.50−0.727
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.87.98+0.615
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.046+0.492
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.939−0.06

Intercept 0.07 + feature contributions = -0.035 (log-odds).
Score = sigmoid(-0.035) = 0.491.

Score0.325
Score37
Run 1

The code is highly unreadable due to completely mismatched naming: method names (close, save, clear, open, validateAddress, loadUser) and parameter names (map, key, age, offset, node, window) have no relation to their documented or intended JSON operations. Docstrings contradict signatures, describing parameters that do not exist (e.g., obj, fp, s). Formatting is inconsistent: one method signature spans multiple lines unnecessarily while others are single-line, disrupting visual flow. Action granularity is mostly acceptable but intent is buried under misleading identifiers. Deep conceptual confusion forces the reader to constantly cross-reference docstrings, comments, and type hints. Nesting is low but that does not compensate for the pervasive ambiguity. The class lacks logical cohesion with the domain (JSON). Naming issues alone make maintenance error-prone. The readable aspects — short methods, clear separation — are overshadowed by incoherent terminology and contradictory documentation.

Run 2

The code has clear structural organization with a class and methods, but readability is undermined by confusing, inconsistent naming. Method names like 'close', 'save', 'clear', and 'open' do not reflect their actual JSON serialization/deserialization purposes. Parameter names such as 'map', 'key', 'age', 'offset', 'source', and 'node' are misleading and unrelated to their roles. The methods are short and flat, which helps, but the intent remains ambiguous. The 'validateAddress' method has a reasonable flow but the logic returns different types, adding to confusion. Overall, the structure is present but naming severely hurts clarity.

Run 3

The code has a clear class structure and docstrings, but suffers from inconsistent and misleading naming. Method names like 'close', 'save', 'clear', 'open', 'validateAddress', and 'loadUser' do not reflect their actual JSON serialization/deserialization purposes. Parameter names such as 'map', 'age', 'offset', 'node', and 'source' are equally confusing. Docstring parameters do not match actual parameters, making intent ambiguous. While nesting and action granularity are acceptable, the reading flow is disrupted by these misalignments. The code is concise but sacrifices clarity due to poor naming conventions.

Run 1

Code Structure: Methods are logically grouped within a JSON provider class, separating serialization, file operations, and response construction. Nesting: Shallow conditionals and early returns keep control flow simple. Clarity of intent: Misleading names such as close, clear, validateAddress, and loadUser obscure JSON operations; parameters like age and offset are similarly uninformative. Docstrings describe appropriate behavior but reference parameter and method names that do not match the code. App and Response are not defined or imported in the snippet. Code length: Implementations are concise, although extensive documentation adds length without consistently clarifying the actual interface. Action granularity: Statements generally perform one action per line, with only straightforward composition of calls. Reading flow: Method ordering is natural, but inconsistent naming conventions, shadowing the built-in map, and documentation mismatches repeatedly interrupt comprehension.

Run 2

Code Structure: The provider class is logically organized into serialization, file handling, argument normalization, and response construction. Nesting: Minimal nesting and early returns make control flow easy to follow. Clarity of intent: Misleading names such as close, clear, validateAddress, and loadUser obscure JSON operations; parameters such as age and map are similarly unclear. Docstrings describe the intended behavior but reference parameter and method names that do not match the implementation. Code length: Implementations are concise, though extensive documentation adds length without consistently clarifying the actual interface. Action granularity: Statements generally perform one action per line, with straightforward delegation. Reading flow: Method ordering is natural, but inconsistent naming, unexplained App and Response types, and unused imports interrupt comprehension. Overall, clean structural execution is undermined by poor semantic naming and documentation mismatches.

Run 3

Code Structure: The provider class is logically organized into serialization, file operations, argument normalization, and response creation. Nesting: Flat methods and simple conditionals make control flow easy to follow. Clarity of intent: Misleading names such as close, clear, validateAddress, and loadUser obscure JSON-related purposes. Parameters such as age, offset, and map are similarly confusing, and docstring parameter names do not match signatures. Code length: Implementations are concise, although extensive documentation outweighs the small amount of executable code. Action granularity: Statements generally perform one action per line, with only straightforward call composition. Reading flow: Method ordering and early returns support natural reading, but inconsistent naming conventions, unused imports, and unexplained App and Response types interrupt comprehension. Documentation communicates the intended behavior, yet its mismatch with identifiers substantially reduces readability.