sensu-plugins/sensu-plugins-chef

View on GitHub

Showing 4 of 6 total issues

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

  def run
    # chef-server-ctl must be run with elevated privs. fail if we're not uid 0
    if Process.uid.nonzero?
      unknown('check-chef-server must be run with elevated privileges so that chef-server-ctl can be executed')
    else
Severity: Minor
Found in bin/check-chef-server.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 nodes_last_seen has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def nodes_last_seen
    nodes = connection.node.all
    nodes.delete_if { |node| node.name =~ /#{config[:exclude_nodes]}/ }

    checked_nodes = []
Severity: Minor
Found in bin/check-chef-nodes.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 chef_node_exists? has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def chef_node_exists?
    retried = 0
    begin
      Ridley.open(
        server_url: settings['chef']['server_url'],
Severity: Minor
Found in bin/handler-chef-node.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 any_node_stuck? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def any_node_stuck?
    stuck = []
    @nodes_last_seen ||= nodes_last_seen
    @nodes_last_seen.flatten.each do |node|
      node.each do |name, status|
Severity: Minor
Found in bin/check-chef-nodes.rb - About 25 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