vladcalin/gemstone

View on GitHub

Showing 20 of 29 total issues

File microservice.py has 331 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import logging
import os
import functools
import random
import threading
Severity: Minor
Found in gemstone/core/microservice.py - About 3 hrs to fix

    MicroService has 29 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class MicroService(Container):
        #: The name of the service. Is required.
        name = None
    
        #: The host where the service will listen
    Severity: Minor
    Found in gemstone/core/microservice.py - About 3 hrs to fix

      Function post has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          def post(self):
              if self.request.headers.get("Content-type").split(";")[0] != "application/json":
                  self.write_single_response(GenericResponse.INVALID_REQUEST)
                  return
      
      
      Severity: Minor
      Found in gemstone/core/handlers.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 handle_single_request has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def handle_single_request(self, request_object):
              """
              Handles a single request object and returns the correct result as follows:
      
              - A valid response object if it is a regular request (with ID)
      Severity: Minor
      Found in gemstone/core/handlers.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 parse_json_structure has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      def parse_json_structure(string_item):
          """
          Given a raw representation of a json structure, returns the parsed corresponding data
          structure (``JsonRpcRequest`` or ``JsonRpcRequestBatch``)
      
      
      Severity: Minor
      Found in gemstone/core/structs.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 exposed_method has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      def exposed_method(name=None, private=False, is_coroutine=True, requires_handler_reference=False):
          """
          Marks a method as exposed via JSON RPC.
      
          :param name: the name of the exposed method. Must contains only letters, digits, dots and underscores.
      Severity: Minor
      Found in gemstone/core/decorators.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_service has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_service(self, name):
              """
              Locates a remote service by name. The name can be a glob-like pattern
              (``"project.worker.*"``). If multiple services match the given name, a
              random instance will be chosen. There might be multiple services that
      Severity: Minor
      Found in gemstone/core/microservice.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 from_dict has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def from_dict(cls, d):
              """
              Validates a dict instance and transforms it in a
              :py:class:`gemstone.core.structs.JsonRpcRequest`
              instance
      Severity: Minor
      Found in gemstone/core/structs.py - About 55 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 as_completed has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def as_completed(*async_result_wrappers):
          """
          Yields results as they become available from asynchronous method calls.
      
          Example usage
      Severity: Minor
      Found in gemstone/util.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 __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self, host="127.0.0.1", port=5672, username="", password="", **connection_options):
      Severity: Minor
      Found in gemstone/event/transport/rabbitmq.py - About 35 mins to fix

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

            def _activate_configurators(self):
                for configurator in self.configurators:
                    configurator.load()
        
                for configurator in self.configurators:
        Severity: Minor
        Found in gemstone/core/microservice.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 prepare_method_call has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def prepare_method_call(self, method, args):
                """
                Wraps a method so that method() will call ``method(*args)`` or ``method(**args)``,
                depending of args type
        
        
        Severity: Minor
        Found in gemstone/core/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

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

            def call_batch(self, *requests):
                body = []
                ids = {}
                for item in requests:
                    if not isinstance(item, (MethodCall, Notification)):
        Severity: Minor
        Found in gemstone/client/remote_service.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 expire_entries has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def expire_entries(self):
                with self.container_lock:
                    for _, entries in self.container.items():
                        i = 0
                        while i < len(entries):
        Severity: Minor
        Found in gemstone/discovery/cache.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 err
        Severity: Major
        Found in gemstone/core/handlers.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                              return resp
          Severity: Major
          Found in gemstone/core/handlers.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return to_return_resp
            Severity: Major
            Found in gemstone/core/handlers.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                                  return resp
              Severity: Major
              Found in gemstone/core/handlers.py - About 30 mins to fix

                Function dynamic_load has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                def dynamic_load(module_or_member):
                    """
                    Dynamically loads a class or member of a class.
                
                    If ``module_or_member`` is something like ``"a.b.c"``, will perform ``from a.b import c``.
                Severity: Minor
                Found in gemstone/util.py - About 25 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 first_completed has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                def first_completed(*async_result_wrappers):
                    """
                    Just like :py:func:`as_completed`, but returns only the first item and discards the
                    rest.
                
                
                Severity: Minor
                Found in gemstone/util.py - About 25 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

                Severity
                Category
                Status
                Source
                Language