Showing 91 of 91 total issues
Method get
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def self.get(resource)
cmd = "drbd-overview --color=no"
output = Chef::ShellOut.new(cmd).run_command.stdout
resource_output = ""
- 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 application.js
has 259 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
* Copyright 2011-2013, Dell
* Copyright 2013-2014, SUSE LINUX Products GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
- Create a ticketCreate a ticket
Method prepare_role_for_cluster_vip_networks
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def prepare_role_for_cluster_vip_networks(role, elements, networks)
dirty = false
elements.each do |element|
next unless PacemakerServiceObject.is_cluster?(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 apply_cluster_roles_to_new_nodes_for
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def apply_cluster_roles_to_new_nodes_for(cluster_element, relevant_nodes, all_roles)
return [] if relevant_nodes.empty?
### Beware of possible confusion between different level of "roles"!
# See comment in apply_cluster_roles_to_new_nodes
- Create a ticketCreate a ticket
Method wait_for_mark_from_founder
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.wait_for_mark_from_founder(node, mark, fatal = false, timeout = 60)
return unless CrowbarPacemakerHelper.cluster_enabled?(node)
return if CrowbarPacemakerHelper.is_cluster_founder?(node)
if CrowbarPacemakerHelper.being_upgraded?(node)
Chef::Log.debug("Node is being upgraded." \
- Create a ticketCreate a ticket
Method action_create
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def action_create
name = new_resource.name
physical_volume_list = [new_resource.physical_volumes].flatten
# Make sure any pvs are not being used as filesystems (e.g. ephemeral0 on
- Create a ticketCreate a ticket
Similar blocks of code found in 2 locations. Consider refactoring. Open
StonithNodeAgents.prototype.writeJson = function(key, value, type) {
return $(this.options.storage).writeJsonAttribute(
'{0}/{1}'.format(
this.options.path,
key
- 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 65.
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
StonithNodeAgents.prototype.removeJson = function(key, value, type) {
return $(this.options.storage).removeJsonAttribute(
'{0}/{1}'.format(
this.options.path,
key
- 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 65.
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
Method maybe_modify_resource
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def maybe_modify_resource(name)
deprecate_target_role
Chef::Log.info "Checking existing #{@current_cib_object} for modifications"
- Create a ticketCreate a ticket
Method wait_for_mark_from_founder
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def self.wait_for_mark_from_founder(node, mark, fatal = false, timeout = 60)
return unless CrowbarPacemakerHelper.cluster_enabled?(node)
return if CrowbarPacemakerHelper.is_cluster_founder?(node)
if CrowbarPacemakerHelper.being_upgraded?(node)
Chef::Log.debug("Node is being upgraded." \
- 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 prepare_stonith_attributes
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def prepare_stonith_attributes(role_attributes, remote_nodes, member_nodes, remotes, members)
cluster_nodes = member_nodes + remote_nodes
stonith_attributes = role_attributes["stonith"]
# still make the original mode 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 crm_configure_show
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def crm_configure_show(name)
cmd = Mixlib::ShellOut.new("crm --display=plain configure show #{name}")
cmd.environment["HOME"] = ENV.fetch("HOME", "/root")
cmd.run_command
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 maybe_configure_params
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def maybe_configure_params(name, cmds, data_type)
configure_cmd_prefix = "crm_resource --resource #{name}"
new_resource.send(data_type).each do |param, new_value|
current_value = @current_resource.send(data_type)[param]
- 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
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.get(resource)
cmd = "drbd-overview --color=no"
output = Chef::ShellOut.new(cmd).run_command.stdout
resource_output = ""
- Create a ticketCreate a ticket
Method health_report
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def health_report
ret = {}
crm_failures = {}
failed_actions = {}
unready_nodes = {}
- Create a ticketCreate a ticket
Method allocate_virtual_ips_for_cluster_in_networks
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def allocate_virtual_ips_for_cluster_in_networks(cluster, networks)
if networks.nil? || networks.empty? || !PacemakerServiceObject.is_cluster?(cluster)
[false, false]
else
nodes = PacemakerServiceObject.expand_nodes(cluster)
- 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_mcast_addr
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def validate_mcast_addr(used_addrs, ring_index, curr_addr)
# compare current address to used addresses
curr_addr_used = (curr_addr != "") && (used_addrs.key? curr_addr)
# if address is used or empty, find an available address
- 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 action_create
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def action_create
name = new_resource.name
physical_volume_list = [new_resource.physical_volumes].flatten
# Make sure any pvs are not being used as filesystems (e.g. ephemeral0 on
- 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
Function update_no_quorum_policy
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function update_no_quorum_policy(evt, init) {
var no_quorum_policy_el = $('#crm_no_quorum_policy');
var non_forced_policy = no_quorum_policy_el.data('non-forced');
var was_forced_policy = no_quorum_policy_el.data('is-forced');
var members = $('#pacemaker-cluster-member').children().length;
- 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_mcast_addr
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def validate_mcast_addr(used_addrs, ring_index, curr_addr)
# compare current address to used addresses
curr_addr_used = (curr_addr != "") && (used_addrs.key? curr_addr)
# if address is used or empty, find an available address
- Create a ticketCreate a ticket