crowbar/crowbar-ha

View on GitHub

Showing 63 of 91 total issues

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 wait_for_mark_from_founder has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.wait_for_mark_from_founder(node, mark, fatal = false, timeout = 60)
    return unless CrowbarPacemakerHelper.cluster_enabled?(node)
    return if CrowbarPacemakerHelper.is_cluster_founder?(node)
    if CrowbarPacemakerHelper.being_upgraded?(node)
      Chef::Log.debug("Node is being upgraded." \
Severity: Minor
Found in chef/cookbooks/crowbar-pacemaker/libraries/synchronization.rb - About 1 hr to fix

Method action_create has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def action_create
        name = new_resource.name
        physical_volume_list = [new_resource.physical_volumes].flatten

        # Make sure any pvs are not being used as filesystems (e.g. ephemeral0 on
Severity: Minor
Found in chef/cookbooks/lvm/libraries/provider_lvm_volume_group.rb - About 1 hr to fix

Method maybe_modify_resource has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def maybe_modify_resource(name)
  deprecate_target_role

  Chef::Log.info "Checking existing #{@current_cib_object} for modifications"

Severity: Minor
Found in chef/cookbooks/pacemaker/providers/primitive.rb - About 1 hr to fix

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

  def self.wait_for_mark_from_founder(node, mark, fatal = false, timeout = 60)
    return unless CrowbarPacemakerHelper.cluster_enabled?(node)
    return if CrowbarPacemakerHelper.is_cluster_founder?(node)
    if CrowbarPacemakerHelper.being_upgraded?(node)
      Chef::Log.debug("Node is being upgraded." \
Severity: Minor
Found in chef/cookbooks/crowbar-pacemaker/libraries/synchronization.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_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 crm_configure_show has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def crm_configure_show(name)
        cmd = Mixlib::ShellOut.new("crm --display=plain configure show #{name}")
        cmd.environment["HOME"] = ENV.fetch("HOME", "/root")
        cmd.run_command
        begin
Severity: Minor
Found in chef/cookbooks/pacemaker/libraries/pacemaker/cib_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 maybe_configure_params has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def maybe_configure_params(name, cmds, data_type)
  configure_cmd_prefix = "crm_resource --resource #{name}"

  new_resource.send(data_type).each do |param, new_value|
    current_value = @current_resource.send(data_type)[param]
Severity: Minor
Found in chef/cookbooks/pacemaker/providers/primitive.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 get has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.get(resource)
    cmd = "drbd-overview --color=no"
    output = Chef::ShellOut.new(cmd).run_command.stdout

    resource_output = ""
Severity: Minor
Found in chef/cookbooks/drbd/libraries/overview.rb - About 1 hr to fix

Method health_report has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def health_report
        ret = {}
        crm_failures = {}
        failed_actions = {}
        unready_nodes = {}
Severity: Minor
Found in crowbar_framework/app/models/api/pacemaker.rb - About 1 hr to fix

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 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 action_create has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def action_create
        name = new_resource.name
        physical_volume_list = [new_resource.physical_volumes].flatten

        # Make sure any pvs are not being used as filesystems (e.g. ephemeral0 on
Severity: Minor
Found in chef/cookbooks/lvm/libraries/provider_lvm_volume_group.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

Function update_no_quorum_policy has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

function update_no_quorum_policy(evt, init) {
  var no_quorum_policy_el = $('#crm_no_quorum_policy');
  var non_forced_policy = no_quorum_policy_el.data('non-forced');
  var was_forced_policy = no_quorum_policy_el.data('is-forced');
  var members = $('#pacemaker-cluster-member').children().length;

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 select_existing_resources has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.select_existing_resources(resources)
    existing_resources = []

    # evil command line; there must be a better way to fetch the list of resources
    # unfortunately, "crm_resource --list-raw" doesn't list groups/clones/etc.
Severity: Minor
Found in chef/cookbooks/crowbar-pacemaker/libraries/helpers.rb - About 1 hr to fix

Method get_options has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def get_options resource
  sync_mark_config = begin
    Chef::DataBagItem.load("crowbar-config", "sync_mark")
  rescue Net::HTTPServerException
    {}
Severity: Minor
Found in chef/cookbooks/crowbar-pacemaker/providers/sync_mark.rb - About 1 hr to fix

Method maybe_modify_resource has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def maybe_modify_resource(name)
  deprecate_target_role

  Chef::Log.info "Checking existing #{@current_cib_object} for modifications"

Severity: Minor
Found in chef/cookbooks/pacemaker/providers/primitive.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 one_op_string has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def self.one_op_string(op, attrs)
    if attrs.nil? || attrs.empty?
      nil
    else
      # crm seems to append interval=0 when there are attributes, but no
Severity: Minor
Found in chef/cookbooks/pacemaker/libraries/pacemaker/resource/primitive.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

Function redisplay_rings has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function redisplay_rings()
{
  if (!corosync_ring_template) {
    corosync_ring_template = Handlebars.compile(
      $('#ring-entries').html()
Severity
Category
Status
Source
Language