Method apply_role
has a Cognitive Complexity of 178 (exceeds 5 allowed). Consider refactoring. Open
def apply_role(role, inst, in_queue, bootstrap = false)
Rails.logger.debug "apply_role(#{role.name}, #{inst}, #{in_queue}, #{bootstrap})"
Rails.logger.progress("Starting to apply role #{role.name}")
# Variables used in the global ensure
- 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
File service_object.rb
has 1352 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "pp"
require "chef"
require "json"
require "hash_only_merge"
require "securerandom"
- Create a ticketCreate a ticket
Class ServiceObject
has 98 methods (exceeds 20 allowed). Consider refactoring. Open
class ServiceObject
include CrowbarPacemakerProxy
FORBIDDEN_PROPOSAL_NAMES=["template","nodes","commit","status"]
- Create a ticketCreate a ticket
Method apply_role
has 289 lines of code (exceeds 25 allowed). Consider refactoring. Open
def apply_role(role, inst, in_queue, bootstrap = false)
Rails.logger.debug "apply_role(#{role.name}, #{inst}, #{in_queue}, #{bootstrap})"
Rails.logger.progress("Starting to apply role #{role.name}")
# Variables used in the global ensure
- Create a ticketCreate a ticket
Method reset_proposal
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def reset_proposal(inst, bc = @bc_name)
::Proposal.find_by(
barclamp: bc,
name: inst
).tap do |proposal|
- 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 validate_proposal_constraints
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def validate_proposal_constraints(proposal)
elements = proposal["deployment"][@bc_name]["elements"]
nodes_is_admin = {}
role_constraints.keys.each do |role|
- 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 relevant_attributes_changed_if_roles?
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def relevant_attributes_changed_if_roles?(node, old_role, new_role, ignore_attr, only_for_roles)
# if only_for_roles has some sole
unless only_for_roles.nil? || only_for_roles.empty?
# get roles for this node
roles_in_new = new_role.elements.keys.select { |r| new_role.elements[r].include?(node) }
- 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 validate_proposal_elements
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def validate_proposal_elements proposal_elements
proposal_elements.each do |role_and_elements|
role, elements = role_and_elements
uniq_elements = elements.uniq
- 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 skip_unready_nodes
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def skip_unready_nodes(bc, inst, new_elements, old_elements)
logger.debug("skip_unready_nodes: enter for #{bc}:#{inst}")
skip_unready_nodes_roles = Rails.application.config.crowbar.fetch(
"skip_unready_nodes", {}
).fetch("roles", [])
- 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 violates_admin_constraint?
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def violates_admin_constraint?(elements, role, nodes_is_admin = {})
if role_constraints[role] && !role_constraints[role]["admin"]
elements[role].each do |element|
next if is_cluster?(element) || is_remotes?(element)
unless nodes_is_admin.key? 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 validate_postponed_nodes
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def validate_postponed_nodes(proposal)
return unless upgrade_postponed?
skip_unready_nodes_enabled = Rails.application.config.crowbar.fetch(
"skip_unready_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 lock_nodes
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def lock_nodes(nodes, lock_owner, lock_reason)
locks = []
errors = {}
return [locks, errors] if 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 reset_proposal
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def reset_proposal(inst, bc = @bc_name)
::Proposal.find_by(
barclamp: bc,
name: inst
).tap do |proposal|
- Create a ticketCreate a ticket
Method wait_for_reboot
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def wait_for_reboot(node)
nobj = Node.find_by_name(node)
if nobj[:crowbar_wall][:wait_for_reboot]
puts "Waiting for reboot of node #{node}"
if RemoteNode.ready?(node, 1200)
- 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 add_role_to_instance_and_node
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_role_to_instance_and_node(barclamp, instance, name, prop, role, newrole)
node = Node.find_by_name(name)
if node.nil?
Rails.logger.debug("ARTOI: couldn't find node #{name}. bailing")
return false
- Create a ticketCreate a ticket
Method lock_nodes
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def lock_nodes(nodes, lock_owner, lock_reason)
locks = []
errors = {}
return [locks, errors] if nodes.empty?
- Create a ticketCreate a ticket
Method validate_proposal_constraints
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def validate_proposal_constraints(proposal)
elements = proposal["deployment"][@bc_name]["elements"]
nodes_is_admin = {}
role_constraints.keys.each do |role|
- Create a ticketCreate a ticket
Method proposal_commit
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def proposal_commit(inst, options = {})
options.reverse_merge!(
in_queue: false,
validate: true,
validate_after_save: true,
- Create a ticketCreate a ticket
Method wait_for_reboot
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def wait_for_reboot(node)
nobj = Node.find_by_name(node)
if nobj[:crowbar_wall][:wait_for_reboot]
puts "Waiting for reboot of node #{node}"
if RemoteNode.ready?(node, 1200)
- Create a ticketCreate a ticket
Method add_role_to_instance_and_node
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def add_role_to_instance_and_node(barclamp, instance, name, prop, role, newrole)
node = Node.find_by_name(name)
if node.nil?
Rails.logger.debug("ARTOI: couldn't find node #{name}. bailing")
return false
- 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 violates_uniqueness_constraint?
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def violates_uniqueness_constraint?(elements, role)
if role_constraints[role] && role_constraints[role]["unique"]
elements[role].each do |element|
elements.keys.each do |loop_role|
next if loop_role == role
- 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 violates_platform_constraint?
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def violates_platform_constraint?(elements, role)
if role_constraints[role] && role_constraints[role].key?("platform")
constraints = role_constraints[role]["platform"]
elements[role].each do |element|
next if is_cluster?(element) || is_remotes?(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 violates_exclude_platform_constraint?
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def violates_exclude_platform_constraint?(elements, role)
if role_constraints[role] && role_constraints[role].key?("exclude_platform")
constraints = role_constraints[role]["exclude_platform"]
elements[role].each do |element|
next if is_cluster?(element) || is_remotes?(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 wait_for_chef_daemons
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def wait_for_chef_daemons(node_list)
return if node_list.empty?
queue = Queue.new
- 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 find_dep_proposal
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def find_dep_proposal(bc, optional=false)
begin
const_service = self.class.get_service(bc)
rescue
Rails.logger.info "Barclamp \"#{bc}\" is not available."
- 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 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)
- Create a ticketCreate a ticket
Method queue_proposal
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def queue_proposal(inst, element_order, elements, deps, bc = @bc_name, pre_cached_nodes = {})
- Create a ticketCreate a ticket
Method relevant_attributes_changed_if_roles?
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def relevant_attributes_changed_if_roles?(node, old_role, new_role, ignore_attr, only_for_roles)
- Create a ticketCreate a ticket
Method select_nodes_for_role
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def select_nodes_for_role(all_nodes, role, preferred_intended_role = nil)
# do not modify array given by caller
valid_nodes = all_nodes.dup
valid_nodes.delete_if { |n| n.nil? }
- 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 restore_to_ready
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def restore_to_ready(nodes)
with_lock "BA-LOCK" do
nodes_to_save = []
nodes.each do |node_name|
node = Node.find_by_name(node_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 proposal_create
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def proposal_create(params)
base_id = params["id"]
params["id"] = "#{@bc_name}-#{params["id"]}"
if FORBIDDEN_PROPOSAL_NAMES.any?{ |n| n == base_id }
return [403,I18n.t("model.service.illegal_name", names: FORBIDDEN_PROPOSAL_NAMES.to_sentence)]
- 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 set_to_applying
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def set_to_applying(nodes, inst, pre_cached_nodes)
with_lock "BA-LOCK" do
nodes_to_save = []
nodes.each do |node_name|
node = pre_cached_nodes[node_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
Avoid too many return
statements within this method. Open
return [405, message]
- Create a ticketCreate a ticket
Avoid too many return
statements within this method. Open
return [405, message]
- Create a ticketCreate a ticket
Avoid too many return
statements within this method. Open
return [405, message]
- Create a ticketCreate a ticket
Method release_chef_locks
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def release_chef_locks(locks)
return if locks.empty?
queue = Queue.new
locks.each { |l| queue.push l }
- 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 save_nodes
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def save_nodes(nodes)
return if nodes.empty?
queue = Queue.new
nodes.each { |n| queue.push 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 run_remote_chef_client
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def run_remote_chef_client(node, command, logfile_name)
Thread.new do
# Exec command
# the -- tells sudo to stop interpreting options
- 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 get_log_lines
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_log_lines(node)
begin
line_count = 0
last_delimiter_line = 0
f = File.open("/var/log/crowbar/chef-client/#{node}.log")
- 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 2 locations. Consider refactoring. Open
begin
apply_role_pre_chef_call(old_role, role, all_nodes)
rescue StandardError => e
Rails.logger.fatal("apply_role: Exception #{e.message} #{e.backtrace.join("\n")}")
Rails.logger.progress("Failed to apply role #{role.name} before calling chef")
- 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 45.
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
begin
apply_role_post_chef_call(old_role, role, all_nodes)
rescue StandardError => e
Rails.logger.fatal("apply_role: Exception #{e.message} #{e.backtrace.join("\n")}")
Rails.logger.progress("Failed to apply role #{role.name} after calling chef")
- 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 45.
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
def violates_remotes_constraint?(elements, role)
if role_constraints[role] && !role_constraints[role]["remotes"]
remotes = elements[role].select { |e| is_remotes? e }
unless remotes.empty?
return true
- 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 29.
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
def violates_cluster_constraint?(elements, role)
if role_constraints[role] && !role_constraints[role]["cluster"]
clusters = elements[role].select { |e| is_cluster? e }
unless clusters.empty?
return true
- 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 29.
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
if violates_platform_constraint?(elements, role)
platforms = role_constraints[role]["platform"].map { |k, v| [k, v].join(" ") }.join(", ")
validation_error("Role #{role} can be used only for #{platforms} platform(s).")
- 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 29.
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
if violates_exclude_platform_constraint?(elements, role)
platforms = role_constraints[role]["exclude_platform"].map { |k, v| [k, v].join(" ") }.join(", ")
validation_error("Role #{role} can't be used for #{platforms} platform(s).")
- 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 29.
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