crowbar/crowbar-core

View on GitHub

Showing 6,062 of 6,062 total issues

Avoid deeply nested control flow statements.
Open

            if count >= 5
              message = "Ran \"#{zypper_command}\" more than five times, and it still requires more runs."
              Chef::Log.fatal(message)
              node.save # node is always dirty due to one_shot_run
              raise message
Severity: Major
Found in chef/cookbooks/updater/recipes/default.rb - About 45 mins to fix

Method downgrade has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def downgrade(ta, td, a, d)
  unless ta["networks"]["nova_floating"].key? "add_ovs_bridge"
    a["networks"]["nova_floating"].delete "add_ovs_bridge"
  end
  unless ta["networks"]["nova_floating"].key? "bridge_name"
Severity: Minor
Found in chef/data_bags/crowbar/migrate/network/011_add_ovs_attributes.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

Function ajaxSubmit has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

        ajaxSubmit: function (fnBefore, fnSuccess, fnComplete, fnError, previewId, index) {
Severity: Minor
Found in crowbar_framework/vendor/assets/javascripts/bootstrap/fileinput.js - About 45 mins to fix

Method enable_interface has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def enable_interface(bc_instance, network, name)
    Rails.logger.debug("Network enable_interface: entering #{name} #{network}")

    return [404, "No network specified"] if network.nil?
    return [404, "No name specified"] if name.nil?
Severity: Minor
Found in crowbar_framework/app/models/network_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

Avoid deeply nested control flow statements.
Open

              if(data) { data.key = key; }
Severity: Major
Found in crowbar_framework/vendor/assets/javascripts/misc/handlebars.js - About 45 mins to fix

Method get_network_by_type has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def self.get_network_by_type(node, type)
        unless node[:crowbar].nil? || node[:crowbar][:network].nil? ||
            node[:network].nil? || node[:network][:networks].nil?
          [type, "admin"].uniq.each do |usage|
            found = node[:crowbar][:network].find do |net, data|
Severity: Minor
Found in chef/cookbooks/barclamp/libraries/barclamp_library.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

Avoid deeply nested control flow statements.
Open

            if result[0] != 200
              Rails.logger.error("Failed to allocate bmc_vlan address for: " \
                "#{node.name}: #{result[0]}")
            end
Severity: Major
Found in crowbar_framework/app/models/network_service.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

        unless current_url.nil? || current_url.empty?
          Chef::Log.info("Removing #{name} zypper repository pointing to wrong URI...")
          `zypper --non-interactive removerepo #{name}`
        end
Severity: Major
Found in chef/cookbooks/provisioner/recipes/base.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

            if node[:updater][:do_reboot]
              Chef::Log.info("Will reboot node at the end of chef run.")
              node.run_state[:reboot] = true
              node[:updater][:need_reboot] = false
            else
Severity: Major
Found in chef/cookbooks/updater/recipes/default.rb - About 45 mins to fix

Method new has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def self.new(nic)
    logstr=""
    if nic.is_a?(::Nic)
      return nic
    elsif o = @@interfaces[nic]
Severity: Minor
Found in chef/cookbooks/barclamp/libraries/nic.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 search_env_filtered has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def search_env_filtered(type, query="*:*", sort="X_CHEF_id_CHEF_X asc",
                            start=0, rows=100, &block)
Severity: Minor
Found in chef/cookbooks/utils/libraries/search.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

            if result[0] != 200
              Rails.logger.error(
                "Failed to allocate bastion address for: #{node.name}: #{result[0]}"
              )
            else
Severity: Major
Found in crowbar_framework/app/models/network_service.rb - About 45 mins to fix

Method list_networks has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def self.list_networks(node)
        answer = []
        unless node[:crowbar].nil? || node[:crowbar][:network].nil? ||
            node[:network].nil? || node[:network][:networks].nil?
          node[:crowbar][:network].each do |net, data|
Severity: Minor
Found in chef/cookbooks/barclamp/libraries/barclamp_library.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 populate_cinder_volumes_with_ses_settings has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def populate_cinder_volumes_with_ses_settings(cinder_controller)
      ses_volume_found = false
      ses_config = ses_settings

      # Loop to check if we have SES managed cluster and update configs
Severity: Minor
Found in chef/cookbooks/ses/libraries/helpers.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 get_host_for_public_url has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def self.get_host_for_public_url(node, use_ssl, use_cluster = false,
                                   want_fqdn = false)
    if use_cluster && defined?(CrowbarPacemakerHelper)
      # loose dependency on the pacemaker cookbook
      cluster_vhostname = CrowbarPacemakerHelper.cluster_vhostname(node)
Severity: Minor
Found in chef/cookbooks/utils/libraries/helpers.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 find has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def self.find(nics)
      t = Hash.new
      nics.each do |n|
        n = Nic.coerce(n)
        t[n.name]=n
Severity: Minor
Found in chef/cookbooks/barclamp/libraries/nic.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 __nics has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def self.__nics
    res = []
    ::Dir.entries("/sys/class/net").each do |d|
      next if d == "." or d == ".."
      next unless ::File.directory?("/sys/class/net/#{d}")
Severity: Minor
Found in chef/cookbooks/barclamp/libraries/nic.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 add_role_to_instance_and_node has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def add_role_to_instance_and_node(barclamp, instance, name, prop, role, newrole)
Severity: Minor
Found in crowbar_framework/app/models/service_object.rb - About 45 mins to fix

Method content has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def content
      struct = [].tap do |result|
        barclamps.each do |barclamp|
          next unless process_barclamp?(
            barclamp
Severity: Minor
Found in crowbar_framework/app/models/batch/export.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 skip_unchanged_node? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def skip_unchanged_node?(node_name, old_role, new_role)
    # if old_role is nil, then we are applying the barclamp for the first time
    return false if old_role.nil?

    # if the servers have changed, we need to apply
Severity: Minor
Found in crowbar_framework/app/models/dns_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

Severity
Category
Status
Source
Language