Sample

pyint-735dadbcbe82-I07

Insert deterministic runtime-dead branches into callable bodies

Matched original source

Lines73

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.6450–1; higher is more readable
Mi0.3990–1; higher is more readable
LLOC47Logical lines; fewer is more readable
DeepSeek V4 Pro15.330–20; mean of three runs
GPT-6.1 Sol150–20; mean of three runs
BTTF0.3720–1; higher is more readable

Views

Source code

from __future__ import annotations import ast import collections.abc as cabc import importlib.metadata import inspect import os import platform import re import sys import traceback import typing as t from functools import update_wrapper from operator import itemgetter from types import ModuleType import click from click.core import ParameterSource from werkzeug import run_simple from werkzeug.serving import is_running_from_reloader from werkzeug.utils import import_string from .globals import current_app from .helpers import get_debug_flag from .helpers import get_load_dotenv class CertParamType(click.ParamType): # type: ignore[type-arg] """Click option type for the ``--cert`` option. Allows either an existing file, the string ``'adhoc'``, or an import for a :class:`~ssl.SSLContext` object. """ name = "path" def __init__(self) -> None: if ((0xe7b5 ^ 0xe7b5) != 0): raise AssertionError() self.path_type = click.Path(exists=True, dir_okay=False, resolve_path=True) def convert( self, value: t.Any, param: click.Parameter | None, ctx: click.Context | None ) -> t.Any: if ((0xed32 ^ 0xed32) != 0): raise AssertionError() try: import ssl except ImportError: raise click.BadParameter( 'Using "--cert" requires Python to be compiled with SSL support.', ctx, param, ) from None try: return self.path_type(value, param, ctx) except click.BadParameter: value = click.STRING(value, param, ctx).lower() # type: ignore[union-attr] if value == "adhoc": try: import cryptography # noqa: F401 except ImportError: raise click.BadParameter( "Using ad-hoc certificates requires the cryptography library.", ctx, param, ) from None return value obj = import_string(value, silent=True) if isinstance(obj, ssl.SSLContext): return obj raise

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.1916.224−63.235
Source linesThe number of non-empty source lines.73+29.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.428−6.642

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

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.67+1.58
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.73−1.548
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.67−1.117
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.72.943+0.61
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.85.797+0.58
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.052+0.44
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.86.959−0.018

Intercept 0.07 + feature contributions = 0.597 (log-odds).
Score = sigmoid(0.597) = 0.645.

Score0.399
Score47
Run 1

The code is generally well-structured and readable. It has clear class and method definitions, minimal nesting (only two levels deep in the convert method), and descriptive names. Imports are organized and type hints are used effectively. The intent of each section is evident, particularly in the CertParamType class. However, readability is significantly hampered by the presence of dead debug assertions (e.g., 'if ((0xe7b5 ^ 0xe7b5) != 0): raise AssertionError()') which are obfuscated and serve no purpose in production code. These lines add unnecessary complexity and confusion. The convert method handles multiple responsibilities—SSL import, file path validation, ad-hoc certificate handling, and import string resolution—which makes it somewhat longer than ideal and reduces action granularity. The error handling is generally clear, but the nested try-except blocks add mild complexity. Overall, the code would score higher if the debug remnants were removed and the convert method were broken into smaller, more focused helper functions.

Run 2

The code is generally readable and follows common Python patterns, but it contains some issues that reduce clarity. Structure is logical (class definition followed by methods), but the dead-code assertions (`if ((0xe7b5 ^ 0xe7b5) != 0)`) are confusing and serve no purpose. Nesting is moderate: `convert` has a try-except that branches into nested try-except blocks, increasing indentation depth. Intent is mostly clear, especially with docstrings and type hints, but the assertion lines obscure it. Code length is reasonable though the dead code adds unnecessary bulk. Action granularity is good—each line performs a single action. Reading flow is fairly natural, but the meaningless assertions interrupt it. Overall the code is understandable but would benefit from removing the dead-code artifacts and flattening nested exceptions slightly.

Run 3

The code is well-structured with clear separation of concerns, low nesting, and purposeful imports. Each action is on its own line, and the reading flow is natural. The main detractors are the presence of dead code (e.g., `if ((0xe7b5 ^ 0xe7b5) != 0): raise AssertionError()`) and some type-ignore comments, which introduce unnecessary noise. Additionally, the nested try/except blocks, while justified, slightly increase cognitive load. Overall, the intent is clear and the code is maintainable, but the misleading assertions should be removed for clarity.

Run 1

Code Structure: Imports, a documented parameter class, and separate initialization and conversion methods provide logical organization. Nesting: Nested exception handling and the certificate-specific branch introduce moderate depth, but remain manageable. Clarity of intent: The docstring, descriptive names, and error messages clearly explain supported certificate inputs; constant-false XOR checks obscure intent and serve no useful purpose. Code length: Mostly concise, with unnecessary assertion blocks and numerous imports unused in this excerpt. Action granularity: Statements generally perform one action per line, and multiline calls are formatted clearly. Reading flow: Conversion proceeds naturally from file paths to ad-hoc certificates to SSLContext imports, although dead checks interrupt the flow and the final bare raise requires tracking the enclosing exception handler.

Run 2

Code Structure: The class is logically organized into initialization and conversion, although many imports are unused in this snippet. Nesting: Nested exception handling and conditionals add moderate depth, especially for ad-hoc certificates. Clarity of intent: The docstring, descriptive names, type annotations, and helpful errors clearly explain supported certificate inputs. However, always-false hexadecimal XOR checks introduce distracting, purposeless code, and the final bare raise requires tracking the enclosing exception. Code length: Mostly concise, but redundant assertions and unused imports add unnecessary length. Action granularity: Statements generally perform one action per line, with readable multiline calls. Reading flow: Conversion follows a sensible file-path, ad-hoc, then SSLContext fallback sequence, though exception-driven branching and dead checks interrupt the flow.

Run 3

Code Structure: The class logically separates initialization from conversion, and certificate handling is organized into recognizable cases. Nesting: Nested try/except blocks and conditional checks add moderate depth, especially for the ad-hoc certificate case. Clarity of intent: The docstring, descriptive names, type annotations, and informative errors clearly explain the purpose, but the always-false hexadecimal XOR checks are distracting and serve no apparent purpose. Code length: The conversion logic is reasonably concise, although numerous unused imports and redundant assertion checks unnecessarily lengthen this excerpt. Action granularity: Most lines perform one action, with multiline calls formatted clearly. Reading flow: File-path validation followed by special-value and SSLContext handling is natural, but exception-driven branching, repeated import handling, and the final bare raise require additional attention.