OpServ-Monitoring/opserv-backend

View on GitHub

Showing 66 of 66 total issues

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

def init():
    # Set up a argsparse.ArgumentParser
    parser = configure_runtime_arg_parser()

    # Validate the passed runtime args
Severity: Minor
Found in app/application_settings/settings_management.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

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

def __init_api_ref_redirect(app):
    @app.route('/apiref', defaults={'path': ''})
    @app.route('/apiref/<path:path>')
    def catch_all(path):
        base_api_doc_url = "https://opserv-monitoring.github.io/opserv-backend/docs/apis/restful"
Severity: Minor
Found in app/server/__management.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

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

        while not queue_manager.set_gathering_rate_queue.empty():
            new_rate = queue_manager.set_gathering_rate_queue.get(False)
            GathererManager.handle_new_rate(new_rate)
Severity: Minor
Found in app/gathering/gather_main.py and 1 other location - About 50 mins to fix
app/gathering/gather_main.py on lines 73..75

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

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

        while not queue_manager.request_data_queue.empty():
            new_request = queue_manager.request_data_queue.get(False)
            GathererManager.handle_data_request(new_request)
Severity: Minor
Found in app/gathering/gather_main.py and 1 other location - About 50 mins to fix
app/gathering/gather_main.py on lines 68..70

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

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 get_path_to_app has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def get_path_to_app():
    """
        Returns the absolute path to the app folder of the project
        E.g. /home/opserv/opserv-backend/app
    """
Severity: Minor
Found in app/misc/standalone_helper.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 create_measurement_if_not_exists has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def create_measurement_if_not_exists(component, metric, args):
    """ Creates a new variable if the specified one doesn't already exists """
    if args is None:
        if not metric in realtime_data[component]:
            realtime_data[component][metric] = None
Severity: Minor
Found in app/misc/data_manager.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

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

app/server/restful_api/api_root/endpoint_management_api_root.py on lines 0..12
app/server/restful_api/data/endpoint_management_data.py on lines 0..12

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

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

    def get_measurements(cls, component_type: str, component_arg: str, metric: str, start_time: int,
Severity: Minor
Found in app/server/data_gates/default_data_gate.py - About 45 mins to fix

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

    def setup_logger(log_to_console, log_to_file, console_loglevel, file_log_path, log_server, log_gathering):
    Severity: Minor
    Found in app/misc/logging_helper.py - About 45 mins to fix

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

          def get_measurements(cls,
      Severity: Minor
      Found in app/server/data_gates/outbound_gate_interface.py - About 45 mins to fix

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

        def request_valid(request):
            """
                Checks the given request for the correct data structure
                Returns True if it has the right structure
            """
        Severity: Minor
        Found in app/gathering/gatherer_manager.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 measure_network has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def measure_network(self, metric, args):
                '''
                    Returns a measurement of the desired network interface and metric
                '''
                try:
        Severity: Minor
        Found in app/gathering/measuring/psutil_source.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

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

        app/server/restful_api/data/endpoint_management_data.py on lines 0..12
        app/server/restful_api/preferences/endpoint_management_preferences.py on lines 0..12

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

        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 queue_exists has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        def queue_exists(component, metric, args):
            """ Checks whether the specified queue already exists """
            if component in realtime_queues:
                if args is not None:
                    if args in realtime_queues[component] and metric in realtime_queues[component][args]:
        Severity: Minor
        Found in app/misc/queue_manager.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 set_gathering_rates has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def set_gathering_rates(cls):
                from misc import queue_manager
                component_metrics_writer_reader = UnifiedDatabaseInterface.get_component_metrics_writer_reader()
        
                if not component_metrics_writer_reader.are_gathering_rates_set():
        Severity: Minor
        Found in app/database/connectors/database_initializer.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 get_condensed_data has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def get_condensed_data(cls, component_type: str, component_arg: str, metric_name: str, start_time: int,
        Severity: Minor
        Found in app/database/connectors/measurement_data_reader.py - About 45 mins to fix

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

          Severity: Major
          Found in app/server/restful_api/data/endpoint_management_data.py and 2 other locations - About 45 mins to fix
          app/server/restful_api/api_root/endpoint_management_api_root.py on lines 0..12
          app/server/restful_api/preferences/endpoint_management_preferences.py on lines 0..12

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

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

              def __on_measurement_received(self, component_type: str, component_arg: str, metric: str, timestamp: int,
          Severity: Minor
          Found in app/server/apis/websocket/websocket_handler.py - About 35 mins to fix

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

                def broadcast_new_measurement(cls, component_type: str, component_arg: str, metric: str, timestamp: int,
            Severity: Minor
            Found in app/server/apis/websocket/websocket_handler.py - About 35 mins to fix

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

                  def __init__(self, component, metric, args, delayms, event=None):
              Severity: Minor
              Found in app/gathering/gatherer.py - About 35 mins to fix
                Severity
                Category
                Status
                Source
                Language