Sample

pyint-2a7ed5de096e-I10

Deterministically remove some optional blank lines and bracketed line breaks

Matched original source

Lines61

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.5080–1; higher is more readable
Mi0.1280–1; higher is more readable
LLOC43Logical lines; fewer is more readable
DeepSeek V4 Pro90–20; mean of three runs
GPT-6.1 Sol15.330–20; mean of three runs
BTTF0.4630–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: 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: 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.1694.374−55.914
Source linesThe number of non-empty source lines.61+24.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.386−6.579

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

Feature contributions

FeatureValueContribution
(log-odds)
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.161.984−3.196
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.162+1.809
Indentation frequencyHow rapidly indentation changes from line to line.55+1.165
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.62−1.159
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.045+0.503
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.60.914+0.442
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398

Intercept 0.07 + feature contributions = 0.032 (log-odds).
Score = sigmoid(0.032) = 0.508.

Score0.128
Score43
Run 1

The code has some readable aspects like docstrings, type hints, and logical grouping of imports. However, several issues significantly hurt readability. The 'convert' method contains deeply nested try/except blocks, making the flow hard to follow. Multiple actions are crammed onto single lines (e.g., the raise click.BadParameter calls), violating the one-action-per-line principle. Formatting is inconsistent, especially in the BadParameter calls where arguments are oddly aligned and spread across lines with excessive whitespace. The intent of the nested error handling is obscured by the messy indentation and argument placement. While the class structure is clear, the execution flow within the method is disorganized and visually cluttered.

Run 2

The code has clear intent and logical organization but suffers from poor formatting and readability issues. The class structure is coherent, and the convert method follows a reasonable flow. However, multiple problems reduce readability: inconsistent indentation creates artificial nesting confusion, multiple statements are crammed onto single lines (violating one-action-per-line), and several function calls have parameters awkwardly split across lines with excessive whitespace. The exception handling creates deeper nesting than necessary, and the repeated try-except blocks within conditionals interrupt the reading flow. The CertParamType class is concise but the convert method's error handling paths are tangled. Parameter alignment is inconsistent, making the code visually disorganized despite its logical structure being sound.

Run 3

The code is functional but has inconsistent formatting that hurts readability. The class structure is logical with a clear purpose, but the convert method is overly long and contains deeply nested try/except blocks. Multiple function calls are split across awkward line breaks (e.g., BadParameter arguments spanning 3-4 lines with odd indentation), violating action granularity expectations. The reading flow is disrupted by unusual spacing—some blank lines are missing between methods while others create invisible separation. The conditional logic for 'adhoc' certificates is understandable but buried in exception handling. Type hints are generally good, improving clarity of intent. Overall structure is acceptable, but nesting depth and formatting irregularities make it harder to scan than necessary.

Run 1

Code Structure: The class cleanly encapsulates certificate-option conversion, although many imports are unrelated to this snippet. Nesting: Nested exception handling and the adhoc branch add moderate depth, but early returns limit complexity. Clarity of intent: The descriptive class name, docstring, type annotations, and explicit error messages clearly explain the supported inputs. Code length: The implementation is reasonably concise, though the import block is disproportionately long. Action granularity: Statements generally perform one action each; awkwardly compressed argument formatting makes some exception constructions harder to scan. Reading flow: Validation progresses logically from an existing file to adhoc certificates and then an SSLContext import. Missing spacing between methods, inconsistent formatting, and the final bare raise slightly disrupt readability.

Run 2

Code Structure: The class cleanly groups certificate validation, although numerous unrelated imports add clutter. Nesting: Nested exception handling and conditional checks introduce moderate complexity, but early returns help. Clarity of intent: The docstring, descriptive names, and specific error messages clearly explain the accepted certificate inputs. Code length: The implementation is reasonably concise, but the import list is excessive for this snippet. Action granularity: Most lines perform one action; awkwardly compressed exception arguments reduce visual clarity. Reading flow: Validation proceeds logically from SSL availability to file paths, ad-hoc certificates, and SSLContext imports. However, inconsistent whitespace, missing separation between methods, long malformed-looking argument lines, and the final bare raise make the flow less polished.

Run 3

Code Structure: The class neatly groups certificate-option validation, although numerous unused imports distract in this snippet. Nesting: Several nested try/except blocks and conditionals increase indentation, but early returns limit complexity. Clarity of intent: The docstring, descriptive class name, and explicit error messages clearly explain the supported inputs; generic names such as value and obj are less informative. Code length: The implementation is reasonably concise, though the import section is disproportionate to the shown functionality. Action granularity: Most lines perform one action, but malformed spacing combines arguments awkwardly on some lines. Reading flow: Validation follows a logical progression from SSL availability to file paths, ad-hoc certificates, and imported contexts. Missing separation between methods and inconsistent argument formatting interrupt otherwise straightforward reading.