Showing 26 of 26 total issues

Function sqla_crud has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

def sqla_crud(repository_cls):
    if not issubclass(repository_cls, CRUDRepository):
        raise TypeError('Repository must be inherited from CRUDRepository before annotating with sqla_crud')

    entity_cls = repository_cls.__entity_cls__
Severity: Minor
Found in winter_sqlalchemy/repository.py - About 5 hrs 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

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

    File decoder.py has 260 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import dataclasses
    import datetime
    import decimal
    import enum
    import inspect
    Severity: Minor
    Found in winter/core/json/decoder.py - About 2 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 get_all_subclasses has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_all_subclasses(supertype: Type) -> Generator[Tuple[str, Type], None, None]:
          for module in dict(sys.modules).values():
              try:
                  for class_name, class_ in inspect.getmembers(module, inspect.isclass):
                      try:
      Severity: Minor
      Found in winter/core/module_discovery.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 validate_missing_raises_annotations has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      def validate_missing_raises_annotations():
          from winter.web.exceptions.problem_annotation import ProblemAnnotation
          from winter.web.exceptions.raises import ExceptionAnnotation
          from winter.core import Component
      
      
      Severity: Minor
      Found in winter_openapi/validators.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_all_classes has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_all_classes(package: str) -> Generator[Tuple[str, Type], None, None]:
          classes_set = set()
          for module in import_recursively(package):
              try:
                  for class_name, class_ in inspect.getmembers(module, inspect.isclass):
      Severity: Minor
      Found in winter/core/module_discovery.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 setup has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def setup():
          from winter.data.exceptions import NotFoundException
          from .exceptions import RedirectException
          from .exceptions.problem_handling import autodiscover_problem_annotations
          from .exceptions.problem_handling import ProblemExceptionHandlerGenerator
      Severity: Minor
      Found in winter/web/__init__.py - About 1 hr to fix

        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 dispatch_many has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def dispatch_many(self, events: List[Event]):
                events_grouped_by_subscription: Dict[EventSubscription, List[Event]] = {}
                injector = get_injector()
        
                for event in events:
        Severity: Minor
        Found in winter/messaging/event_dispacher.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 dispatch has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def dispatch(self, events: Iterable[DomainEvent]):
                events_grouped_by_subscription: Dict[DomainEventSubscription, List[DomainEvent]] = {}
        
                for event in events:
                    event_type = type(event)
        Severity: Minor
        Found in winter_ddd/domain_event_dispatcher.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 get_swagger_ui_html has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

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

          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

                Function _convert_result_to_http_response has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                def _convert_result_to_http_response(request: django.http.HttpRequest, result: Any, method: ComponentMethod):
                    if isinstance(result, django.http.HttpResponse):
                        return result
                    if isinstance(result, ResponseEntity):
                        body = result.entity
                Severity: Minor
                Found in winter_django/view.py - About 35 mins 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_handler has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def get_handler(self, exception: Union[Type[Exception], Exception]) -> ExceptionHandler:
                        exception_type = type(exception) if isinstance(exception, Exception) else exception
                
                        for exception_cls, handler in self._handlers_by_exception.items():
                            if issubclass(exception_type, exception_cls):
                Severity: Minor
                Found in winter/web/exceptions/handlers.py - About 35 mins 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

                Avoid too many return statements within this function.
                Open

                        return Undefined()
                Severity: Major
                Found in winter/core/json/decoder.py - About 30 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language