OpServ-Monitoring/opserv-backend

View on GitHub

Showing 53 of 66 total issues

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

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

    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

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

              def insert_measurement(self, component_type, component_arg, metric_name, timestamp, value):
          Severity: Minor
          Found in app/database/connectors/measurement_insert_transaction.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/server_management.py - About 35 mins to fix

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

                  def __init__(self, uri=None, http_method=None, headers=None, params=None, body=None):
              Severity: Minor
              Found in app/server/restful_api/general/requestholder.py - About 35 mins to fix

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

                def read_measurement_from_queue(component, metric, args=None, blocking=False,
                Severity: Minor
                Found in app/misc/queue_manager.py - About 35 mins to fix

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

                      def __get_api_paths(cls, base_api_path, sub_paths, version, is_current):
                  Severity: Minor
                  Found in app/server/restful_api/flask_restful_wrapper.py - About 35 mins to fix

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

                    def hardwareAdded(hardware):
                        print(hardware.Name)
                        print(hardware.GetReport())
                        for sensor in hardware.Sensors:
                            print(typeList[sensor.SensorType])
                    Severity: Minor
                    Found in app/gathering/testing-sources/pythonnet_test.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 write_error has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def write_error(self, status_code, **kwargs) -> None:
                            """
                            Overrides the built-in function to implement custom error responses.
                            If in debug mode and caused by an uncaught exception this will add the stacktrace to the error response.
                    
                    
                    Severity: Minor
                    Found in app/server/apis/endpoint.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 __is_mandatory_parameter_valid has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def __is_mandatory_parameter_valid(self, mandatory_parameter):
                            parameter_name = mandatory_parameter[0]
                            verification_function = mandatory_parameter[1]
                    
                            params = self._request_holder.get_params()
                    Severity: Minor
                    Found in app/server/restful_api/data/v1/endpoints/__general_data_v1.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 _put has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def _put(self) -> bool:
                            request_body = self._request_holder.get_body()
                    
                            component_metrics_dict = self.__get_all_component_metrics()
                    
                    
                    Severity: Minor
                    Found in app/server/restful_api/data/v1/endpoints/gatheringrates.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_measurement has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def get_measurement(self, component, metric, args):
                            '''
                                Retrieves a measurement from the measuring source
                                given the component, metric and optionally arguments
                            '''
                    Severity: Minor
                    Found in app/gathering/measuring/ohm_source.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 rate_update_valid has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

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

                        def get_cpu_measurement(self, metric, args):
                            """
                                Updates the hardware class for the specified cpu (not cores, whole cpu socket)
                                and returns the value for the  specified metric
                            """
                    Severity: Minor
                    Found in app/gathering/measuring/ohm_source.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

                    Avoid too many return statements within this function.
                    Open

                                return False
                    Severity: Major
                    Found in app/application_settings/configuration_settings.py - About 30 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language