sensu-plugins/sensu-plugins-logs

View on GitHub

Showing 8 of 8 total issues

Method search_log has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

  def search_log
    log_file_size = @log.stat.size
    @bytes_to_skip = 0 if log_file_size < @bytes_to_skip
    bytes_read = 0
    n_warns = 0
Severity: Minor
Found in bin/check-log.rb - 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

Method run has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

  def run
    unknown 'No log file specified' unless config[:log_file] || config[:file_pattern]
    unknown 'No thresholds specified' unless config[:crit] || config[:warn]
    file_list = []
    file_list << config[:log_file] if config[:log_file]
Severity: Minor
Found in bin/check-log.rb - 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

Method handle has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def handle
    event_action = @event['action']
    event_action ||= 'unknown'
    check_name = @event['check']['name'] if (@event.include? 'check') && (@event['check'].include? 'name')
    check_name ||= 'unknown'
Severity: Minor
Found in bin/handler-logevent.rb - 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

Method run has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def run
    unknown 'No log file specified' unless config[:log_file] || config[:file_pattern]
    unknown 'No thresholds specified' unless config[:crit] || config[:warn]
    file_list = []
    file_list << config[:log_file] if config[:log_file]
Severity: Minor
Found in bin/check-log.rb - About 1 hr to fix

    Method search_log has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def search_log
        log_file_size = @log.stat.size
        @bytes_to_skip = 0 if log_file_size < @bytes_to_skip
        bytes_read = 0
        n_warns = 0
    Severity: Minor
    Found in bin/check-log.rb - About 1 hr to fix

      Method search_journal has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def search_journal(journalctl_args)
          n_matches = 0
      
          puts "Executing 'journalctl #{journalctl_args}'" if config[:verbose]
          IO.popen("journalctl #{journalctl_args}") do |cmd|
      Severity: Minor
      Found in bin/check-journal.rb - 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

      Method open_log has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def open_log(log_file)
          state_dir = config[:state_auto] || config[:state_dir]
      
          # Opens file using optional encoding page.  ex: 'iso8859-1'
          @log = if config[:encoding]
      Severity: Minor
      Found in bin/check-log.rb - 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

      Method get_log_entry has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def get_log_entry(first_line)
          log_entry = [first_line]
      
          @log.each_line do |line|
            line = encode_line(line)
      Severity: Minor
      Found in bin/check-log.rb - 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

      Severity
      Category
      Status
      Source
      Language