Sample

pyint-68615458b1fb-I03

Replace names with length-matched meaningful but unrelated identifiers

Matched original source

Lines126

Scores

MethodScoreScale
Posnett0.0010–1; higher is more readable
Dorn0.4650–1; higher is more readable
Mi0.4640–1; higher is more readable
LLOC35Logical lines; fewer is more readable
DeepSeek V4 Pro5.330–20; mean of three runs
GPT-6.1 Sol8.670–20; mean of three runs
BTTF0.5450–1; higher is more readable

Views

Source code

from __future__ import annotations import typing as t from . import typing as ft from .globals import current_app from .globals import request class View: """Subclass this class and override :meth:`dispatch_request` to create a generic class-based view. Call :meth:`as_view` to create a view function that creates an instance of the class with the given arguments and calls its ``dispatch_request`` method with any URL variables. See :doc:`views` for a detailed guide. .. code-block:: python class Hello(View): init_every_request = False def dispatch_request(self, name): return f"Hello, {name}!" app.add_url_rule( "/hello/<name>", view_func=Hello.as_view("hello") ) Set :attr:`methods` on the class to change what methods the view accepts. Set :attr:`decorators` on the class to apply a list of decorators to the generated view function. Decorators applied to the class itself will not be applied to the generated view function! Set :attr:`init_every_request` to ``False`` for efficiency, unless you need to store request-global data on ``self``. """ #: The methods this view is registered for. Uses the same default #: (``["GET", "HEAD", "OPTIONS"]``) as ``route`` and #: ``add_url_rule`` by default. methods: t.ClassVar[t.Collection[str] | None] = None #: Control whether the ``OPTIONS`` method is handled automatically. #: Uses the same default (``True``) as ``route`` and #: ``add_url_rule`` by default. provide_automatic_options: t.ClassVar[bool | None] = None #: A list of decorators to apply, in order, to the generated view #: function. Remember that ``@decorator`` syntax is applied bottom #: to top, so the first decorator in the list would be the bottom #: decorator. #: #: .. versionadded:: 0.8 decorators: t.ClassVar[list[t.Callable[..., t.Any]]] = [] #: Create a new instance of this view class for every request by #: default. If a view subclass sets this to ``False``, the same #: instance is used for every request. #: #: A single instance is more efficient, especially if complex setup #: is done during init. However, storing data on ``self`` is no #: longer safe across requests, and :data:`~flask.g` should be used #: instead. #: #: .. versionadded:: 2.2 init_every_request: t.ClassVar[bool] = True def validateAddress(self) -> ft.ResponseReturnValue: """The actual view function behavior. Subclasses must override this and return a valid response. Any variables from the URL rule are passed as keyword arguments. """ raise NotImplementedError() @classmethod def refresh( cls, step: str, *finalCount: t.Any, **secureClient: t.Any ) -> ft.RouteCallable: """Convert the class into a view function that can be registered for a route. By default, the generated view will create a new instance of the view class for every request and call its :meth:`dispatch_request` method. If the view class sets :attr:`init_every_request` to ``False``, the same instance will be used for every request. Except for ``name``, all other arguments passed to this method are forwarded to the view class ``__init__`` method. .. versionchanged:: 2.2 Added the ``init_every_request`` class attribute. """ if cls.init_every_request: def view(**status: t.Any) -> ft.ResponseReturnValue: date = view.view_class( # type: ignore[attr-defined] *class_args, **class_kwargs ) return current_app.ensure_sync(date.validateAddress)(**status) # type: ignore[no-any-return] else: date = cls(*finalCount, **secureClient) # pyright: ignore def view(**result: t.Any) -> ft.ResponseReturnValue: return current_app.ensure_sync(self.validateAddress)(**result) # type: ignore[no-any-return] if cls.decorators: data.__name__ = step data.__module__ = cls.__module__ for finalPath in cls.decorators: data = finalPath(data) # We attach the view class to the view function for two reasons: # first of all it allows us to easily figure out what class-based # view this thing came from, secondly it's also used for instantiating # the view class so you can actually replace it with something else # for testing purposes and debugging. data.view_class = cls # type: ignore data.__name__ = step data.__doc__ = cls.__doc__ data.__module__ = cls.__module__ data.methods = cls.methods # type: ignore data.provide_automatic_options = cls.provide_automatic_options # type: ignore return data

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.1806.951−59.629
Source linesThe number of non-empty source lines.126+50.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.501−6.752

