dragorhast/server

View on GitHub

Showing 16 of 21 total issues

File bikes.py has 436 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
Bike Related Views
-------------------------

Handles all the bike CRUD
Severity: Minor
Found in server/views/bikes.py - About 6 hrs to fix

    File users.py has 368 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """
    User Related Views
    -------------------------
    
    Handles all the user CRUD
    Severity: Minor
    Found in server/views/users.py - About 4 hrs to fix

      Function returns has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
      Open

      def returns(
          schema: Optional[Schema] = None, return_code: HTTPException = web.HTTPOk,
          **named_schema: Union[Schema, Tuple[Optional[Schema], HTTPException]]
      ):
          """
      Severity: Minor
      Found in server/serializer/decorators.py - About 4 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

      Function resolve_match_map has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

      def resolve_match_map(request: Request, match_map) -> Dict[str, Any]:
          resolved_matches = {}
          errors = []
      
          for key, value in match_map.items():
      Severity: Minor
      Found in server/views/decorators.py - About 3 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

      Function match_getter has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

      def match_getter(getter_function, *injection_parameters: Union[str, Optional],
                       **match_map: Union[str, GetFrom, Optional, Tuple[str, type]]):
          """
          Automatically fetches and includes an item, or 404's if it doesn't exist.
      
      
      Severity: Minor
      Found in server/views/decorators.py - About 3 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

      Function expects has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      def expects(schema: Optional[Schema], into="data"):
          """
          A decorator that asserts that the JSON data supplied
          to the route validates the given :class:`~marshmallow.Schema`.
      
      
      Severity: Minor
      Found in server/serializer/decorators.py - About 2 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

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

          def subscribe(self, target: Union[Callable, EventEmitter], handler: Callable):
              """
              :param target: The event to listen for.
              :param handler: The event handler.
              """
      Severity: Minor
      Found in server/events/event_hub.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 assert_fields has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def assert_fields(self, data, **kwargs):
              """
              Asserts that, according to the specification:
      
              - the ``data`` field is included when the status is :attr:`~JSendStatus.SUCCESS` or :attr:`~JSendStatus.FAIL`
      Severity: Minor
      Found in server/serializer/jsend.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 build_app has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def build_app(db_uri=None):
          """Sets up the app and installs uvloop."""
          app = web.Application(middlewares=[SentryMiddleware(), validate_token_middleware])
          uvloop.install()
      
      
      Severity: Minor
      Found in server/app.py - About 45 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 serialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def serialize(
      Severity: Minor
      Found in server/models/bike.py - About 45 mins to fix

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

            def _rental_ended(self, user, bike, location, price, distance):
        Severity: Minor
        Found in server/service/background/stats_reporter.py - About 35 mins to fix

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

              def rental_ended(self, user: User, bike: Bike, location: Point, price: float, distance: float):
          Severity: Minor
          Found in server/service/manager/rental_manager.py - About 35 mins to fix

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

                def __getattr__(self, item: str):
                    """Intercepts getattribute and raises if the event does not exist."""
                    for event_list in self._event_lists:
                        try:
                            event = getattr(event_list, item)
            Severity: Minor
            Found in server/events/event_hub.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 None
            Severity: Major
            Found in server/serializer/fields.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return cls.DISCONNECTED
              Severity: Major
              Found in server/models/bike.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return new_func
                Severity: Major
                Found in server/serializer/decorators.py - About 30 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language