crowbar/crowbar-ha

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

Summary

Maintainability
F
1 wk
Test Coverage

File pacemaker_service.rb has 708 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class PacemakerService < ServiceObject
  def initialize(thelogger = nil)
    super
    @bc_name = "pacemaker"
  end
Severity: Major
Found in crowbar_framework/app/models/pacemaker_service.rb - About 1 day to fix

Method validate_proposal_stonith has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
Open

  def validate_proposal_stonith stonith_attributes, members
    case stonith_attributes["mode"]
    when "manual"
      # nothing to do
    when "sbd"
Severity: Minor
Found in crowbar_framework/app/models/pacemaker_service.rb - About 1 day 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 validate_proposal_after_save has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
Open

  def validate_proposal_after_save proposal
    validate_at_least_n_for_role proposal, "pacemaker-cluster-member", 1

    role_name = proposal["deployment"][@bc_name]["config"]["environment"]
    elements = proposal["deployment"][@bc_name]["elements"]
Severity: Minor
Found in crowbar_framework/app/models/pacemaker_service.rb - About 1 day 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 validate_proposal_after_save has 133 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def validate_proposal_after_save proposal
    validate_at_least_n_for_role proposal, "pacemaker-cluster-member", 1

    role_name = proposal["deployment"][@bc_name]["config"]["environment"]
    elements = proposal["deployment"][@bc_name]["elements"]
Severity: Major
Found in crowbar_framework/app/models/pacemaker_service.rb - About 5 hrs to fix

Method validate_proposal_stonith has 121 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def validate_proposal_stonith stonith_attributes, members
    case stonith_attributes["mode"]
    when "manual"
      # nothing to do
    when "sbd"
Severity: Major
Found in crowbar_framework/app/models/pacemaker_service.rb - About 4 hrs to fix

Method apply_role_pre_chef_call has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

  def apply_role_pre_chef_call(old_role, role, all_nodes)
    @logger.debug("Pacemaker apply_role_pre_chef_call: entering #{all_nodes.inspect}")

    attributes = role.override_attributes[@bc_name]
    old_attributes = old_role.override_attributes[@bc_name] unless old_role.nil?
Severity: Minor
Found in crowbar_framework/app/models/pacemaker_service.rb - About 4 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 apply_cluster_roles_to_new_nodes_for has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

  def apply_cluster_roles_to_new_nodes_for(cluster_element, relevant_nodes, all_roles)
    return [] if relevant_nodes.empty?

    ### Beware of possible confusion between different level of "roles"!
    # See comment in apply_cluster_roles_to_new_nodes
Severity: Minor
Found in crowbar_framework/app/models/pacemaker_service.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 apply_role_pre_chef_call has 69 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def apply_role_pre_chef_call(old_role, role, all_nodes)
    @logger.debug("Pacemaker apply_role_pre_chef_call: entering #{all_nodes.inspect}")

    attributes = role.override_attributes[@bc_name]
    old_attributes = old_role.override_attributes[@bc_name] unless old_role.nil?
Severity: Major
Found in crowbar_framework/app/models/pacemaker_service.rb - About 2 hrs to fix

Method prepare_stonith_attributes has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def prepare_stonith_attributes(role_attributes, remote_nodes, member_nodes, remotes, members)
    cluster_nodes = member_nodes + remote_nodes
    stonith_attributes = role_attributes["stonith"]

    # still make the original mode available
Severity: Major
Found in crowbar_framework/app/models/pacemaker_service.rb - About 2 hrs to fix

Class PacemakerService has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

class PacemakerService < ServiceObject
  def initialize(thelogger = nil)
    super
    @bc_name = "pacemaker"
  end
Severity: Minor
Found in crowbar_framework/app/models/pacemaker_service.rb - About 2 hrs to fix

Method apply_cluster_roles_to_new_nodes_for has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def apply_cluster_roles_to_new_nodes_for(cluster_element, relevant_nodes, all_roles)
    return [] if relevant_nodes.empty?

    ### Beware of possible confusion between different level of "roles"!
    # See comment in apply_cluster_roles_to_new_nodes
Severity: Major
Found in crowbar_framework/app/models/pacemaker_service.rb - About 2 hrs to fix

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

  def prepare_stonith_attributes(role_attributes, remote_nodes, member_nodes, remotes, members)
    cluster_nodes = member_nodes + remote_nodes
    stonith_attributes = role_attributes["stonith"]

    # still make the original mode available
Severity: Minor
Found in crowbar_framework/app/models/pacemaker_service.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 validate_mcast_addr has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def validate_mcast_addr(used_addrs, ring_index, curr_addr)
    # compare current address to used addresses
    curr_addr_used = (curr_addr != "") && (used_addrs.key? curr_addr)

    # if address is used or empty, find an available address
Severity: Minor
Found in crowbar_framework/app/models/pacemaker_service.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 validate_mcast_addr has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def validate_mcast_addr(used_addrs, ring_index, curr_addr)
    # compare current address to used addresses
    curr_addr_used = (curr_addr != "") && (used_addrs.key? curr_addr)

    # if address is used or empty, find an available address
Severity: Minor
Found in crowbar_framework/app/models/pacemaker_service.rb - About 1 hr to fix

Method role_constraints has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def role_constraints
      {
        "pacemaker-cluster-member" => {
          "unique" => false,
          "count" => 32,
Severity: Minor
Found in crowbar_framework/app/models/pacemaker_service.rb - About 1 hr to fix

Method apply_cluster_roles_to_new_nodes has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def apply_cluster_roles_to_new_nodes(role, member_nodes, remote_nodes)
    ### Beware of possible confusion between different level of "roles"!
    # - we have barclamp roles that are related to a barclamp (as in "knife role
    #   list | grep config" or RoleObject.proposal?); the cluster_role variable
    #   is always such a role
Severity: Minor
Found in crowbar_framework/app/models/pacemaker_service.rb - About 1 hr to fix

Method apply_role_post_chef_call has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def apply_role_post_chef_call(old_role, role, all_nodes)
    @logger.debug("Pacemaker apply_role_post_chef_call: entering #{all_nodes.inspect}")

    # Make sure the nodes have a link to the dashboard on them.  This
    # needs to be done via apply_role_post_chef_call rather than
Severity: Minor
Found in crowbar_framework/app/models/pacemaker_service.rb - About 45 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 prepare_stonith_attributes has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def prepare_stonith_attributes(role_attributes, remote_nodes, member_nodes, remotes, members)
Severity: Minor
Found in crowbar_framework/app/models/pacemaker_service.rb - About 35 mins to fix

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

  def allocate_member_addresses(nodes, network)
    members = []

    net_svc = NetworkService.new @logger
    nodes.each_with_index do |node, node_index|
Severity: Minor
Found in crowbar_framework/app/models/pacemaker_service.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 build_used_mcast_addrs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def build_used_mcast_addrs(proposal_id, role_name)
    used_mcast_addrs = {}

    # iterate proposals, skip current proposal by ID
    proposals_raw.each do |p|
Severity: Minor
Found in crowbar_framework/app/models/pacemaker_service.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

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

  def preserve_existing_password(role, old_role)
    if role.default_attributes["pacemaker"]["corosync"]["password"].empty?
      # no password requested
      return
    end
Severity: Minor
Found in crowbar_framework/app/models/pacemaker_service.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