Nekmo/simple-monitor-alert

View on GitHub

Showing 35 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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                    for pattern in exclude_directories:
                        if (fnmatchcase(name, pattern)
                            or fn.lower() == pattern.lower()):
                            bad_name = True
                            if show_ignored:
    Severity: Major
    Found in setup.py and 1 other location - About 3 hrs to fix
    setup.py on lines 218..226

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 64.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                    for pattern in exclude:
                        if (fnmatchcase(name, pattern)
                            or fn.lower() == pattern.lower()):
                            bad_name = True
                            if show_ignored:
    Severity: Major
    Found in setup.py and 1 other location - About 3 hrs to fix
    setup.py on lines 194..202

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 64.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      class ItemLine(KeyValueLine):
          def __init__(self, key, value):
              super(ItemLine, self).__init__(key, value)
      
          def __str__(self):
      Severity: Major
      Found in simple_monitor_alert/lines.py and 1 other location - About 1 hr to fix
      simple_monitor_alert/lines.py on lines 317..322

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 47.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      class HeaderLine(KeyValueLine):
          def __init__(self, key, value):
              super(HeaderLine, self).__init__(key, value)
      
          def __str__(self):
      Severity: Major
      Found in simple_monitor_alert/lines.py and 1 other location - About 1 hr to fix
      simple_monitor_alert/lines.py on lines 309..314

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 47.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      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
                Severity
                Category
                Status
                Source
                Language