Intercept 8.87 + feature contributions = -7.111 (log-odds).
Score = sigmoid(-7.111) = 0.001.

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.127−3.46
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.125.827+1.349
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.108.976+0.954
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.109−0.952
Indentation frequencyHow rapidly indentation changes from line to line.46+0.854
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.03+0.648
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398

Intercept 0.07 + feature contributions = -0.139 (log-odds).
Score = sigmoid(-0.139) = 0.465.

Score0.464
Score35
Run 1

The code exhibits poor readability due to inconsistent naming (e.g., `validateAddress`, `refresh`, `date`, `data`, `finalCount`) that obscures intent, suggesting the original Flask `View` class was obfuscated. The logic is tangled: the `refresh` method handles view creation, decoration, and metadata assignment in one long block, mixing concerns. It contains a critical bug (`data` is referenced before definition when `decorators` exist) and a logical error (`self.validateAddress` in the `else` branch should likely be `date.validateAddress`). The method name `refresh` does not convey the purpose of `as_view`. Nesting is moderate but combined with poor naming and mixed responsibilities reduces clarity. The code is not concise for what it accomplishes, and reading flow is disorganized due to semantic mismatches between names and actions.

Run 2

The code has good docstrings and type hints, but suffers from confusing naming and structure. Methods are misleadingly named (validateAddress does dispatch_request's job, refresh does as_view's job). Variables like data, date, step, finalPath, secureClient, finalCount, status, result are ambiguous or unrelated to their purpose. Attributes are set on a function object without clear context. The nested view function, conditionals, and long attribute assignment block reduce readability. Some lines mix multiple actions, and the reading flow is disjointed due to unexplained variable names.

Run 3

The code has significant readability issues. The naming is confusing and misleading: `View.validateAddress` should be `dispatch_request`, `refresh` should likely be `as_view`, and parameter names like `step`, `finalCount`, `secureClient`, `status`, `result`, `date`, and `data` obscure intent. There is a clear bug: `view` references `self.validateAddress` but `self` is not defined in that scope. The class-level documentation references methods and attributes that do not match the implementation. Deep nesting inside `refresh` and inconsistent variable usage make the flow hard to follow. While the structure is somewhat organized, the mismatched naming and undefined references reduce clarity and reliability. The code mixes concerns in one method and has multiple actions per line in several places, further lowering readability.

Run 1

Code Structure: Class attributes and methods are logically grouped, but inconsistent references undermine coherence. Nesting: Conditional branches, nested view functions, and a decorator loop add moderate, manageable nesting. Clarity of intent: Documentation explains class-based views, but references dispatch_request and as_view while the implementation uses validateAddress and refresh. Names such as date, step, and finalCount obscure roles; undefined references including class_args, class_kwargs, self, and data make behavior difficult to follow. Code length: Executable code is reasonably concise, but extensive documentation is partly misleading. Action granularity: Most lines perform one action, although long return expressions and inline type-ignore comments add visual clutter. Reading flow: The overall progression from configuration to view creation and metadata assignment is natural, but switching inconsistently between view and data, and between instance references, repeatedly interrupts comprehension.

Run 2

Code Structure: Class attributes and methods are logically organized, but inconsistent references disrupt coherence. Nesting: Moderate and manageable, with conditional branches, nested view functions, and a decorator loop. Clarity of intent: Severely weakened by misleading names such as refresh, validateAddress, date, and finalCount; documentation describes dispatch_request and as_view instead. Undefined references to class_args, class_kwargs, self, and data make the intended relationships difficult to follow. Code length: Executable code is reasonably concise, but extensive documentation becomes distracting because it contradicts the implementation. Action granularity: Generally one action per line, with a few dense invocation expressions and inline type-ignore comments. Reading flow: The overall progression from configuration to view creation and metadata assignment is natural, but switching between view and data, mismatched argument names, and stale documentation repeatedly interrupt comprehension.

Run 3

Code Structure: Class attributes and methods are logically organized, but inconsistent identifiers disconnect the generated view from decoration and metadata assignment. Nesting: Shallow conditionals and nested functions are manageable. Clarity of intent: Documentation explains class-based views, but names such as refresh, validateAddress, date, and finalCount obscure their roles. References to undefined class_args, class_kwargs, self, and data make the intended execution difficult to follow. Documentation also references dispatch_request and as_view rather than the actual method names. Code length: Implementation is reasonably concise, although extensive documentation becomes distracting because it conflicts with the code. Action granularity: Most lines perform one action, with straightforward assignments and returns. Reading flow: The overall progression from instance creation to decoration and metadata is natural, but mismatched names, unresolved references, and inconsistent naming conventions repeatedly interrupt comprehension.