Nekmo/simple-monitor-alert

View on GitHub

Showing 31 of 35 total issues

Function find_package_data has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
Open

def find_package_data(where='.', package='',
                      exclude=standard_exclude,
                      exclude_directories=standard_exclude_directories,
                      only_in_packages=True,
                      show_ignored=False):
Severity: Minor
Found in setup.py - About 1 day 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

File setup.py has 334 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import distutils
import filecmp
import getpass
Severity: Minor
Found in setup.py - About 4 hrs to fix

    Function set_default_subparser has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    def set_default_subparser(self, name, args=None):
        """default subparser selection. Call after setup, just before parse_args()
        name: is the name of the subparser to call by default
        args: if set is the argument list handed to parse_args()
    
    
    Severity: Minor
    Found in simple_monitor_alert/management.py - About 3 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

    File lines.py has 275 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import re
    import string
    import sys
    
    import six
    Severity: Minor
    Found in simple_monitor_alert/lines.py - About 2 hrs to fix

      Function run has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          def run(self):
              print('Starting Python module installation.')
              self.do_egg_install()
              print('-' * 80)
              if getpass.getuser() != 'root':
      Severity: Minor
      Found in setup.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 _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 pprint_list has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      def pprint_list(input_list, terminal_size=None):
          # http://stackoverflow.com/questions/25026556/output-list-like-ls
          term_width, term_height = terminal_size or get_terminal_size()
          if len(str(input_list)) <= term_width:
              print(input_list)
      Severity: Minor
      Found in simple_monitor_alert/utils/console.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 send has 10 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def send(self, subject, message, observable_name='', name='', extra_info=None, level='warning', fail=True,
      Severity: Major
      Found in alerts/telegram.py - About 1 hr to fix

        Function send has 10 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def send(self, subject, message, observable_name='', name='', extra_info=None, level='warning', fail=True,
        Severity: Major
        Found in alerts/mail.py - About 1 hr to fix

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

          def get_prints(auth=None):
              auth = auth or Auth()
              r = None
              for i in range(2):
                  r = requests.get(SEARCH_PRINTS, auth=auth)
          Severity: Minor
          Found in monitors/google-cloud-print.py - About 55 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 send_alerts has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def send_alerts(self, observable, fail=True):
                  communication = ObservableCommunication(observable, fail)
                  for alert in self:
                      seconds = observable.get_line_value('seconds', 0)
                      since = self.sma.results.get_observable_result(observable).get('since')
          Severity: Minor
          Found in simple_monitor_alert/alerts.py - About 55 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 deeply nested control flow statements.
          Open

                              if (fnmatchcase(name, pattern)
                                  or fn.lower() == pattern.lower()):
                                  bad_name = True
                                  if show_ignored:
                                      sys.stderr.write(
          Severity: Major
          Found in setup.py - About 45 mins to fix

            Function find_package_data has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def find_package_data(where='.', package='',
            Severity: Minor
            Found in setup.py - About 45 mins to fix

              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

              Avoid deeply nested control flow statements.
              Open

                                  if (fnmatchcase(name, pattern)
                                      or fn.lower() == pattern.lower()):
                                      bad_name = True
                                      if show_ignored:
                                          sys.stderr.write(
              Severity: Major
              Found in setup.py - About 45 mins to fix

                Function get_alerts_config has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def get_alerts_config(self):
                        for section in self.config.sections():
                            if self.config.has_option(section, 'alert'):
                                alert = self.config.get(section, 'alert')
                                if alert not in self.valid_alerts:
                Severity: Minor
                Found in simple_monitor_alert/alerts.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

                Avoid deeply nested control flow statements.
                Open

                                    if not package:
                                        new_package = name
                                    else:
                                        new_package = package + '.' + name
                                    stack.append((fn, '', new_package, False))
                Severity: Major
                Found in setup.py - About 45 mins to fix

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

                      def send(self, subject, message, observable=None, result=None, **kwargs):
                  Severity: Minor
                  Found in alerts/file.py - About 35 mins to fix

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

                    def _sma_observable(observable_name, expected, function=None, param=None, value=None):
                    Severity: Minor
                    Found in monitors/web.py - About 35 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language