odin-detector/odin-data

View on GitHub
python/src/odin_data/control/odin_data_adapter.py

Summary

Maintainability
F
5 days
Test Coverage

File odin_data_adapter.py has 417 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
Created on 6th September 2017

:author: Alan Greer
"""
Severity: Minor
Found in python/src/odin_data/control/odin_data_adapter.py - About 6 hrs to fix

    Function get has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

        def get(self, path, request):
    
            """
            Implementation of the HTTP GET verb for OdinDataAdapter
    
    
    Severity: Minor
    Found in python/src/odin_data/control/odin_data_adapter.py - About 5 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

    Function send_to_clients has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

        def send_to_clients(self, request_command, parameters, client_index=-1):
            status_code = 200
            response = {}
    
            # Check if the parameters object is a list
    Severity: Minor
    Found in python/src/odin_data/control/odin_data_adapter.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

    Function put has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        def put(self, path, request):  # pylint: disable=W0613
    
            """
            Implementation of the HTTP PUT verb for OdinDataAdapter
    
    
    Severity: Minor
    Found in python/src/odin_data/control/odin_data_adapter.py - About 3 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

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

        def update_loop(self):
            """Handle background update loop tasks.
            This method handles background update tasks executed periodically in the tornado
            IOLoop instance. This includes requesting the status from the underlying application
            and preparing the JSON encoded reply in a format that can be easily parsed.
    Severity: Minor
    Found in python/src/odin_data/control/odin_data_adapter.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 process_reconnection has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def process_reconnection(self, client):
            # We have been notified that a client has reconnected.
            # Loop over all stored configuration, sending any that needs to be processed
            logging.debug("Processing reconnection for client: %d", client)
            # First load the configuration file
    Severity: Minor
    Found in python/src/odin_data/control/odin_data_adapter.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 process_configuration_file has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def process_configuration_file(self, config_file_path, client_index):
            status_code = 200
            response = {}
            if config_file_path != '':
                logging.debug("Loading configuration file {}".format(config_file_path))
    Severity: Minor
    Found in python/src/odin_data/control/odin_data_adapter.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 process_configuration has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def process_configuration(self, request_command, parameters):
            status_code = 200
            response = {}
            logging.debug("Process configuration with URI: %s", request_command)
            client_index = -1
    Severity: Minor
    Found in python/src/odin_data/control/odin_data_adapter.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 uri_params_to_dictionary has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def uri_params_to_dictionary(request_command, parameters):
            # Check to see if the request contains more than one item
            if request_command is not None:
                request_list = request_command.split('/')
                logging.debug("URI request list: %s", request_list)
    Severity: Minor
    Found in python/src/odin_data/control/odin_data_adapter.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

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

            try:
                index = int(uri_items[-1])
                if index >= 0:
                    # This is a valid index so remove the value from the URI
                    request_command = remove_suffix(request_command, "/" + uri_items[-1])
    Severity: Major
    Found in python/src/odin_data/control/odin_data_adapter.py and 1 other location - About 3 hrs to fix
    python/src/odin_data/control/odin_data_adapter.py on lines 349..357

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

    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

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

                try:
                    index = int(uri_items[-1])
                    if index >= 0:
                        # This is a valid index so remove the value from the URI
                        request_command = remove_suffix(request_command, "/" + uri_items[-1])
    Severity: Major
    Found in python/src/odin_data/control/odin_data_adapter.py and 1 other location - About 3 hrs to fix
    python/src/odin_data/control/odin_data_adapter.py on lines 278..286

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

    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

    Identical blocks of code found in 5 locations. Consider refactoring.
    Open

            try:
                if client_index == -1:
                    # We are sending the value to all clients
                    for client in self._clients:
                        client.send_request(command)
    Severity: Major
    Found in python/src/odin_data/control/odin_data_adapter.py and 4 other locations - About 1 hr to fix
    python/src/odin_data/control/meta_listener_adapter.py on lines 153..159
    python/src/odin_data/control/odin_data_adapter.py on lines 432..440
    python/src/odin_data/control/odin_data_adapter.py on lines 448..454
    python/src/odin_data/control/odin_data_adapter.py on lines 457..464

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

    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

    Identical blocks of code found in 5 locations. Consider refactoring.
    Open

                    try:
                        command, parameters = OdinDataAdapter.uri_params_to_dictionary(request_command, parameters)
                        self._clients[client_index].send_configuration(parameters, command)
                    except Exception as err:
                        logging.debug(OdinDataAdapter.ERROR_FAILED_TO_SEND)
    Severity: Major
    Found in python/src/odin_data/control/odin_data_adapter.py and 4 other locations - About 1 hr to fix
    python/src/odin_data/control/meta_listener_adapter.py on lines 153..159
    python/src/odin_data/control/odin_data_adapter.py on lines 397..409
    python/src/odin_data/control/odin_data_adapter.py on lines 432..440
    python/src/odin_data/control/odin_data_adapter.py on lines 448..454

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

    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

    Identical blocks of code found in 5 locations. Consider refactoring.
    Open

                            try:
                                command, parameters = OdinDataAdapter.uri_params_to_dictionary(request_command,
                                                                                               param_set)
                                client.send_configuration(parameters, command)
                            except Exception as err:
    Severity: Major
    Found in python/src/odin_data/control/odin_data_adapter.py and 4 other locations - About 1 hr to fix
    python/src/odin_data/control/meta_listener_adapter.py on lines 153..159
    python/src/odin_data/control/odin_data_adapter.py on lines 397..409
    python/src/odin_data/control/odin_data_adapter.py on lines 448..454
    python/src/odin_data/control/odin_data_adapter.py on lines 457..464

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

    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

    Identical blocks of code found in 5 locations. Consider refactoring.
    Open

                        try:
                            client.send_configuration(parameters, command)
                        except Exception as err:
                            logging.debug(OdinDataAdapter.ERROR_FAILED_TO_SEND)
                            logging.error("Error: %s", err)
    Severity: Major
    Found in python/src/odin_data/control/odin_data_adapter.py and 4 other locations - About 1 hr to fix
    python/src/odin_data/control/meta_listener_adapter.py on lines 153..159
    python/src/odin_data/control/odin_data_adapter.py on lines 397..409
    python/src/odin_data/control/odin_data_adapter.py on lines 432..440
    python/src/odin_data/control/odin_data_adapter.py on lines 457..464

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

    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

                except IOError as io_error:
                    logging.error("Failed to open configuration file: {}".format(io_error))
                    status_code = 503
                    response = {'error': "Failed to open configuration file: {}".format(io_error)}
    Severity: Major
    Found in python/src/odin_data/control/odin_data_adapter.py and 1 other location - About 1 hr to fix
    python/src/odin_data/control/odin_data_adapter.py on lines 327..330

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

    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

                except ValueError as value_error:
                    logging.error("Failed to parse json config: {}".format(value_error))
                    status_code = 503
                    response = {'error': "Failed to parse json config: {}".format(value_error)}
    Severity: Major
    Found in python/src/odin_data/control/odin_data_adapter.py and 1 other location - About 1 hr to fix
    python/src/odin_data/control/odin_data_adapter.py on lines 323..326

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

    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

    There are no issues that match your filters.

    Category
    Status