crowbar/crowbar-ceph

View on GitHub

Showing 21 of 35 total issues

Method validate_proposal_after_save has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

  def validate_proposal_after_save proposal
    validate_at_least_n_for_role proposal, "ceph-mon", 1
    validate_count_as_odd_for_role proposal, "ceph-mon"
    validate_at_least_n_for_role proposal, "ceph-osd", 2

Severity: Minor
Found in crowbar_framework/app/models/ceph_service.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 apply_role_pre_chef_call has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

  def apply_role_pre_chef_call(old_role, role, all_nodes)
    @logger.debug("ceph apply_role_pre_chef_call: entering #{all_nodes.inspect}")
    monitors = role.override_attributes["ceph"]["elements"]["ceph-mon"] || []
    osd_nodes = role.override_attributes["ceph"]["elements"]["ceph-osd"] || []
    mds_nodes = role.override_attributes["ceph"]["elements"]["ceph-mds"] || []
Severity: Minor
Found in crowbar_framework/app/models/ceph_service.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

File ceph_service.rb has 314 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "chef"

def mask_to_bits(mask)
  octets = mask.split(".")
  count = 0
Severity: Minor
Found in crowbar_framework/app/models/ceph_service.rb - About 3 hrs to fix

Method apply_role_pre_chef_call has 84 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def apply_role_pre_chef_call(old_role, role, all_nodes)
    @logger.debug("ceph apply_role_pre_chef_call: entering #{all_nodes.inspect}")
    monitors = role.override_attributes["ceph"]["elements"]["ceph-mon"] || []
    osd_nodes = role.override_attributes["ceph"]["elements"]["ceph-osd"] || []
    mds_nodes = role.override_attributes["ceph"]["elements"]["ceph-mds"] || []
Severity: Major
Found in crowbar_framework/app/models/ceph_service.rb - About 3 hrs to fix

Method find_node_ip_in_network has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

def find_node_ip_in_network(network, nodeish=nil)
  nodeish = node unless nodeish
  net = IPAddr.new(network)
  nodeish["network"]["interfaces"].each do |iface|
    if iface[1]["routes"].nil?
Severity: Minor
Found in chef/cookbooks/ceph/libraries/default.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 validate_proposal_after_save has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def validate_proposal_after_save proposal
    validate_at_least_n_for_role proposal, "ceph-mon", 1
    validate_count_as_odd_for_role proposal, "ceph-mon"
    validate_at_least_n_for_role proposal, "ceph-osd", 2

Severity: Major
Found in crowbar_framework/app/models/ceph_service.rb - About 2 hrs to fix

Method mask_to_bits has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

def mask_to_bits(mask)
  octets = mask.split(".")
  count = 0
  octets.each do |octet|
    break if octet == "0"
Severity: Minor
Found in crowbar_framework/app/models/ceph_service.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 role_constraints has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def role_constraints
      {
        "ceph-calamari" => {
          "unique" => false,
          "count" => 1,
Severity: Minor
Found in crowbar_framework/app/models/ceph_service.rb - About 1 hr to fix

Method auth_set_key has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def auth_set_key(ceph_conf, admin_keyring, keyname, caps)
  raise "No caps defined for ceph_client resource!" if caps.empty?
  # try to add the key
  caps_str = caps.map { |k, v| "#{k} '#{v}'" }.join(" ")
  cmd = "ceph -k #{admin_keyring} -c #{ceph_conf} auth get-or-create #{keyname} #{caps_str}"
Severity: Minor
Found in chef/cookbooks/ceph/providers/client.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 create_proposal has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def create_proposal
    @logger.debug("Ceph create_proposal: entering")
    base = super

    if base["attributes"]["ceph"]["config"]["fsid"].empty?
Severity: Minor
Found in crowbar_framework/app/models/ceph_service.rb - About 1 hr to fix

Method create_proposal has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def create_proposal
    @logger.debug("Ceph create_proposal: entering")
    base = super

    if base["attributes"]["ceph"]["config"]["fsid"].empty?
Severity: Minor
Found in crowbar_framework/app/models/ceph_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 get_ceph_client_name has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def get_ceph_client_name(cnode)
  if cnode["ceph"] && cnode["ceph"]["client_network"]
    net_name = cnode["ceph"]["client_network"]
  elsif node["ceph"] && node["ceph"]["client_network"]
    net_name = node["ceph"]["client_network"]
Severity: Minor
Found in chef/cookbooks/ceph/libraries/default.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 apply_role_post_chef_call has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def apply_role_post_chef_call(old_role, role, all_nodes)
    @logger.debug("ceph apply_role_post_chef_call: entering #{all_nodes.inspect}")
    calamari = role.override_attributes["ceph"]["elements"]["ceph-calamari"] || []

    calamari.each do |n|
Severity: Minor
Found in crowbar_framework/app/models/ceph_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 get_mon_addresses has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def get_mon_addresses()
  mon_ips = []
  node_name = get_ceph_client_name(node)
  if File.exist?("/var/run/ceph/ceph-mon.#{node_name}.asok")
    mon_ips = get_quorum_members_ips()
Severity: Minor
Found in chef/cookbooks/ceph/libraries/default.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_mon_nodes has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def get_mon_nodes(extra_search=nil)
  if is_crowbar?
    mon_roles = search(:role, "name:crowbar-* AND run_list_map:ceph-mon")
    if not mon_roles.empty?
      search_string = mon_roles.map { |role_object| "roles:"+role_object.name }.join(" OR ")
Severity: Minor
Found in chef/cookbooks/ceph/libraries/default.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

Avoid deeply nested control flow statements.
Open

          create_cmd            = create_cmd + " #{journal_device}" if journal_device
Severity: Major
Found in chef/cookbooks/ceph/recipes/osd.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

          if ssd_partitions > partitions_per_ssd && ssd_devices[ssd_index+1]
            ssd_partitions      = 0
            ssd_index           = ssd_index + 1
          end
Severity: Major
Found in chef/cookbooks/ceph/recipes/osd.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

        case service_type
        when "upstart"
          service_name "ceph-osd-all-starter"
          provider Chef::Provider::Service::Upstart
        else
Severity: Major
Found in chef/cookbooks/ceph/recipes/osd.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

          extra_options = "--mark-init systemd" if service_type == "systemd"
Severity: Major
Found in chef/cookbooks/ceph/recipes/osd.rb - About 45 mins to fix

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

def upgrade ta, td, a, d
  a["disk_mode"] = a["disk-mode"] || ta["disk_mode"]
  a["config"] = ta["config"]
  a["monitor-secret"] = ta["monitor-secret"]
  a["admin-secret"] = ta["admin-secret"]
Severity: Minor
Found in chef/data_bags/crowbar/migrate/ceph/001_migration_from_pebbles.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

Severity
Category
Status
Source
Language