Showing 748 of 748 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
$(document).ready(function($) {
var cinder_backend_template;
Handlebars.registerHelper('if_eq', function(a, b, opts) {
- 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 729.
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
$(document).ready(function($) {
var manila_backend_template;
Handlebars.registerHelper('if_eq', function(a, b, opts) {
- 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 729.
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
File server.rb
has 553 lines of code (exceeds 250 allowed). Consider refactoring. Open
package "keystone" do
package_name "openstack-keystone" if %w(rhel suse).include?(node[:platform_family])
end
if %w(rhel).include?(node[:platform_family])
- Create a ticketCreate a ticket
Method validate_proposal_after_save
has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring. Open
def validate_proposal_after_save(proposal)
validate_one_for_role proposal, "nova-controller"
elements = proposal["deployment"]["nova"]["elements"]
nodes = Hash.new(0)
- 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 config.rb
has 551 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "open3"
nova = get_instance("roles:nova-controller")
keystone_settings = KeystoneHelper.keystone_settings(nova, "nova")
- Create a ticketCreate a ticket
Method rabbitmq_settings
has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring. Open
def self.rabbitmq_settings(node, barclamp)
instance = node[barclamp][:rabbitmq_instance] || "default"
# Cache the result for each cookbook in an instance variable hash. This
# cache needs to be invalidated for each chef-client run from chef-client
- 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 server.rb
has 506 lines of code (exceeds 250 allowed). Consider refactoring. Open
include_recipe "apache2"
include_recipe "apache2::mod_headers"
include_recipe "apache2::mod_wsgi"
include_recipe "apache2::mod_rewrite"
- Create a ticketCreate a ticket
Method upgrade
has 195 lines of code (exceeds 25 allowed). Consider refactoring. Open
def upgrade(ta, td, a, d)
fields = ["type", "boot", "console", "deploy", "inspect", "management", "power", "raid"]
# init empty attributes with defaults
fields.each do |field|
- Create a ticketCreate a ticket
File default.rb
has 478 lines of code (exceeds 250 allowed). Consider refactoring. Open
default["postgresql"]["enable_pgdg_apt"] = false
default["postgresql"]["server"]["config_change_notify"] = :restart
case node[:platform]
when "debian"
- Create a ticketCreate a ticket
Method validate_proposal_after_save
has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring. Open
def validate_proposal_after_save(proposal)
validate_one_for_role proposal, "cinder-controller"
validate_at_least_n_for_role proposal, "cinder-volume", 1
volume_names = {}
- 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 update_ovs_bridge_attributes
has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring. Open
def update_ovs_bridge_attributes(attributes, node)
needs_save = false
ovs_bridge_networks = []
ml2_mechanism_drivers = []
if attributes["networking_plugin"] == "ml2"
- 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 nova_service.rb
has 441 lines of code (exceeds 250 allowed). Consider refactoring. Open
class NovaService < OpenstackServiceObject
def initialize(thelogger = nil)
super(thelogger)
@bc_name = "nova"
end
- Create a ticketCreate a ticket
File neutron_service.rb
has 436 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "ipaddr"
class NeutronService < OpenstackServiceObject
def initialize(thelogger = nil)
super(thelogger)
- Create a ticketCreate a ticket
Method run
has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring. Open
def run(args, options={"ForceArray" => false})
p = Axlsx::Package.new
styles = p.workbook.styles
delta_style = styles.add_style bg_color: DELTA_BG,
- 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 register.rb
has 427 lines of code (exceeds 250 allowed). Consider refactoring. Open
action :wakeup do
count = 0
error = true
loop do
count = count + 1
- Create a ticketCreate a ticket
Method apply_role_pre_chef_call
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
def apply_role_pre_chef_call(old_role, role, all_nodes)
@logger.debug("Nova apply_role_pre_chef_call: entering #{all_nodes.inspect}")
unless hyperv_available?
role.override_attributes["nova"]["elements"]["nova-compute-hyperv"] = []
- 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 scan_available_timezones
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
def scan_available_timezones(tzdir)
# There should be an /etc/localtime zoneinfo file that is a link to
# (or a copy of) a timezone data file under tzdir, which should have
# been installed under the "share" directory by the tzdata package.
#
- 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 server.rb
has 370 lines of code (exceeds 250 allowed). Consider refactoring. Open
ha_enabled = node[:heat][:ha][:enabled]
db_settings = fetch_database_settings
include_recipe "database::client"
- Create a ticketCreate a ticket
Method validate_proposal_after_save
has 121 lines of code (exceeds 25 allowed). Consider refactoring. Open
def validate_proposal_after_save(proposal)
validate_one_for_role proposal, "cinder-controller"
validate_at_least_n_for_role proposal, "cinder-volume", 1
volume_names = {}
- Create a ticketCreate a ticket
File compute.rb
has 355 lines of code (exceeds 250 allowed). Consider refactoring. Open
include_recipe "nova::neutron"
include_recipe "nova::config"
if %w(rhel suse).include?(node[:platform_family])
# Start open-iscsi daemon, since nova-compute is going to use it and stumble over the
- Create a ticketCreate a ticket