File upgrade.rb
has 1844 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "open3"
module Api
class Upgrade < Tableless
class << self
- Create a ticketCreate a ticket
Class Upgrade
has 78 methods (exceeds 20 allowed). Consider refactoring. Open
class Upgrade < Tableless
class << self
def timeouts
::Crowbar::UpgradeTimeouts.new.values
end
- Create a ticketCreate a ticket
Method services
has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring. Open
def services
return unless cluster_health_check
return unless check_schema_migrations
return unless check_product_version
begin
- Read upRead up
- Create a ticketCreate a ticket
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 checks
has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring. Open
def checks
upgrade_status = ::Crowbar::UpgradeStatus.new
upgrade_status.start_step(:prechecks)
{}.tap do |ret|
- Read upRead up
- Create a ticketCreate a ticket
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 services
has 163 lines of code (exceeds 25 allowed). Consider refactoring. Open
def services
return unless cluster_health_check
return unless check_schema_migrations
return unless check_product_version
begin
- Create a ticketCreate a ticket
Method adminrepocheck
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
def adminrepocheck
upgrade_status = ::Crowbar::UpgradeStatus.new
upgrade_status.start_step(:repocheck_crowbar)
zypper_stream = Hash.from_xml(
`sudo /usr/bin/zypper-retry --xmlout products`
- Read upRead up
- Create a ticketCreate a ticket
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 adminrepocheck
has 102 lines of code (exceeds 25 allowed). Consider refactoring. Open
def adminrepocheck
upgrade_status = ::Crowbar::UpgradeStatus.new
upgrade_status.start_step(:repocheck_crowbar)
zypper_stream = Hash.from_xml(
`sudo /usr/bin/zypper-retry --xmlout products`
- Create a ticketCreate a ticket
Method upgradable_elements_of_proposals
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def upgradable_elements_of_proposals(proposals)
to_upgrade = []
# First find out the nodes with compute role, for later checks
compute_nodes = {}
- Read upRead up
- Create a ticketCreate a ticket
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 nodes
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def nodes(component = "all")
status = ::Crowbar::UpgradeStatus.new
if component == "postpone"
status.postpone
- Read upRead up
- Create a ticketCreate a ticket
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 non_disruptive_upgrade_compute_nodes
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def non_disruptive_upgrade_compute_nodes(names)
compute_nodes = names.map do |name|
::Node.find_node_by_name_or_alias(name)
end
- Read upRead up
- Create a ticketCreate a ticket
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 checks
has 91 lines of code (exceeds 25 allowed). Consider refactoring. Open
def checks
upgrade_status = ::Crowbar::UpgradeStatus.new
upgrade_status.start_step(:prechecks)
{}.tap do |ret|
- Create a ticketCreate a ticket
Method nodes
has 91 lines of code (exceeds 25 allowed). Consider refactoring. Open
def nodes(component = "all")
status = ::Crowbar::UpgradeStatus.new
if component == "postpone"
status.postpone
- Create a ticketCreate a ticket
Method parallel_upgrade_compute_nodes
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def parallel_upgrade_compute_nodes(compute_nodes, controller = nil)
Rails.logger.info("Entering parallel upgrade of compute nodes, #{upgrade_mode} mode")
Rails.logger.info("Nodes for upgrade: #{compute_nodes.map(&:name).join(', ')}")
save_nodes_state(compute_nodes, "compute", "upgrading")
save_node_action("upgrading the packages")
- Read upRead up
- Create a ticketCreate a ticket
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 openstackbackup
has 84 lines of code (exceeds 25 allowed). Consider refactoring. Open
def openstackbackup
crowbar_lib_dir = "/var/lib/crowbar"
dump_path = "#{crowbar_lib_dir}/backup/8-to-9-openstack_dump.sql.gz"
if File.exist?(dump_path)
Rails.logger.warn("OpenStack backup already exists. Skipping...")
- Create a ticketCreate a ticket
Method parallel_upgrade_compute_nodes
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parallel_upgrade_compute_nodes(compute_nodes, controller = nil)
Rails.logger.info("Entering parallel upgrade of compute nodes, #{upgrade_mode} mode")
Rails.logger.info("Nodes for upgrade: #{compute_nodes.map(&:name).join(', ')}")
save_nodes_state(compute_nodes, "compute", "upgrading")
save_node_action("upgrading the packages")
- Create a ticketCreate a ticket
Method evacuate_network_node
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
def evacuate_network_node(controller, network_node, delete_namespaces = false)
save_node_action("evacuating dhcp networks")
hostname = network_node["hostname"]
migrated_file = "/var/lib/crowbar/upgrade/crowbar-network-evacuated"
if network_node.file_exist? migrated_file
- Create a ticketCreate a ticket
Method openstackbackup
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def openstackbackup
crowbar_lib_dir = "/var/lib/crowbar"
dump_path = "#{crowbar_lib_dir}/backup/8-to-9-openstack_dump.sql.gz"
if File.exist?(dump_path)
Rails.logger.warn("OpenStack backup already exists. Skipping...")
- Read upRead up
- Create a ticketCreate a ticket
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 ha_config_errors
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def ha_config_errors(check)
ret = {}
if check[:errors]
ret[:ha_configured] = {
data: check[:errors],
- Create a ticketCreate a ticket
Method non_disruptive_upgrade_compute_nodes
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def non_disruptive_upgrade_compute_nodes(names)
compute_nodes = names.map do |name|
::Node.find_node_by_name_or_alias(name)
end
- Create a ticketCreate a ticket
Method prepare_compute_nodes
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def prepare_compute_nodes(virt)
Rails.logger.info("Preparing #{virt} compute nodes for upgrade... ")
compute_nodes = ::Node.find("roles:nova-compute-#{virt}")
if compute_nodes.empty?
Rails.logger.info("There are no compute nodes of #{virt} type.")
- Create a ticketCreate a ticket
Method run_online_migrations
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def run_online_migrations
nova_nodes = ::Node.find("roles:nova-controller")
heat_nodes = ::Node.find("roles:heat-server")
return if nova_nodes.empty? && heat_nodes.empty?
- Read upRead up
- Create a ticketCreate a ticket
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 noderepocheck
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def noderepocheck
upgrade_status = ::Crowbar::UpgradeStatus.new
upgrade_status.start_step(:repocheck_nodes)
response = {}
- Create a ticketCreate a ticket
Method start_remote_resources
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def start_remote_resources(controller, hostname)
save_node_action("starting services at remote node #{hostname}")
out = controller.run_ssh_cmd(
"crm --wait node ready remote-#{hostname}",
"60s"
- Create a ticketCreate a ticket
Method execute_scripts_and_wait_for_finish
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def execute_scripts_and_wait_for_finish(nodes, script, seconds)
nodes.each do |node|
Rails.logger.info("Executing script '#{script}' at #{node.name}")
ssh_status = node.ssh_cmd(script).first
if ssh_status != 200
- Create a ticketCreate a ticket
Method keystone_migrate_and_restart
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def keystone_migrate_and_restart(node)
save_node_action("Making sure that Keystone is stopped on non-upgraded nodes")
cluster = node[:pacemaker][:config][:environment]
- Create a ticketCreate a ticket
Method upgradable_elements_of_proposals
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def upgradable_elements_of_proposals(proposals)
to_upgrade = []
# First find out the nodes with compute role, for later checks
compute_nodes = {}
- Create a ticketCreate a ticket
Method delete_upgrade_scripts
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def delete_upgrade_scripts(node)
return if node.admin?
scripts_to_delete = [
"prepare-repositories",
- Create a ticketCreate a ticket
Method upgrade_first_cluster_node
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def upgrade_first_cluster_node(node, other_node)
return true if node.upgraded?
node_api = Api::Node.new node.name
other_node_api = Api::Node.new other_node.name
node_api.save_node_state("controller", "upgrading")
- Create a ticketCreate a ticket
Method run_online_migrations
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run_online_migrations
nova_nodes = ::Node.find("roles:nova-controller")
heat_nodes = ::Node.find("roles:heat-server")
return if nova_nodes.empty? && heat_nodes.empty?
- Create a ticketCreate a ticket
Method upgrade_controller_clusters
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def upgrade_controller_clusters
::Crowbar::UpgradeStatus.new.save_substep(:controller_nodes, :running)
return upgrade_controllers_disruptive if upgrade_mode == :normal
- Create a ticketCreate a ticket
Method upgrade_controllers_disruptive
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def upgrade_controllers_disruptive
Rails.logger.info("Entering disruptive upgrade of controller nodes")
# Go through all OpenStack barclamps ordered by run_order
proposals = {}
- Read upRead up
- Create a ticketCreate a ticket
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 execute_scripts_and_wait_for_finish
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def execute_scripts_and_wait_for_finish(nodes, script, seconds)
nodes.each do |node|
Rails.logger.info("Executing script '#{script}' at #{node.name}")
ssh_status = node.ssh_cmd(script).first
if ssh_status != 200
- Read upRead up
- Create a ticketCreate a ticket
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_controller_clusters
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def upgrade_controller_clusters
::Crowbar::UpgradeStatus.new.save_substep(:controller_nodes, :running)
return upgrade_controllers_disruptive if upgrade_mode == :normal
- Read upRead up
- Create a ticketCreate a ticket
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 evacuate_network_node
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def evacuate_network_node(controller, network_node, delete_namespaces = false)
save_node_action("evacuating dhcp networks")
hostname = network_node["hostname"]
migrated_file = "/var/lib/crowbar/upgrade/crowbar-network-evacuated"
if network_node.file_exist? migrated_file
- Read upRead up
- Create a ticketCreate a ticket
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 start_remote_resources
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def start_remote_resources(controller, hostname)
save_node_action("starting services at remote node #{hostname}")
out = controller.run_ssh_cmd(
"crm --wait node ready remote-#{hostname}",
"60s"
- Read upRead up
- Create a ticketCreate a ticket
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 stop_nova_services
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def stop_nova_services
nova_nodes = if upgrade_mode == :normal
::Node.find("roles:nova-controller")
else
::Node.find("roles:nova-*").sort do |n|
- Read upRead up
- Create a ticketCreate a ticket
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 reload_nova_services
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def reload_nova_services
nova_nodes = if upgrade_mode == :normal
::Node.find("roles:nova-controller")
else
::Node.find("roles:nova-*").sort do |n|
- Read upRead up
- Create a ticketCreate a ticket
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 node_status
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def node_status
not_upgraded = []
upgraded = []
if ::Crowbar::UpgradeStatus.new.finished?
upgraded = ::Node.all.reject(&:admin?).map(&:name)
- Read upRead up
- Create a ticketCreate a ticket
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_nodes_disruptive
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def upgrade_nodes_disruptive(elements_to_upgrade)
elements_to_upgrade.each do |element|
# If role has a cluster assigned ugprade that cluster (reuse the non-disruptive code here)
if ServiceObject.is_cluster?(element)
cluster = ServiceObject.cluster_name element
- Read upRead up
- Create a ticketCreate a ticket
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 check_for_running_instances
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def check_for_running_instances
controller = ::Node.find("run_list_map:nova-controller").first
if controller.nil?
Rails.logger.info("No nova-controller node found.")
return
- Read upRead up
- Create a ticketCreate a ticket
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 unlock_crowbar_ui_package
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def unlock_crowbar_ui_package
ui_unlock = run_cmd("sudo zypper-retry removelock 'crowbar-ui*'")
unless ui_unlock[:exit_code].zero?
raise_node_upgrade_error(
"Removing crowbar-ui package lock has failed. " \
- Read upRead up
- Create a ticketCreate a ticket
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_compute_nodes
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def upgrade_compute_nodes(virt)
Rails.logger.info("Upgrading #{virt} compute nodes... ")
compute_nodes = ::Node.find("roles:nova-compute-#{virt}")
if compute_nodes.empty?
Rails.logger.info("There are no compute nodes of #{virt} type.")
- Read upRead up
- Create a ticketCreate a ticket
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 enable_compute_service
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def enable_compute_service(controller, node, only_enable = false)
hostname = node[:hostname]
controller.run_ssh_cmd(
"source /root/.openrc; " \
"openstack --insecure compute service set --enable #{hostname} nova-compute"
- Read upRead up
- Create a ticketCreate a ticket
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_compute_node
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def upgrade_compute_node(controller, node)
return if node.upgraded?
node_api = Api::Node.new node.name
node_api.save_node_state("compute", "upgrading")
hostname = node[:hostname]
- Read upRead up
- Create a ticketCreate a ticket
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_one_node
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def upgrade_one_node(name)
node = ::Node.find_node_by_name_or_alias(name)
return if node.upgraded?
node_api = Api::Node.new name
- Read upRead up
- Create a ticketCreate a ticket
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 3 locations. Consider refactoring. Open
begin
unless monasca_node.nil?
monasca_node.wait_for_script_to_finish(
"/usr/sbin/crowbar-dump-monasca-db.sh",
timeouts[:dump_monasca_db]
- Read upRead up
- Create a ticketCreate a ticket
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 40.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
begin
unless monasca_node.nil?
monasca_node.wait_for_script_to_finish(
"/usr/sbin/crowbar-monasca-cleanups.sh",
timeouts[:monasca_cleanups]
- Read upRead up
- Create a ticketCreate a ticket
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 40.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
begin
unless nova_node.nil?
nova_node.wait_for_script_to_finish(
"/usr/sbin/crowbar-delete-unknown-nova-services.sh",
timeouts[:delete_nova_services]
- Read upRead up
- Create a ticketCreate a ticket
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 40.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
rescue ::Crowbar::Error::Upgrade::NodeError => e
substep = ::Crowbar::UpgradeStatus.new.current_substep
::Crowbar::UpgradeStatus.new.save_substep(substep, :failed)
::Crowbar::UpgradeStatus.new.end_step(
false,
- Read upRead up
- Create a ticketCreate a ticket
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 32.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
rescue ::Crowbar::Error::Upgrade::LiveMigrationError => e
substep = ::Crowbar::UpgradeStatus.new.current_substep
::Crowbar::UpgradeStatus.new.save_substep(substep, :failed)
::Crowbar::UpgradeStatus.new.end_step(
false,
- Read upRead up
- Create a ticketCreate a ticket
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 32.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
"prepare-repositories",
"upgrade-os",
"shutdown-services-before-upgrade",
"delete-cinder-services-before-upgrade",
"dump-monasca-db",
- Read upRead up
- Create a ticketCreate a ticket
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 26.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76