sensu-plugins/sensu-plugins-filesystem-checks

View on GitHub

Showing 4 of 4 total issues

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

  def run
    unknown 'No log file specified' unless config[:file]
    unknown 'No pattern specified' unless config[:pattern]
    if File.exist?(config[:file])
      if !config[:absent]
Severity: Minor
Found in bin/check-tail.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 18 (exceeds 5 allowed). Consider refactoring.
Open

  def run
    unknown 'No file or directory specified' unless config[:file] || config[:directory]
    unknown 'No warn or critical age specified' unless config[:warn] || config[:crit]

    requested_files = if config[:file]
Severity: Minor
Found in bin/check-ctime.rb - 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

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

  def run
    files = config[:files].split(',')

    if files.length == 1 && !config[:hash] && !config[:hashfile]
      unknown 'We have nothing to compare this file with.'
Severity: Minor
Found in bin/check-checksums.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 a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  def run
    unknown 'No file specified' unless config[:file]
    unknown 'No warn or critical age specified' unless config[:warning_age] || config[:critical_age]
    if File.exist?(config[:file])
      if File.size?(config[:file]).nil? && !config[:ok_zero_size]
Severity: Minor
Found in bin/check-mtime.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

Severity
Category
Status
Source
Language