wglass/lighthouse

View on GitHub

Showing 19 of 33 total issues

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

    def sync_nodes(self, clusters):
        """
        Syncs the enabled/disabled status of nodes existing in HAProxy based
        on the given clusters.

Severity: Minor
Found in lighthouse/haproxy/balancer.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_command has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def send_command(self, command):
        """
        Sends a given command to the HAProxy control socket.

        Returns the response from the socket as a string.
Severity: Minor
Found in lighthouse/haproxy/control.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 start_watching has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def start_watching(self, cluster, callback):
        """
        Initiates the "watching" of a cluster's associated znode.

        This is done via kazoo's ChildrenWatch object.  When a cluster's
Severity: Minor
Found in lighthouse/zookeeper.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 validate_proxies_config has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def validate_proxies_config(cls, proxies):
        """
        Specific config validation method for the "proxies" portion of a
        config.

Severity: Minor
Found in lighthouse/haproxy/balancer.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_response has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def get_response(sock, buffer_size=4096):
    """
    Helper method for retrieving a response from a given socket.

    Returns two values in a tuple, the first is the reponse line and the second
Severity: Minor
Found in lighthouse/sockutils.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 check_loop has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def check_loop(self, service):
        """
        While the reporter is not shutting down and the service being checked
        is present in the reporter's configuration, this method will launch a
        job to run all of the service's checks and then pause for the
Severity: Minor
Found in lighthouse/reporter.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 run_checks has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def run_checks(self):
        """
        Iterates over the configured ports and runs the checks on each one.

        Returns a two-element tuple: the first is the set of ports that
Severity: Minor
Found in lighthouse/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 get_current_nodes has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def get_current_nodes(self, clusters):
        """
        Returns two dictionaries, the current nodes and the enabled nodes.

        The current_nodes dictionary is keyed off of the cluster name and
Severity: Minor
Found in lighthouse/haproxy/balancer.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 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(
Severity: Minor
Found in lighthouse/haproxy/config.py - About 45 mins to fix

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

        def __init__(
    Severity: Minor
    Found in lighthouse/configs/handler.py - About 45 mins to fix

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

          def update_checks(self, check_configs):
              """
              Maintains the values in the `checks` attribute's dictionary.  Each
              key in the dictionary is a port, and each value is a nested dictionary
              mapping each check's name to the Check instance.
      Severity: Minor
      Found in lighthouse/service.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, name, port, upstreams, options=None, bind_address=None):
      Severity: Minor
      Found in lighthouse/haproxy/stanzas/proxy.py - About 35 mins to fix

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

            def __init__(self, name, port, lines, members, bind_address=None):
        Severity: Minor
        Found in lighthouse/haproxy/stanzas/meta.py - About 35 mins to fix

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

              def __init__(self, host, ip, port, peer=None, metadata=None):
          Severity: Minor
          Found in lighthouse/node.py - About 35 mins to fix

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

                def start(self, on_add, on_update, on_delete):
                    """
                    Starts monitoring the file path, passing along on_(add|update|delete)
                    callbacks to a watchdog observer.
            
            
            Severity: Minor
            Found in lighthouse/configs/monitor.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 get_installed_classes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_installed_classes(cls):
                    """
                    Iterates over installed plugins associated with the `entry_point` and
                    returns a dictionary of viable ones keyed off of their names.
            
            
            Severity: Minor
            Found in lighthouse/pluggable.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 apply_config has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def apply_config(self, config):
                    """
                    Constructs HAProxyConfig and HAProxyControl instances based on the
                    contents of the config.
            
            
            Severity: Minor
            Found in lighthouse/haproxy/balancer.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 deserialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def deserialize(cls, value):
                    """
                    Creates a new Node instance via a JSON map string.
            
                    Note that `port` and `ip` and are required keys for the JSON map,
            Severity: Minor
            Found in lighthouse/node.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 validate_config has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def validate_config(cls, config):
                    """
                    Validates that a config file path and a control socket file path
                    and pid file path are all present in the HAProxy config.
                    """
            Severity: Minor
            Found in lighthouse/haproxy/balancer.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