crowbar/crowbar-ha

View on GitHub

Showing 91 of 91 total issues

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

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

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

  describe "#params_string" do
    it "should return empty string with nil params" do
      fixture.params = nil
      expect(fixture.params_string).to eq("")
    end
chef/cookbooks/pacemaker/spec/helpers/meta_examples.rb on lines 2..18

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

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

  describe "#meta_string" do
    it "should return empty string with nil meta" do
      fixture.meta = nil
      expect(fixture.meta_string).to eq("")
    end
Severity: Minor
Found in chef/cookbooks/pacemaker/spec/helpers/meta_examples.rb and 1 other location - About 1 hr to fix
chef/cookbooks/pacemaker/spec/libraries/pacemaker/resource/primitive_spec.rb on lines 28..44

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

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

def downgrade(ta, td, a, d)
  downgrade_to_single_ring(a["corosync"])

  unless d.key?("required_post_chef_calls")
    begin
Severity: Minor
Found in chef/data_bags/crowbar/migrate/pacemaker/201_add_ring_array.rb and 1 other location - About 55 mins to fix
chef/data_bags/crowbar/migrate/pacemaker/201_add_ring_array.rb on lines 26..46

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

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

def upgrade(ta, td, a, d)
  upgrade_to_multi_ring(a["corosync"])

  # Are we a proposal? If yes, then look for the applied role if it exists and modify it
  # (the pacemaker barclamp adds an required_post_chef_calls attribute to the
Severity: Minor
Found in chef/data_bags/crowbar/migrate/pacemaker/201_add_ring_array.rb and 1 other location - About 55 mins to fix
chef/data_bags/crowbar/migrate/pacemaker/201_add_ring_array.rb on lines 68..81

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

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

  def self.stonith_agent_valid?(agent)
    if agent.nil? || agent.empty?
      false
    else
      if @@stonith_agents.nil?
Severity: Minor
Found in chef/cookbooks/pacemaker/libraries/stonith.rb - About 55 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 get_options has a Cognitive Complexity of 9 (exceeds 5 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 55 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 cluster_founder has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def self.cluster_founder(node)
    return nil unless cluster_enabled?(node)

    if is_cluster_founder? node
      node
Severity: Minor
Found in chef/cookbooks/crowbar-pacemaker/libraries/helpers.rb - About 55 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 from_definition has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def from_definition(definition)
        calling_class = self.singleton_class
        this_class = method(__method__).owner
        if calling_class == this_class
          # Invoked via (this) base class
Severity: Minor
Found in chef/cookbooks/pacemaker/libraries/pacemaker/cib_object.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 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

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

  block do
    file = File.new(authkey_file, "r")
    contents = ""
    file.each do |f|
      contents << f
Severity: Minor
Found in chef/cookbooks/corosync/recipes/authkey_generator.rb and 1 other location - About 45 mins to fix
chef/cookbooks/pacemaker/recipes/authkey_generator.rb on lines 50..59

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

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

  block do
    file = File.new(authkey_file, "r")
    contents = ""
    file.each do |f|
      contents << f
Severity: Minor
Found in chef/cookbooks/pacemaker/recipes/authkey_generator.rb and 1 other location - About 45 mins to fix
chef/cookbooks/corosync/recipes/authkey_generator.rb on lines 52..61

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

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

      def start_runnable_resource
        name = new_resource.name
        unless @current_resource
          raise "Cannot start non-existent #{cib_object_class.description} '#{name}'"
        end
chef/cookbooks/pacemaker/libraries/chef/mixin/pacemaker/runnable_resource.rb on lines 24..34

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

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

      def stop_runnable_resource
        name = new_resource.name
        unless @current_resource
          raise "Cannot stop non-existent #{cib_object_class.description} '#{name}'"
        end
chef/cookbooks/pacemaker/libraries/chef/mixin/pacemaker/runnable_resource.rb on lines 11..21

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

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

Severity
Category
Status
Source
Language