Showing 53 of 66 total issues
Function get_measurement
has a Cognitive Complexity of 29 (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
'''
- Read upRead up
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
File ohm_source.py
has 313 lines of code (exceeds 250 allowed). Consider refactoring. Open
'''
This module is pretty experimental and uses pythonnet to laod a C#-DLL
The OpenHardwareMonitorLib is a pretty sophisticated library to get system metrics
For more information about the project/code visit the GitHub Repository
https://github.com/openhardwaremonitor/openhardwaremonitor
Endpoint
has 27 functions (exceeds 20 allowed). Consider refactoring. Open
class Endpoint(metaclass=ABCMeta):
_outbound_gate = DefaultDataGate
_request_holder = None
_response_holder = None
File psutil_source.py
has 294 lines of code (exceeds 250 allowed). Consider refactoring. Open
'''
This module contains a wrapper class to create a nice fitting interface to the psutil module
'''
import logging
Function is_pathname_valid
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def is_pathname_valid(pathname: str) -> bool:
'''
`True` if the passed pathname is a valid pathname for the current OS;
`False` otherwise.
SRC: http://stackoverflow.com/questions/9532499
- Read upRead up
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_endpoint
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def __init_endpoint(self, endpoints_prefix, endpoint_class, version, is_current):
basic_auth = self.__basic_auth # read basic_auth from wrapper class
class CustomResource(Resource):
if basic_auth is not None:
- Read upRead up
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 add_cpu
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def add_cpu(self, hardware):
'''
Adds the given CPU (as OHM Hardware Object) to the cpu list
Also adds all its cores and updates the supported metrics
'''
- Read upRead up
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_all_component_metrics
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def __get_all_component_metrics(cls) -> dict:
from misc.constants import implemented_hardware, component_needs_arg
component_metrics = {}
for component_type in implemented_hardware:
- Read upRead up
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 11 (exceeds 5 allowed). Consider refactoring. Open
def get_measurement(cls, component, metric, args):
"""
Given the component and metric this function uses the libraries to make a measurement
Returns: The value of the measurement
"""
- Read upRead up
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 11 (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
'''
- Read upRead up
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 run
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def run(self):
"""
Starts the whole gathering process by manually
starting the queue_listener and then waiting for updates
"""
- Read upRead up
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
Consider simplifying this complex logical expression. Open
if "component_type" not in request_body or request_body["component_type"] not in component_metrics_dict:
# TODO Future version: Log and return error message
return self.STOP_PROCESSING()
elif "component_arg" not in request_body \
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
- Read upRead up
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"
- Read upRead up
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_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
"""
- Read upRead up
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
- Read upRead up
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_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,
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):
Function get_measurements
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_measurements(cls,
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
"""
- Read upRead up
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"