crowbar/crowbar-openstack

View on GitHub

Showing 748 of 748 total issues

Similar blocks of code found in 3 locations. Consider refactoring.
Open

database_user "grant privileges to the #{grafana_db[:user]} database user" do
  connection db_settings[:connection]
  database_name grafana_db[:database]
  username grafana_db[:user]
  password grafana_db[:password]
Severity: Major
Found in chef/cookbooks/horizon/recipes/monasca_ui.rb and 2 other locations - About 1 hr to fix
chef/cookbooks/monasca/recipes/database.rb on lines 54..64
chef/cookbooks/nova/recipes/database.rb on lines 54..64

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 53.

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 3 locations. Consider refactoring.
Open

  database_user "grant privileges to the #{d[:user]} database user" do
    connection db_settings[:connection]
    database_name d[:database]
    username d[:user]
    password d[:password]
Severity: Major
Found in chef/cookbooks/nova/recipes/database.rb and 2 other locations - About 1 hr to fix
chef/cookbooks/horizon/recipes/monasca_ui.rb on lines 71..81
chef/cookbooks/monasca/recipes/database.rb on lines 54..64

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 53.

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 3 locations. Consider refactoring.
Open

database_user "grant privileges to the #{monasca_db[:user]} database user" do
  connection db_settings[:connection]
  database_name monasca_db[:database]
  username monasca_db[:user]
  password monasca_db[:password]
Severity: Major
Found in chef/cookbooks/monasca/recipes/database.rb and 2 other locations - About 1 hr to fix
chef/cookbooks/horizon/recipes/monasca_ui.rb on lines 71..81
chef/cookbooks/nova/recipes/database.rb on lines 54..64

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 53.

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

Function networking_plugin_check has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function networking_plugin_check() {
  switch ($('#networking_plugin').val()) {
  case 'ml2':
    $('#vmware_container').hide();
    $('#ml2_mechanism_drivers_container').show();

Method downgrade has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def downgrade(ta, td, a, d)
  a["ldap"].delete("user_description_attribute")
  a["ldap"].delete("group_members_are_ids")
  a["ldap"].delete("user_enabled_emulation_use_group_config")
  a["ldap"]["project_tree_dn"] = ta["ldap"]["project_tree_dn"]

Method swift_settings has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def swift_settings(node, glance)
      swift = CrowbarUtilsSearch.node_search_with_cache(node, "roles:swift-proxy").first || {}
      # configure swift only if direct deploy interface is enabled
      return unless swift && node[:ironic][:enabled_deploy_interfaces].include?("direct")

Severity: Minor
Found in chef/cookbooks/ironic/libraries/helpers.rb - About 1 hr to fix

Method auth_body has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def auth_body(auth)
      body = {
        auth: {
          identity: {
            methods: ["password"],
Severity: Minor
Found in chef/cookbooks/keystone/libraries/helpers.rb - About 1 hr to fix

Method set_retention_policy has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.set_retention_policy(db_name, policy_name, duration, replicas,
    shard_group_duration: nil, default: nil,
    **options)
    rps_available = InfluxDBHelper.get_retention_policies(db_name, **options)
    rp = rps_available.find { |rp| rp['name'] == policy_name }
Severity: Minor
Found in chef/cookbooks/monasca/libraries/helper.rb - About 1 hr to fix

Method create_proposal has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def create_proposal
    @logger.debug("Magnum create_proposal: entering")
    base = super

    nodes = NodeObject.all
Severity: Minor
Found in crowbar_framework/app/models/magnum_service.rb - About 1 hr to fix

Method apply_role_pre_chef_call has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def apply_role_pre_chef_call(old_role, role, all_nodes)
    @logger.debug("Keystone apply_role_pre_chef_call: entering #{all_nodes.inspect}")

    server_elements, server_nodes, ha_enabled = role_expand_elements(role, "keystone-server")

Severity: Minor
Found in crowbar_framework/app/models/keystone_service.rb - About 1 hr to fix

Method create_proposal has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def create_proposal
    @logger.debug("Cinder create_proposal: entering")
    base = super

    nodes = NodeObject.all
Severity: Minor
Found in crowbar_framework/app/models/cinder_service.rb - About 1 hr to fix

Method apply_role_pre_chef_call has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def apply_role_pre_chef_call(old_role, role, all_nodes)
    @logger.debug("octavia apply_role_pre_chef_call: entering #{all_nodes.inspect}")
    return if all_nodes.empty?

    if old_role
Severity: Minor
Found in crowbar_framework/app/models/octavia_service.rb - About 1 hr to fix

Similar blocks of code found in 2 locations. Consider refactoring.
Open

pacemaker_primitive evacuate_primitive do
  agent "ocf:openstack:NovaEvacuate"
  params ({
    "auth_url"       => keystone_settings["internal_auth_url"],
    # "region_name"    => keystone_settings["endpoint_region"],
Severity: Major
Found in chef/cookbooks/nova/recipes/compute_ha.rb and 1 other location - About 1 hr to fix
chef/cookbooks/nova/recipes/compute_ha.rb on lines 169..184

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 51.

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

pacemaker_primitive nova_primitive do
  agent "ocf:openstack:NovaCompute"
  params ({
    "auth_url"       => keystone_settings["internal_auth_url"],
    # "region_name"    => keystone_settings["endpoint_region"],
Severity: Major
Found in chef/cookbooks/nova/recipes/compute_ha.rb and 1 other location - About 1 hr to fix
chef/cookbooks/nova/recipes/compute_ha.rb on lines 229..244

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 51.

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

    if (values.indexOf($('#ml2_type_drivers_default_provider_network').val()) < 0) {
      $('#ml2_type_drivers_default_provider_network').val(values[0]).trigger('change');
    }
crowbar_framework/app/assets/javascripts/barclamps/neutron/application.js on lines 319..321

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 57.

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

    if (values.indexOf($('#ml2_type_drivers_default_provider_network').val()) < 0) {
      $('#ml2_type_drivers_default_tenant_network').val(values[0]).trigger('change');
    }
crowbar_framework/app/assets/javascripts/barclamps/neutron/application.js on lines 322..324

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 57.

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

Method action_create has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        def action_create
          begin
            unless exists?(:logins)
              if @new_resource.windows_user
                db.execute("CREATE LOGIN [#{@new_resource.username}] FROM WINDOWS").do

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 network_settings has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def network_settings(node)
      @ip ||= Chef::Recipe::Barclamp::Inventory.get_network_by_type(node, "admin").address
      @cluster_admin_ip ||= nil

      if node[:magnum][:ha][:enabled] && !@cluster_admin_ip
Severity: Minor
Found in chef/cookbooks/magnum/libraries/helpers.rb - About 1 hr 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 unset_db_synced has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def self.unset_db_synced
      # keystone is not included here because we keep it running for some longer
      # during the upgrade and don't what the chef-recipes to trigger the database
      # schema migrations.

Severity: Minor
Found in crowbar_framework/lib/openstack/upgrade.rb - About 1 hr 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 validate_proposal_after_save has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def validate_proposal_after_save(proposal)
    validate_one_for_role proposal, "monasca-server"
    nodes = proposal["deployment"][@bc_name]["elements"]
    nodes["monasca-server"].each do |node|
      n = NodeObject.find_node_by_name(node)
Severity: Minor
Found in crowbar_framework/app/models/monasca_service.rb - About 1 hr 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

Severity
Category
Status
Source
Language