wglass/lighthouse

View on GitHub

Showing 33 of 33 total issues

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 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 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

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

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

          def wind_down(self):
              """
              Winding down a writer ConfigWatcher is merely a matter of stopping
              the present discovery methods.
              """
      Severity: Minor
      Found in lighthouse/writer.py and 1 other location - About 40 mins to fix
      lighthouse/reporter.py on lines 128..137

      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 34.

      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 wind_down(self):
              """
              Winds down the reporter by stopping any discovery method instances and
              joining any running threads.
      
      
      Severity: Minor
      Found in lighthouse/reporter.py and 1 other location - About 40 mins to fix
      lighthouse/writer.py on lines 170..176

      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 34.

      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 __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 __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, name, port, upstreams, options=None, bind_address=None):
          Severity: Minor
          Found in lighthouse/haproxy/stanzas/proxy.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 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

            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

            Severity
            Category
            Status
            Source
            Language