winter_openapi/generator.py

Summary

Maintainability
C
1 day
Test Coverage

File generator.py has 333 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import inspect
import warnings
from itertools import groupby
from typing import Any
from typing import Dict
Severity: Minor
Found in winter_openapi/generator.py - About 4 hrs to fix

    Function build_schema has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def build_schema(self, type_info: TypeInfo, *, output: bool) -> Schema:
            if type_info.type_ == DataTypes.ANY:
                return Schema(
                    description='Can be any value - string, number, boolean, array or object.',
                    nullable=type_info.nullable,
    Severity: Minor
    Found in winter_openapi/generator.py - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function determine_path_prefix has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def determine_path_prefix(url_paths: List[str]) -> str:
        """
        https://github.com/encode/django-rest-framework/blob/master/LICENSE.md
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
        INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    Severity: Minor
    Found in winter_openapi/generator.py - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function generate_openapi has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def generate_openapi(
        title: str,
        version: str,
        routes: Sequence[Route],
        description: Optional[str] = None,
    Severity: Minor
    Found in winter_openapi/generator.py - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function get_schema_or_reference has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_schema_or_reference(self, type_info: Union[Type, TypeInfo], output: bool) -> Union[Schema, Reference]:
            if not isinstance(type_info, TypeInfo):
                type_info = inspect_type(type_info)
            schema = self._schemas.get((type_info.hint_class, output))
            if not schema:
    Severity: Minor
    Found in winter_openapi/generator.py - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function generate_openapi has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def generate_openapi(
    Severity: Major
    Found in winter_openapi/generator.py - About 50 mins to fix

      Function _get_openapi_path has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def _get_openapi_path(
      Severity: Minor
      Found in winter_openapi/generator.py - About 35 mins to fix

        Function _get_openapi_operation has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def _get_openapi_operation(
        Severity: Minor
        Found in winter_openapi/generator.py - About 35 mins to fix

          There are no issues that match your filters.

          Category
          Status