cocaine/cocaine-framework-python

View on GitHub

Showing 45 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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        def tornado_http(func):
            func = gen.coroutine(func)
        
            def wrapper(request, response):
                yield func(TornadoPatchedRequest(request), _HTTPResponse(response))
        Severity: Major
        Found in cocaine/decorators/http_dec.py and 1 other location - About 1 hr to fix
        cocaine/decorators/http_dec.py on lines 185..190

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 45.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        def http(func):
            func = gen.coroutine(func)
        
            def wrapper(request, response):
                yield func(HTTPPatchedRequest(request), _HTTPResponse(response))
        Severity: Major
        Found in cocaine/decorators/http_dec.py and 1 other location - About 1 hr to fix
        cocaine/decorators/http_dec.py on lines 177..182

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 45.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          class CocaineErrno(object):
              # no handler for requested event
              ENOHANDLER = 200
              # syntax error or import error
              EBADSOURCE = 210
          Severity: Major
          Found in cocaine/common/__init__.py and 1 other location - About 1 hr to fix
          cocaine/worker/message.py on lines 35..42

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 39.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          class RPCv1(object):
              HANDSHAKE = 0
              HEARTBEAT = 0
              INVOKE = 0
              WRITE = 0
          Severity: Major
          Found in cocaine/worker/message.py and 1 other location - About 1 hr to fix
          cocaine/common/__init__.py on lines 23..37

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 39.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  @property
                  def uuid(self):
                      if not self._uuid:
                          self._uuid = self.get_opt("--uuid")
                      return self._uuid
              Severity: Minor
              Found in cocaine/detail/defaults.py and 1 other location - About 50 mins to fix
              cocaine/detail/defaults.py on lines 101..105

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 36.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Severity
              Category
              Status
              Source
              Language