sensu-plugins/sensu-plugins-windows

View on GitHub

Showing 3 of 7 total issues

Method read_wmic has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

  def read_wmic
    `wmic volume where DriveType=3 list brief /format:"%WINDIR%\\System32\\wbem\\en-US\\csv"`.split("\n").drop(1).each do |line|
      begin
        # #YELLOW
        _hostname, capacity, type, _fs, avail, label, mnt = line.split(',')
Severity: Minor
Found in bin/check-windows-disk.rb - About 5 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 19 (exceeds 5 allowed). Consider refactoring.
Open

  def run
    interface = config[:interface]
    timestamp = Time.now.utc.to_i
    IO.popen("typeperf -sc 1 \"\\Network Interface(#{interface})\\*\" ") do |io|
      CSV.parse(io.read.strip, headers: true) do |row|
Severity: Minor
Found in bin/metric-windows-network.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 12 (exceeds 5 allowed). Consider refactoring.
Open

  def run
    `wmic logicaldisk get caption, drivetype, freespace, size`.split(/\n+/).each do |line|
      caption, drivetype, freespace, size = line.split
      next unless drivetype.to_i == 3
      next if config[:ignore_mnt] && config[:ignore_mnt].find { |x| caption.match(x) }
Severity: Minor
Found in bin/metric-windows-disk-usage.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