crowbar/crowbar-openstack

View on GitHub

Showing 748 of 748 total issues

Method run_test has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def run_test(node)
    raise "unable to look up a #{@bc_name} proposal at node #{node.inspect}" if (proposal = _get_proposal_by_node node).nil?

    test_run_uuid = `uuidgen`.strip
    test_run = {
Severity: Minor
Found in crowbar_framework/app/models/tempest_service.rb - About 1 hr to fix

Method validate_proposal_after_save has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def validate_proposal_after_save(proposal)
    validate_one_for_role proposal, "ironic-server"

    net_svc = NetworkService.new @logger
    network_proposal = Proposal.find_by(barclamp: net_svc.bc_name, name: "default")
Severity: Minor
Found in crowbar_framework/app/models/ironic_service.rb - About 1 hr to fix

Method set_retention_policy has a Cognitive Complexity of 11 (exceeds 5 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

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

  def validate_vxlan(vxlan_settings)
    if vxlan_settings["vni_start"] < 0 || vxlan_settings["vni_start"] > 16777215
      validation_error I18n.t("barclamp.#{@bc_name}.validation.vxlan_vni_start")
    end
    if vxlan_settings["vni_end"]  < 0 || vxlan_settings["vni_end"] > 16777215
Severity: Minor
Found in crowbar_framework/app/models/neutron_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

Method switch_to_zone has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def switch_to_zone()
        #set switch to zone by round-robin
        zone_count=@node[:swift][:zones]
        zone_list=zone_count.times.to_a
        switch_list=@switch_list
Severity: Minor
Found in chef/cookbooks/swift/libraries/rack_awareness.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 clear_dispersion_reports has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def clear_dispersion_reports
    def delete_file(file_name)
      File.delete(file_name) if File.exist?(file_name)
    end

Severity: Minor
Found in crowbar_framework/app/models/swift_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

Method test_runs has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def test_runs
    # POST /tempest/test_runs/clear
    if (request.post? or request.put?) and params[:id] == "clear"
      @service_object.clear_test_runs
      flash[:notice] = t "barclamp.#{@bc_name}.dashboard.clear.success"
Severity: Minor
Found in crowbar_framework/app/controllers/tempest_controller.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 clear_test_runs has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def clear_test_runs
    def delete_file(file_name)
      File.delete(file_name) if File.exist?(file_name)
    end

Severity: Minor
Found in crowbar_framework/app/models/tempest_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

Method validate_proposal_after_save has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def validate_proposal_after_save(proposal)
    validate_one_for_role proposal, "database-server"

    attributes = proposal["attributes"][@bc_name]
    deployment = proposal["deployment"][@bc_name]
Severity: Minor
Found in crowbar_framework/app/models/database_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

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

def upgrade(ta, td, a, d)
  unless a["volume_defaults"]["netapp"].key? "max_over_subscription_ratio"
    a["volume_defaults"]["netapp"]["max_over_subscription_ratio"] = \
      ta["volume_defaults"]["netapp"]["max_over_subscription_ratio"]

chef/data_bags/crowbar/migrate/cinder/206_add_nfs_snapshot.rb on lines 1..11

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

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

def upgrade ta, td, a, d
  %w{ tree_dn filter objectclass domain_id_attribute id_attribute member_attribute name_attribute desc_attribute enabled_attribute attribute_ignore allow_create allow_update allow_delete enabled_emulation enabled_emulation_dn }.each do |attr|
    a["ldap"]["project_#{attr}"] = a["ldap"]["tenant_#{attr}"] || ta["ldap"]["project_#{attr}"]
    a["ldap"].delete "tenant_#{attr}"
  end
chef/data_bags/crowbar/migrate/keystone/021_ldap_tenants_to_projects.rb on lines 10..16

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

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

def downgrade ta, td, a, d
  %w{ tree_dn filter objectclass domain_id_attribute id_attribute member_attribute name_attribute desc_attribute enabled_attribute attribute_ignore allow_create allow_update allow_delete enabled_emulation enabled_emulation_dn }.each do |attr|
    a["ldap"]["tenant_#{attr}"] = a["ldap"]["project_#{attr}"] || ta["ldap"]["tenant_#{attr}"]
    a["ldap"].delete "project_#{attr}"
  end
chef/data_bags/crowbar/migrate/keystone/021_ldap_tenants_to_projects.rb on lines 1..7

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

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

def upgrade(ta, td, a, d)
  unless a["volume_defaults"]["nfs"].key? "nfs_snapshot"
    a["volume_defaults"]["nfs"]["nfs_snapshot"] = ta["volume_defaults"]["nfs"]["nfs_snapshot"]

    a["volumes"].each do |volume|
chef/data_bags/crowbar/migrate/cinder/106_add_max_over_subscription_ratio.rb on lines 1..13

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

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 load_current_resource has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def load_current_resource
  @current_resource = Chef::Resource::CrowbarOpenstackWsgi.new(@new_resource.name)

  @current_resource.bind_host(@new_resource.bind_host)
  @current_resource.bind_port(@new_resource.bind_port)
Severity: Minor
Found in chef/cookbooks/crowbar-openstack/providers/wsgi.rb - About 1 hr to fix

Method role_constraints has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def role_constraints
      {
        "neutron-server" => {
          "unique" => false,
          "count" => 1,
Severity: Minor
Found in crowbar_framework/app/models/neutron_service.rb - About 1 hr to fix

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

def upgrade(template_attrs, template_deployment, attrs, deployment)
  attrs["mysql"]["wsrep_provider_options_custom"] = template_attrs["mysql"]["wsrep_provider_options_custom"] unless attrs["mysql"]["wsrep_provider_options_custom"]
  attrs["mysql"]["gcs_fc_limit_multiplier"] = template_attrs["mysql"]["gcs_fc_limit_multiplier"] unless attrs["mysql"]["gcs_fc_limit_multiplier"]
  attrs["mysql"]["gcs_fc_factor"] = template_attrs["mysql"]["gcs_fc_factor"] unless attrs["mysql"]["gcs_fc_factor"]
  return attrs, deployment
chef/data_bags/crowbar/migrate/database/207_add_more_tuning.rb on lines 1..11

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

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

def upgrade(ta, td, a, d)
  unless a["mysql"]["innodb_flush_log_at_trx_commit"]
    a["mysql"]["innodb_flush_log_at_trx_commit"] = ta["mysql"]["innodb_flush_log_at_trx_commit"]
  end
  unless a["mysql"]["innodb_buffer_pool_instances"]
chef/data_bags/crowbar/migrate/database/301_make_wsrep_provider_options_configurable.rb on lines 1..5

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

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 upgrade has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def upgrade(ta, td, a, d)
  a["ldap"]["user_description_attribute"] = ta["ldap"]["user_description_attribute"]
  a["ldap"]["group_members_are_ids"] = ta["ldap"]["group_members_are_ids"]
  a["ldap"]["user_enabled_emulation_use_group_config"] =
    ta["ldap"]["user_enabled_emulation_use_group_config"]

Method action_alter_sys_roles has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def action_alter_sys_roles
          begin
            if @new_resource.password || (@new_resource.windows_user && !exists?(:logins))
              action_create
            end

Method role_constraints has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def role_constraints
      {
        "monasca-agent" => {
          "unique" => false,
          "admin" => false,
Severity: Minor
Found in crowbar_framework/app/models/monasca_service.rb - About 1 hr to fix
Severity
Category
Status
Source
Language