OpServ-Monitoring/opserv-backend

View on GitHub

Showing 66 of 66 total issues

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

              Avoid too many return statements within this function.
              Open

                              return self.cpuinfo.get_cpu_info()["count"]
              Severity: Major
              Found in app/gathering/measuring/cpuinfo_source.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                return None
                Severity: Major
                Found in app/server/restful_api/flask_restful_wrapper.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return False
                  Severity: Major
                  Found in app/server/restful_api/general/endpoint.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return self.KEEP_PROCESSING()
                    Severity: Major
                    Found in app/server/restful_api/data/v1/endpoints/gatheringrates.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                          return None
                      Severity: Major
                      Found in app/misc/opserv_helper.py - About 30 mins to fix

                        Function __read_limit_header has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def __read_limit_header(self, headers):
                                if "limit" in headers:
                                    try:
                                        limit = int(headers["limit"])
                        
                        

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

                            def __parse_component_metrics_dict_to_list(cls, component_metric_dict: dict) -> list:
                                component_metric_list = []
                        
                                for component_type in component_metric_dict:
                                    for component_arg in component_metric_dict[component_type]:
                        Severity: Minor
                        Found in app/server/restful_api/data/v1/endpoints/gatheringrates.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