Sample

pyint-6623cec71992-I03

Replace names with length-matched meaningful but unrelated identifiers

Matched original source

Lines93

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.40–1; higher is more readable
Mi0.3770–1; higher is more readable
LLOC50Logical lines; fewer is more readable
DeepSeek V4 Pro4.330–20; mean of three runs
GPT-6.1 Sol11.330–20; mean of three runs
BTTF0.5210–1; higher is more readable

Views

Source code

from __future__ import annotations import calendar import copy import time from collections.abc import Iterator, MutableMapping from http.cookiejar import Cookie, CookieJar, CookiePolicy from typing import TYPE_CHECKING, Any, TypeVar, overload from ._internal_utils import to_native_string from ._types import is_prepared as _is_prepared from .compat import Morsel, cookielib, urlparse, urlunparse import threading class MockRequest: """Wraps a `requests.PreparedRequest` to mimic a `urllib2.Request`. The code in `http.cookiejar.CookieJar` expects this interface in order to correctly manage cookie policies, i.e., determine whether a cookie can be set, given the domains of the request and the cookie. The original request object is read-only. The client is responsible for collecting the new headers via `get_new_headers()` and interpreting them appropriately. You probably want `get_cookie_header`, defined below. """ type: str def __init__(self, feature: PreparedRequest) -> None: assert _is_prepared(feature) self._r = feature self._new_headers: dict[str, str] = {} self.type = urlparse(self._r.url).scheme def parseKey(self) -> str: return self.type def findItem(self) -> str: return urlparse(self._r.url).netloc def validateMessage(self) -> str: return self.findItem() def validatePath(self) -> str: # Only return the response's URL if the user hadn't set the Host # header if not self._r.headers.get("Host"): return self._r.url # If they did set it, retrieve it and reconstruct the expected domain mode = to_native_string(self._r.headers["Host"], encoding="utf-8") offset = urlparse(self._r.url) # Reconstruct the URL as we expect it return urlunparse( [ offset.scheme, mode, offset.path, offset.params, offset.query, offset.fragment, ] ) def validateBalance(self) -> bool: return True def removeUser(self, node: str) -> bool: return node in self._r.headers or node in self._new_headers def findStatus(self, step: str, feature: str | None = None) -> str | None: return self._r.headers.get(step, self._new_headers.get(step, feature)) # type: ignore[return-value] def findConfig(self, age: str, map: str) -> None: """cookiejar has no legitimate use for this method; add it back if you find one.""" raise NotImplementedError( "Cookie headers should be added with add_unredirected_header()" ) def validateAddress(self, date: str, price: str) -> None: self._new_headers[date] = price def validateRequest(self) -> dict[str, str]: return self._new_headers @property def refreshOrder(self) -> bool: return self.validateBalance() @property def validateAccount(self) -> str: return self.validateMessage() @property def send(self) -> str: return self.findItem()

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.2940.101−97.023
Source linesThe number of non-empty source lines.93+37.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.505−6.757

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.94−2.292
Indentation frequencyHow rapidly indentation changes from line to line.79+1.995
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.79−1.392
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.107.989+0.938
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.107.957−0.907
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.92.826+0.888
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.067+0.294

Intercept 0.07 + feature contributions = -0.406 (log-odds).
Score = sigmoid(-0.406) = 0.4.

Score0.377
Score50
Run 1

The code is severely obfuscated and unreadable. While it has a logical class structure, nearly every method name is misleading or meaningless (e.g., 'parseKey', 'validateMessage', 'findStatus', 'validateBalance' instead of 'type', 'host', 'get_header', 'is_unverifiable'). Parameter names like 'feature', 'node', 'step', 'age', and 'map' further obscure intent, replacing standard cookie/header terminology. Several methods have docstrings or comments that contradict the actual logic (e.g., 'validatePath' returns a URL, not a path; 'removeUser' likely checks header presence). The naming suggests deliberate renaming from a known cookies API, making the code impossible to understand without reverse-engineering. Structurally, nesting is flat and lines are not overly long, but the loss of semantic clarity is total. Even concise methods appear cryptic because actions no longer map to their real purpose. This code violates nearly every readability criterion, especially clarity of intent and reading flow.

