tredis/client.py

Summary

Maintainability
D
2 days
Test Coverage

File client.py has 580 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
Cluster Supporting Redis Client

"""
import collections
Severity: Major
Found in tredis/client.py - About 1 day to fix

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

        def _on_connected(self, future):
            """Invoked when connections have been established. If the client is
            in clustering mode, it will kick of the discovery step if needed. If
            not, it will select the configured database.
    
    
    Severity: Minor
    Found in tredis/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 _read has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def _read(self, command, future):
            """Invoked when a command is executed to read and parse its results.
            It will loop on the IOLoop until the response is complete and then
            set the value of the response in the execution future.
    
    
    Severity: Minor
    Found in tredis/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 _execute has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def _execute(self, parts, expectation=None, format_callback=None):
            """Really execute a redis command
    
            :param list parts: The list of command parts
            :param mixed expectation: Optional response expectation
    Severity: Minor
    Found in tredis/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 9 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self,
    Severity: Major
    Found in tredis/client.py - About 1 hr to fix

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

          def _encode_resp(self, value):
              """Dynamically build the RESP payload based upon the list provided.
      
              :param mixed value: The list of command parts to encode
              :rtype: bytes
      Severity: Minor
      Found in tredis/client.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,
      Severity: Minor
      Found in tredis/client.py - About 45 mins to fix

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

            def __init__(self,
        Severity: Minor
        Found in tredis/client.py - About 35 mins to fix

          Avoid too many return statements within this function.
          Open

                      return b''.join(output)
          Severity: Major
          Found in tredis/client.py - About 30 mins to fix

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

                def _pick_cluster_host(self, value):
                    """Selects the Redis cluster host for the specified value.
            
                    :param mixed value: The value to use when looking for the host
                    :rtype: tredis.client._Connection
            Severity: Minor
            Found in tredis/client.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

            There are no issues that match your filters.

            Category
            Status