OpServ-Monitoring/opserv-backend

View on GitHub

Showing 53 of 66 total issues

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

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

                def __insert_default_gathering_rates(cls):
                    from misc import constants
                    default_rates = constants.default_gathering_rates
            
                    insert_values = []
            Severity: Minor
            Found in app/database/connectors/database_initializer.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 get_core_measurement has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_core_measurement(self, metric, args):
                    """
                        Updates the hardware of the given cpu core to get a measurement
                        for the specified metric
                    """
            Severity: Minor
            Found in app/gathering/measuring/ohm_source.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 print_stuff has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            def print_stuff():
                for chip in sensors.get_detected_chips():
                    print(chip)
            
                    for feature in chip.get_features():
            Severity: Minor
            Found in app/gathering/testing-sources/pysensortest.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 get_measurement has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_measurement(self, component, metric, args):
                    '''
                        Reads the temperature and frequency out of a file.
                        Temprature needs to be converted from millicentigrade to centigrade.
                    '''
            Severity: Minor
            Found in app/gathering/measuring/raspi_temp_source.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 ohm_hardware_added_handler has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def ohm_hardware_added_handler(self, hardware):
                    """
                        Hardware Added Handler
                        This is called with the given hardware when a new hardware on the computer is found
                    """
            Severity: Minor
            Found in app/gathering/measuring/ohm_source.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 net_calc_bytesper_sec has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def net_calc_bytesper_sec(self, received, name):
                    '''
                       Uses the last received data fields to calculate either the receive or sent
                       bytes per second. Returns zero if it couldn't be determined
                       Also can raise the FileNotFoundError, if the interface can not be found
            Severity: Minor
            Found in app/gathering/measuring/psutil_source.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