crowbar/crowbar-ha

View on GitHub

Showing 63 of 91 total issues

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

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 prepare_role_for_ha_with_haproxy has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def prepare_role_for_ha_with_haproxy(role, attribute_path, ha_enabled, elements, networks)
Severity: Minor
Found in crowbar_framework/app/models/pacemaker_service_object.rb - About 35 mins to fix

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

      def set_node_as_founder(name)
        # 1. find the cluster new founder is in
        new_founder = NodeObject.find_node_by_name(name)
        if new_founder.nil?
          Rails.logger.error("Node #{name} not found!")
Severity: Minor
Found in crowbar_framework/app/models/api/pacemaker.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 upgrade has a Cognitive Complexity of 7 (exceeds 5 allowed). 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 - 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 extract_hash has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def self.extract_hash(obj_definition, data_type)
      results = find_all_to_extract(obj_definition, data_type).map do |string|
        extract_hash_from_one(string, data_type)
      end

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

def downgrade_to_single_ring(corosync)
  # skip if already downgraded
  return unless corosync["rings"]

  # move values from first ring to a flat list
Severity: Minor
Found in chef/data_bags/crowbar/migrate/pacemaker/201_add_ring_array.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 downgrade has a Cognitive Complexity of 7 (exceeds 5 allowed). 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 - 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 cluster_nodes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.cluster_nodes(node, role = nil)
    return [] unless cluster_enabled?(node)

    role ||= "pacemaker-cluster-member"
    server_nodes = []
Severity: Minor
Found in chef/cookbooks/crowbar-pacemaker/libraries/helpers.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 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 role_expand_elements has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def role_expand_elements(role, role_name)
    elements = role.override_attributes[@bc_name]["elements"][role_name]
    expanded_nodes = nil
    if role.override_attributes[@bc_name].key?("elements_expanded")
      expanded_nodes = role.override_attributes[@bc_name]["elements_expanded"][role_name]
Severity: Minor
Found in crowbar_framework/app/models/pacemaker_service_object.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 definition_from_attributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def definition_from_attributes
      str = "#{self.class.object_type} #{name} \"#{handler}\""
      str << continuation_line(meta_string) unless meta.nil? || meta.empty?
      str << continuation_line("to #{receiver}") unless receiver.nil? || receiver.empty?
      str
Severity: Minor
Found in chef/cookbooks/pacemaker/libraries/pacemaker/alert.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

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

      def report
        if maintenance_mode_set_via_this_chef_run?
          # Chef::Provider::PacemakerService must have handled at
          # least one :restart action, so we know we need to take
          # the node out of maintenance mode.

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

Severity
Category
Status
Source
Language