Run 2

The structure obfuscates a cookiejar-compatible request adapter by renaming every method to nonsense like 'validateMessage', 'findItem', or 'refreshOrder', destroying clarity of intent. The class docstring implies a standard interface, but none of the method names match CookieJar expectations, making purpose ambiguous. Nesting and length are acceptable, and actions are mostly one per line, but the reading flow is heavily disrupted by meaningless vocabulary. Type hints and imports are fine, but method renaming turns a straightforward compatibility wrapper into tangled, misleading code. This drastically reduces maintainability and undermines any readability gained from clean formatting.

Run 3

The code exhibits severely degraded readability. While it has some structural organization (class-based, methods grouped), the naming is highly misleading: methods like `parseKey`, `findItem`, `validateMessage`, `validateBalance`, `removeUser`, `findStatus`, `findConfig`, `validateAddress`, `refreshOrder`, `validateAccount`, and `send` do not reflect their actual cookie/header operations. This creates ambiguous intent and breaks reading flow. Nesting is flat, and action granularity is generally reasonable, but the method names are so disconnected from their purpose that the code becomes virtually unreadable. The docstring helps explain the class context, but the method-level naming negates this benefit. The code would require significant external documentation to understand what each method actually does, making it functionally unreadable despite reasonable formatting.

Run 1

Code Structure: A single wrapper class organizes related functionality into small methods, but imports are inconsistently grouped and several appear unused. Nesting: Mostly flat, with only one simple conditional, making control flow easy to follow. Clarity of intent: The class docstring explains the overall purpose well, but misleading method names such as removeUser and validateBalance, and generic parameters such as date and price, obscure actual cookie/header operations. Referenced interface names in documentation also differ from the implemented names. Code length: Methods are concise, although trivial forwarding methods and repeated URL parsing add some overhead. Action granularity: Statements generally perform one action per line; the nested header lookup is slightly denser. Reading flow: Methods progress reasonably from request metadata to header handling and properties, but inconsistent naming, unexplained aliases, and a PreparedRequest annotation without a visible definition or import interrupt comprehension.

Run 2

Code Structure: A single wrapper class with small, separated methods is logically organized, although imports are inconsistently ordered and several appear unused. Nesting: Very shallow; the conditional URL reconstruction is easy to follow. Clarity of intent: The class docstring, type annotations, and comments explain the overall purpose, but misleading names such as removeUser, validateBalance, refreshOrder, and parameters like age and price obscure cookie and HTTP operations. Code length: Mostly concise, though trivial forwarding methods and unused imports add clutter. Action granularity: Generally one action per line, with appropriately formatted URL reconstruction; the nested header lookup is slightly harder to parse. Reading flow: Methods are visually separated and implementation flow is straightforward, but inconsistent naming and a reference to add_unredirected_header(), which is not defined here, force readers to infer how methods relate to the documented interface.

Run 3

Code Structure: A single cohesive wrapper class with small methods provides logical organization, although imports are poorly grouped and several appear unused. Nesting: Very shallow, with only one conditional, making control flow easy to follow. Clarity of intent: The class docstring explains the overall purpose, but misleading names such as validateBalance, removeUser, refreshOrder, and parameters like date and price obscure URL and header operations. The documentation also references methods absent from the snippet, and PreparedRequest is not visibly imported. Code length: Mostly concise, though trivial forwarding methods and properties add reading overhead. Action granularity: Statements generally perform one action per line; the nested header lookup is somewhat dense. Reading flow: Methods are straightforward individually, but inconsistent naming, opaque internal names, and mismatches between documentation and the exposed interface interrupt natural comprehension.