Sample

pyint-9ddaff71ddf0-I05

Rewrite eligible decimal integer literals in hexadecimal notation

Matched original source

Lines69

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8910–1; higher is more readable
Mi0.3980–1; higher is more readable
LLOC43Logical lines; fewer is more readable
DeepSeek V4 Pro15.670–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.5350–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.69+27.6
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.394−6.59

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.70−1.442
Indentation frequencyHow rapidly indentation changes from line to line.63+1.442
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.86.971+0.599
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.68.864+0.553
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.045+0.502
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
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.929−0.017

Intercept 0.07 + feature contributions = 2.104 (log-odds).
Score = sigmoid(2.104) = 0.891.

Score0.398
Score43
Run 1

The code is generally readable with clear imports, type hints, and logical organization. The CertParamType class has a focused purpose and the convert method follows a coherent flow. However, there are some issues: the nested try/except blocks create moderate complexity, and the final raise statement without context could be confusing - it re-raises the original BadParameter exception from the path_type call, which isn't immediately obvious. The import ssl inside the method could be at module level for clarity. Type ignores and conditional imports add minor noise. Variable naming is clear, and line lengths are reasonable. Overall structure is good but the error handling flow could be more explicit, and the exception re-raise pattern requires careful reading to understand.

Run 2

The code is well-structured with clear logical organization, separating imports, class definition, and method implementation. Nesting is moderate with a few exception handlers but remains manageable. Intent is generally clear, particularly in the docstring and error messages. Some sections, like the convert method's fallback logic with its try/except and type ignores, are slightly harder to follow. Code length is reasonable for handling multiple certificate types. Action granularity is appropriate—one action per line. Reading flow is natural, though the nested exception handling and the re-raise after import_string add some cognitive load.

Run 3

The code is generally well-structured with clear purpose and logical organization. It defines a single Click parameter type with sensible imports and type hints, demonstrating good clarity of intent. The convert method follows a clear validation flow: SSL check, path conversion, adhoc handling, and SSLContext import. Nesting is moderate but acceptable, with only a few levels. Action granularity is mostly one action per line, and the reading flow is natural. Minor deductions include the slightly long convert method, the try/except block with multiple fallbacks creating some complexity, and the `# type: ignore[type-arg]` comment suggesting minor type friction. Overall, it's readable and maintainable for experienced Python developers familiar with Click and Flask patterns.

Run 1

Code Structure: Imports and a focused parameter-type class are logically organized, with conversion logic contained in one method. Nesting: Nested exception handlers and the ad-hoc certificate branch add moderate depth, but early returns limit complexity. Clarity of intent: The docstring, descriptive names, type annotations, and actionable error messages clearly explain supported certificate inputs. The final bare raise is less immediately clear because it re-raises the original path-validation error after fallback checks. Code length: The implementation is concise for its validation requirements, although many imports are unused in this excerpt. Action granularity: Statements generally perform one action per line, and multiline calls are consistently formatted. Reading flow: Processing naturally proceeds from SSL availability to file validation, ad-hoc certificates, and imported SSL contexts. Minor spacing limitations around imports and the class, plus inline tooling comments, slightly reduce visual readability.

Run 2

Code Structure: The class neatly encapsulates certificate-option validation, with a separate initializer and conversion method; numerous unused imports in this snippet add clutter. Nesting: Mostly manageable, but nested exception handling and the conditional dependency check require extra attention. Clarity of intent: The docstring, type annotations, descriptive names, and specific error messages clearly communicate supported inputs. The final bare raise and lowercasing before import resolution are less immediately intuitive. Code length: The implementation is reasonably concise for its validation and dependency checks, although the import block is disproportionate to the shown functionality. Action granularity: Statements generally perform one action each, and multiline calls remain easy to scan. Reading flow: Validation proceeds naturally from SSL availability to a file path, an ad-hoc certificate, and an SSLContext import, though using an exception handler for the entire fallback sequence slightly complicates the flow.

Run 3

Code Structure: The class cleanly separates initialization from conversion, with logically grouped validation and fallback handling. Nesting: Several nested try/except and conditional blocks add moderate complexity, particularly in the certificate fallback path. Clarity of intent: The docstring, descriptive names, type annotations, and explicit error messages clearly explain accepted certificate inputs. Code length: The implementation is reasonably concise, although numerous imports are unused in this excerpt and distract from its purpose. Action granularity: Statements generally perform one action per line, with readable multiline calls. Reading flow: Processing naturally progresses from SSL availability to file validation, ad-hoc certificates, and imported SSL contexts. However, using exceptions to select fallback behavior and ending with a bare raise require readers to track the enclosing exception context.