viatoriche/microservices

View on GitHub

Showing 34 of 52 total issues

Function drain_events has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

    def drain_events(self, infinity=True):

        with nested(*self.consumers):
            while not self._stop:
                try:
Severity: Minor
Found in microservices/queues/service.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

File service.py has 341 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import socket
from multiprocessing.pool import ThreadPool
from time import sleep

import six
Severity: Minor
Found in microservices/queues/service.py - About 4 hrs to fix

    Function test_client has 57 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def test_client(self):
            from microservices.http.client import Client, ResponseError
    
            valid_method = 'GET'
            valid_url = 'http://user:password@endpoint:8000/test/1/'
    Severity: Major
    Found in microservices/http/test.py - About 2 hrs to fix

      Function update_by_resources has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def update_by_resources(self, response):
              resources_name = self.schema.get('resources', None)
              if resources_name is not None:
                  another_resources_info = {}
                  for another_resource in [
      Severity: Minor
      Found in microservices/http/renderers.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 test_service has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def test_service(self):
              from microservices.queues.service import Microservice
              from microservices.queues.client import Client
              from kombu.connection import Connection
      
      
      Severity: Minor
      Found in microservices/queues/test.py - About 1 hr to fix

        Function url_for has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def url_for(self, resource='', query=None, params='', fragment='',
                        keep_blank_values=None):
                """Generate url for resource
        
                Use endpoint for generation
        Severity: Minor
        Found in microservices/http/client.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 __init__ has 12 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(
        Severity: Major
        Found in microservices/http/resources.py - About 1 hr to fix

          Function handle_response has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def handle_response(self, response, response_key=None):
                  """Handler for response object
          
                  :param response: requests.response obj
                  :param response_key: key for dict in response obj
          Severity: Minor
          Found in microservices/http/client.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 test_render has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def test_render(self):
                  from microservices.http.renderers import SchemaRenderer
                  from microservices.http.resources import ResourceSchema, ResourceMarker
          
                  schema = ResourceSchema(
          Severity: Minor
          Found in microservices/http/test.py - About 1 hr to fix

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

                def __init__(
            Severity: Major
            Found in microservices/http/resources.py - About 1 hr to fix

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

                  def __init__(
              Severity: Major
              Found in microservices/http/resources.py - About 1 hr to fix

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

                    def __init__(self, connection='amqp:///', logger=None, timeout=1, name=None,
                Severity: Major
                Found in microservices/queues/service.py - About 1 hr to fix

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

                      def revive(self):  # pragma no cover
                          def _revive():
                              for i, consumer in enumerate(self.consumers):
                                  self.logger.debug('Try revive consumer: %s', i)
                                  consumer.channel = self.connection
                  Severity: Minor
                  Found in microservices/queues/service.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 tornado_run has 9 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  def tornado_run(app, port=5000, address="", use_gevent=False, start=True,
                  Severity: Major
                  Found in microservices/http/runners.py - About 1 hr to fix

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

                    def tornado_run(app, port=5000, address="", use_gevent=False, start=True,
                                    monkey_patch=None, Container=None,
                                    Server=None, threadpool=None):  # pragma: no cover
                        """Run your app in one tornado event loop process
                    
                    
                    Severity: Minor
                    Found in microservices/http/runners.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 connect has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def connect(self):  # pragma no cover
                            """Try connect to mq"""
                            while not self._stop and not self.connection.connected:
                                try:
                                    self.connection.connect()
                    Severity: Minor
                    Found in microservices/queues/service.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 callback has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def callback(self, body, message):
                            message = DeferredMessage(message, self.deferred_callbacks)
                            self.logger.debug('Data (len: %s) received', len(body))
                    
                            def autoack():
                    Severity: Minor
                    Found in microservices/queues/service.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 gevent_run has 8 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    def gevent_run(app, port=5000, log=None, error_log=None, address='',
                    Severity: Major
                    Found in microservices/http/runners.py - About 1 hr to fix

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

                          def __init__(self, endpoint, ok_statuses=None, to_none_statuses=None,
                      Severity: Major
                      Found in microservices/http/client.py - About 1 hr to fix

                        Function tornado_combiner has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def tornado_combiner(configs, use_gevent=False, start=True, monkey_patch=None,
                                             Container=None, Server=None, threadpool=None):  # pragma: no cover
                            """Combine servers in one tornado event loop process
                        
                            :param configs: [
                        Severity: Minor
                        Found in microservices/http/runners.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

                        Severity
                        Category
                        Status
                        Source
                        Language