Nekmo/simple-monitor-alert

View on GitHub
simple_monitor_alert/monitor.py

Summary

Maintainability
B
4 hrs
Test Coverage

Function _execute_process has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def _execute_process(self, env):
        lines = []
        popen = subprocess.Popen([self.script_path], stdout=subprocess.PIPE, env=env)

        l = self.get_timer(popen)
Severity: Minor
Found in simple_monitor_alert/monitor.py - About 2 hrs 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 parse_lines has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_lines(self, lines, on_error=InvalidScriptLineLogging):
        for i, line in enumerate(lines):
            try:
                yield RawLine.parse(line, self)
            except InvalidScriptLineError:
Severity: Minor
Found in simple_monitor_alert/monitor.py - About 1 hr 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 log_evaluate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def log_evaluate(observable, result=None, use_logger=True):
    from simple_monitor_alert.utils.system import get_hostname
    result = result or observable.evaluate()
    level = 'success' if result else observable.get_line_value('level') or 'warning'
    msg = '{} - - Trigger: [{}] ({}) {}. '.format(get_hostname(), level,
Severity: Minor
Found in simple_monitor_alert/monitor.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 execute_all has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def execute_all(self, use_config=True):
        for monitor in self.get_monitors():
            if not monitor.shoud_be_executed():
                continue
            observables = self.execute(monitor)
Severity: Minor
Found in simple_monitor_alert/monitor.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

There are no issues that match your filters.

Category
Status