cocaine/cocaine-framework-python

View on GitHub

Showing 25 of 45 total issues

BasicWorker has 26 functions (exceeds 20 allowed). Consider refactoring.
Open

class BasicWorker(object):
    def __init__(self, disown_timeout=DEFAULT_DISOWN_TIMEOUT,
                 heartbeat_timeout=DEFAULT_HEARTBEAT_TIMEOUT,
                 io_loop=None, app=None, uuid=None, endpoint=None):
        if heartbeat_timeout < disown_timeout:
Severity: Minor
Found in cocaine/worker/worker.py - About 3 hrs to fix

    File headers.py has 283 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    #
    #    Copyright (c) 2012+ Anton Tyurin <noxiouz@yandex.ru>
    #    Copyright (c) 2011-2016 Other contributors as noted in the AUTHORS file.
    #
    #    This file is part of Cocaine.
    Severity: Minor
    Found in cocaine/detail/headers.py - About 2 hrs to fix

      File worker.py has 274 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      #
      #    Copyright (c) 2012+ Anton Tyurin <noxiouz@yandex.ru>
      #    Copyright (c) 2013+ Evgeny Safronov <division494@gmail.com>
      #    Copyright (c) 2011-2014 Other contributors as noted in the AUTHORS file.
      #
      Severity: Minor
      Found in cocaine/worker/worker.py - About 2 hrs to fix

        Function resolve_logging has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        def resolve_logging(endpoints, name="logging", io_loop=None):
            if io_loop:
                warnings.warn('io_loop argument is deprecated.', DeprecationWarning)
        
            for host, port in endpoints:
        Severity: Minor
        Found in cocaine/detail/logger.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 merge has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def merge(self, raw_headers):
                # TODO: PY3: the static table contains only byte strings.
                # Seems values must be converted to bytestrings too.
                if raw_headers is None or len(raw_headers) == 0:
                    return Headers()
        Severity: Minor
        Found in cocaine/detail/headers.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 _send has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def _send(self):
                """ Send a message lazy formatted with args.
                External log attributes can be passed via named attribute `extra`,
                like in logging from the standart library.
        
        
        Severity: Minor
        Found in cocaine/detail/logger.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 emit has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def emit(self, record):
                lvl = record.levelno
                extra = getattr(record, "extra", {})
                if lvl >= logging.ERROR:
                    # to avoid message formatting
        Severity: Minor
        Found in cocaine/detail/logger.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 _invoke has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def _invoke(self, method_name, *args, **kwargs):
                trace = kwargs.pop("trace", None)
                if trace:
                    update_dict_with_trace(kwargs, trace)
                new_trace_id = kwargs.get('trace_id', self.trace_id)
        Severity: Minor
        Found in cocaine/detail/channel.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 feed_message has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def feed_message(self, msg):
                session, type_id, payload = msg[:3]
                if session == 1:
                    if type_id == RPCv1.HEARTBEAT:
                        self._dispatch_heartbeat(None)
        Severity: Minor
        Found in cocaine/worker/worker.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 makeRecord has 9 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def makeRecord(self, name, level, fn, lno, msg, args, exc_info, func=None, extra=None):  # noqa
        Severity: Major
        Found in cocaine/detail/logger.py - About 1 hr to fix

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

              def prepare_message_args(self, level, message, *args, **kwargs):
                  if args:
                      try:
                          message %= args
                      except Exception:
          Severity: Minor
          Found in cocaine/detail/logger.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 search has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def search(self, name, value):
                  """
                  Searches the table for the entry specified by name
                  and value
          
          
          Severity: Minor
          Found in cocaine/detail/headers.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 on_read has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def on_read(self, read_bytes):
                  self.log.debug("read %.300s", read_bytes)
                  self.buffer.feed(read_bytes)
                  for msg in self.buffer:
                      self.log.debug("unpacked: %.300s", msg)
          Severity: Minor
          Found in cocaine/detail/baseservice.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 __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(self, rx_tree, session_id, header_table=None, io_loop=None, service_name=None,
          Severity: Major
          Found in cocaine/detail/channel.py - About 50 mins to fix

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

                def __init__(self, name, endpoints=LOCATOR_DEFAULT_ENDPOINT,
            Severity: Major
            Found in cocaine/detail/service.py - About 50 mins to fix

              Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def __init__(self, tx_tree, pipe, session_id, header_table, service_name, trace_id=None):
              Severity: Minor
              Found in cocaine/detail/channel.py - About 45 mins to fix

                Function manage_headers has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def manage_headers(headers, table):
                    result = []
                    for k, v in six.iteritems(headers):
                        match = table.search(k, v)
                        if match is None:
                Severity: Minor
                Found in cocaine/detail/channel.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 get has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def get(self, timeout=0, protocol=None):
                        if self._done and self._queue.empty():
                            raise ChokeEvent()
                
                        # to pull various service errors
                Severity: Minor
                Found in cocaine/detail/channel.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 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def __init__(self, disown_timeout=DEFAULT_DISOWN_TIMEOUT,
                Severity: Minor
                Found in cocaine/worker/worker.py - About 45 mins to fix

                  Function _dispatch_invoke has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def _dispatch_invoke(self, msg, headers):
                          response = ResponseStream(msg.session, self, msg.event)
                          try:
                              workerlog.debug("invoke has been received %s", msg)
                              request = RequestStream(headers, self._header_table['rx'])
                  Severity: Minor
                  Found in cocaine/worker/worker.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

                  Severity
                  Category
                  Status
                  Source
                  Language