crowbar/crowbar-ha

View on GitHub
crowbar_framework/app/models/pacemaker_service_object.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Class PacemakerServiceObject has 27 methods (exceeds 20 allowed). Consider refactoring.
Open

class PacemakerServiceObject < ServiceObject
  #
  # Eigenclass with methods used by ServiceObject
  #

Severity: Minor
Found in crowbar_framework/app/models/pacemaker_service_object.rb - About 3 hrs to fix

Method prepare_role_for_cluster_vip_networks has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def prepare_role_for_cluster_vip_networks(role, elements, networks)
    dirty = false

    elements.each do |element|
      next unless PacemakerServiceObject.is_cluster?(element)
Severity: Minor
Found in crowbar_framework/app/models/pacemaker_service_object.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 allocate_virtual_ips_for_cluster_in_networks has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def allocate_virtual_ips_for_cluster_in_networks(cluster, networks)
    if networks.nil? || networks.empty? || !PacemakerServiceObject.is_cluster?(cluster)
      [false, false]
    else
      nodes = PacemakerServiceObject.expand_nodes(cluster)
Severity: Minor
Found in crowbar_framework/app/models/pacemaker_service_object.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 prepare_role_for_ha_with_haproxy has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def prepare_role_for_ha_with_haproxy(role, attribute_path, ha_enabled, elements, networks)
Severity: Minor
Found in crowbar_framework/app/models/pacemaker_service_object.rb - About 35 mins to fix

Method role_expand_elements has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def role_expand_elements(role, role_name)
    elements = role.override_attributes[@bc_name]["elements"][role_name]
    expanded_nodes = nil
    if role.override_attributes[@bc_name].key?("elements_expanded")
      expanded_nodes = role.override_attributes[@bc_name]["elements_expanded"][role_name]
Severity: Minor
Found in crowbar_framework/app/models/pacemaker_service_object.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

There are no issues that match your filters.

Category
Status