crowbar/crowbar-ha

View on GitHub

Showing 91 of 91 total issues

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

      def action_create # rubocop:disable MethodLength
        name = new_resource.name
        group = new_resource.group
        fs_type = new_resource.filesystem
        device_name = "/dev/mapper/#{to_dm_name(group)}-#{to_dm_name(name)}"
Severity: Minor
Found in chef/cookbooks/lvm/libraries/provider_lvm_logical_volume.rb - About 5 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 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 synchronize_on_mark has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

  def self.synchronize_on_mark(node, mark, fatal = false, timeout = 60)
    return unless CrowbarPacemakerHelper.cluster_enabled?(node)

    attribute = "#{prefix}#{mark}"
    cluster_name = CrowbarPacemakerHelper.cluster_name(node)
Severity: Minor
Found in chef/cookbooks/crowbar-pacemaker/libraries/synchronization.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

Class CIBObject has 31 methods (exceeds 20 allowed). Consider refactoring.
Open

  class CIBObject
    attr_accessor :name

    @@subclasses = { } unless class_variable_defined?(:@@subclasses)

Severity: Minor
Found in chef/cookbooks/pacemaker/libraries/pacemaker/cib_object.rb - About 3 hrs to fix

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

      def action_create # rubocop:disable MethodLength
        name = new_resource.name
        group = new_resource.group
        fs_type = new_resource.filesystem
        device_name = "/dev/mapper/#{to_dm_name(group)}-#{to_dm_name(name)}"
Severity: Major
Found in chef/cookbooks/lvm/libraries/provider_lvm_logical_volume.rb - About 3 hrs to fix

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 health_report has a Cognitive Complexity of 22 (exceeds 5 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 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 synchronize_on_mark has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.synchronize_on_mark(node, mark, fatal = false, timeout = 60)
    return unless CrowbarPacemakerHelper.cluster_enabled?(node)

    attribute = "#{prefix}#{mark}"
    cluster_name = CrowbarPacemakerHelper.cluster_name(node)
Severity: Major
Found in chef/cookbooks/crowbar-pacemaker/libraries/synchronization.rb - About 2 hrs to fix

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

describe Pacemaker::Resource::Clone do
  let(:fixture) { Chef::RSpec::Pacemaker::Config::CLONE_RESOURCE.dup }
  let(:fixture_definition) do
    Chef::RSpec::Pacemaker::Config::CLONE_RESOURCE_DEFINITION
  end
chef/cookbooks/pacemaker/spec/libraries/pacemaker/resource/group_spec.rb on lines 8..53
chef/cookbooks/pacemaker/spec/libraries/pacemaker/resource/ms_spec.rb on lines 8..53

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

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 3 locations. Consider refactoring.
Open

describe Pacemaker::Resource::MasterSlave do
  let(:fixture) { Chef::RSpec::Pacemaker::Config::MS_RESOURCE.dup }
  let(:fixture_definition) do
    Chef::RSpec::Pacemaker::Config::MS_RESOURCE_DEFINITION
  end
chef/cookbooks/pacemaker/spec/libraries/pacemaker/resource/clone_spec.rb on lines 8..53
chef/cookbooks/pacemaker/spec/libraries/pacemaker/resource/group_spec.rb on lines 8..53

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

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 3 locations. Consider refactoring.
Open

describe Pacemaker::Resource::Group do
  let(:fixture) { Chef::RSpec::Pacemaker::Config::RESOURCE_GROUP.dup }
  let(:fixture_definition) do
    Chef::RSpec::Pacemaker::Config::RESOURCE_GROUP_DEFINITION
  end
chef/cookbooks/pacemaker/spec/libraries/pacemaker/resource/clone_spec.rb on lines 8..53
chef/cookbooks/pacemaker/spec/libraries/pacemaker/resource/ms_spec.rb on lines 8..53

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

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