crowbar/crowbar-core

View on GitHub
crowbar_framework/spec/models/api/crowbar_spec.rb

Summary

Maintainability
F
3 days
Test Coverage

File crowbar_spec.rb has 474 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "spec_helper"

describe Api::Crowbar do
  let(:pid) { rand(20000..30000) }
  let(:admin_node) { NodeObject.find_node_by_name("admin") }
Severity: Minor
Found in crowbar_framework/spec/models/api/crowbar_spec.rb - About 7 hrs to fix

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

    it "succeeds when there are three clusters and they are db+apis+network" do
      allow(Api::Crowbar).to(receive(:addon_installed?).and_return(true))
      allow(NodeObject).to(receive(:find).with(
        "pacemaker_founder:true AND pacemaker_config_environment:*"
      ).and_return([node]))
Severity: Major
Found in crowbar_framework/spec/models/api/crowbar_spec.rb and 2 other locations - About 2 hrs to fix
crowbar_framework/spec/models/api/crowbar_spec.rb on lines 228..252
crowbar_framework/spec/models/api/crowbar_spec.rb on lines 255..279

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

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

    it "fails when there are four clusters" do
      allow(Api::Crowbar).to(receive(:addon_installed?).and_return(true))
      allow(NodeObject).to(receive(:find).with(
        "pacemaker_founder:true AND pacemaker_config_environment:*"
      ).and_return([node]))
Severity: Major
Found in crowbar_framework/spec/models/api/crowbar_spec.rb and 2 other locations - About 2 hrs to fix
crowbar_framework/spec/models/api/crowbar_spec.rb on lines 336..360
crowbar_framework/spec/models/api/crowbar_spec.rb on lines 363..387

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

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

    it "succeeds when there are two clusters and one is dedicated to neutron" do
      allow(Api::Crowbar).to(receive(:addon_installed?).and_return(true))
      allow(NodeObject).to(receive(:find).with(
        "pacemaker_founder:true AND pacemaker_config_environment:*"
      ).and_return([node]))
Severity: Major
Found in crowbar_framework/spec/models/api/crowbar_spec.rb and 2 other locations - About 2 hrs to fix
crowbar_framework/spec/models/api/crowbar_spec.rb on lines 255..279
crowbar_framework/spec/models/api/crowbar_spec.rb on lines 282..306

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

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

    it "succeeds when there are two clusters and one is dedicated to db" do
      allow(Api::Crowbar).to(receive(:addon_installed?).and_return(true))
      allow(NodeObject).to(receive(:find).with(
        "pacemaker_founder:true AND pacemaker_config_environment:*"
      ).and_return([node]))
Severity: Major
Found in crowbar_framework/spec/models/api/crowbar_spec.rb and 2 other locations - About 2 hrs to fix
crowbar_framework/spec/models/api/crowbar_spec.rb on lines 228..252
crowbar_framework/spec/models/api/crowbar_spec.rb on lines 282..306

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

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

    it "fails when there are two clusters and roles assignment does not match supported patterns" do
      allow(Api::Crowbar).to(receive(:addon_installed?).and_return(true))
      allow(NodeObject).to(receive(:find).with(
        "pacemaker_founder:true AND pacemaker_config_environment:*"
      ).and_return([node]))
Severity: Major
Found in crowbar_framework/spec/models/api/crowbar_spec.rb and 2 other locations - About 2 hrs to fix
crowbar_framework/spec/models/api/crowbar_spec.rb on lines 309..333
crowbar_framework/spec/models/api/crowbar_spec.rb on lines 336..360

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

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

    it "fails when there are three clusters and db/api/network roles are mixed" do
      allow(Api::Crowbar).to(receive(:addon_installed?).and_return(true))
      allow(NodeObject).to(receive(:find).with(
        "pacemaker_founder:true AND pacemaker_config_environment:*"
      ).and_return([node]))
Severity: Major
Found in crowbar_framework/spec/models/api/crowbar_spec.rb and 2 other locations - About 2 hrs to fix
crowbar_framework/spec/models/api/crowbar_spec.rb on lines 309..333
crowbar_framework/spec/models/api/crowbar_spec.rb on lines 363..387

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

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

    it "passes with nice compute nodes" do
      allow(NodeObject).to(receive(:find).with("roles:database-server").and_return([node]))
      allow(NodeObject).to(receive(:find).with("roles:nova-compute-*").and_return([node]))
      allow_any_instance_of(NodeObject).to(
        receive(:roles).and_return(
Severity: Minor
Found in crowbar_framework/spec/models/api/crowbar_spec.rb and 1 other location - About 1 hr to fix
crowbar_framework/spec/models/api/crowbar_spec.rb on lines 418..428

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

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

    it "passes with compute node together with nova-controller " do
      allow(NodeObject).to(receive(:find).with("roles:database-server").and_return([node]))
      allow(NodeObject).to(receive(:find).with("roles:nova-compute-*").and_return([node]))
      allow_any_instance_of(NodeObject).to(
        receive(:roles).and_return(
Severity: Minor
Found in crowbar_framework/spec/models/api/crowbar_spec.rb and 1 other location - About 1 hr to fix
crowbar_framework/spec/models/api/crowbar_spec.rb on lines 392..402

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

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

There are no issues that match your filters.

Category
Status