crowbar/crowbar-openstack

View on GitHub

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) {
crowbar_framework/app/assets/javascripts/barclamps/manila/application.js on lines 17..113

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

Further Reading

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) {
crowbar_framework/app/assets/javascripts/barclamps/cinder/application.js on lines 19..116

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

Further Reading

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])
Severity: Major
Found in chef/cookbooks/keystone/recipes/server.rb - About 1 day to fix

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)
Severity: Minor
Found in crowbar_framework/app/models/nova_service.rb - About 1 day to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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")

Severity: Major
Found in chef/cookbooks/tempest/recipes/config.rb - About 1 day to fix

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
Severity: Minor
Found in chef/cookbooks/crowbar-openstack/libraries/helpers.rb - About 1 day to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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"

Severity: Major
Found in chef/cookbooks/horizon/recipes/server.rb - About 1 day to fix

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|

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"
Severity: Minor
Found in chef/cookbooks/postgresql/attributes/default.rb - About 7 hrs to fix

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 = {}
Severity: Minor
Found in crowbar_framework/app/models/cinder_service.rb - About 7 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method 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"
Severity: Minor
Found in crowbar_framework/app/models/neutron_service.rb - About 6 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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
Severity: Minor
Found in crowbar_framework/app/models/nova_service.rb - About 6 hrs to fix

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)
Severity: Minor
Found in crowbar_framework/app/models/neutron_service.rb - About 6 hrs to fix

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,
Severity: Minor
Found in bin/tempest_results_processor.rb - About 6 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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
Severity: Minor
Found in chef/cookbooks/keystone/providers/register.rb - About 6 hrs to fix

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"] = []
Severity: Minor
Found in crowbar_framework/app/models/nova_service.rb - About 5 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method 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.
    #
Severity: Minor
Found in chef/cookbooks/postgresql/libraries/default.rb - About 4 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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"
Severity: Minor
Found in chef/cookbooks/heat/recipes/server.rb - About 4 hrs to fix

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 = {}
Severity: Major
Found in crowbar_framework/app/models/cinder_service.rb - About 4 hrs to fix

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
Severity: Minor
Found in chef/cookbooks/nova/recipes/compute.rb - About 4 hrs to fix
Severity
Category
Status
Source
Language