crowbar/crowbar-ha

View on GitHub

Showing 91 of 91 total issues

Method get has a Cognitive Complexity of 17 (exceeds 5 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 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

File application.js has 259 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * Copyright 2011-2013, Dell
 * Copyright 2013-2014, SUSE LINUX Products GmbH
 *
 * Licensed under the Apache License, Version 2.0 (the "License");

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 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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  StonithNodeAgents.prototype.writeJson = function(key, value, type) {
    return $(this.options.storage).writeJsonAttribute(
      '{0}/{1}'.format(
        this.options.path,
        key
crowbar_framework/app/assets/javascripts/barclamps/pacemaker/application.js on lines 193..202

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 65.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  StonithNodeAgents.prototype.removeJson = function(key, value, type) {
    return $(this.options.storage).removeJsonAttribute(
      '{0}/{1}'.format(
        this.options.path,
        key
crowbar_framework/app/assets/javascripts/barclamps/pacemaker/application.js on lines 182..191

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 65.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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
Severity
Category
Status
Source
Language