ClusterLabs/hawk

View on GitHub
hawk/spec/models/colocation_spec.rb

Summary

Maintainability
A
1 hr
Test Coverage

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

    it 'provide everything' do
      record = Colocation.new
      record.id = "foo"
      record.score = "infinity"
      record.resources = [{"resources"=>["test01"], "sequential"=>"true", "action"=>"Started"},
Severity: Minor
Found in hawk/spec/models/colocation_spec.rb and 1 other location - About 45 mins to fix
hawk/spec/models/order_spec.rb on lines 60..66

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

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

    it 'with blank score' do
      record = Colocation.new
      record.score = ""
      record.valid? #run validation
      record.errors[:score].should include("Score is required")
Severity: Minor
Found in hawk/spec/models/colocation_spec.rb and 5 other locations - About 15 mins to fix
hawk/spec/models/colocation_spec.rb on lines 12..17
hawk/spec/models/colocation_spec.rb on lines 56..61
hawk/spec/models/order_spec.rb on lines 5..10
hawk/spec/models/order_spec.rb on lines 12..17
hawk/spec/models/order_spec.rb on lines 53..58

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

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

    it 'with ID' do
      record = Colocation.new
      record.id = "foo"
      record.valid?
      record.errors[:id].should_not include("ID is required")
Severity: Minor
Found in hawk/spec/models/colocation_spec.rb and 5 other locations - About 15 mins to fix
hawk/spec/models/colocation_spec.rb on lines 5..10
hawk/spec/models/colocation_spec.rb on lines 12..17
hawk/spec/models/order_spec.rb on lines 5..10
hawk/spec/models/order_spec.rb on lines 12..17
hawk/spec/models/order_spec.rb on lines 53..58

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

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

    it 'with invalid score' do
      record = Colocation.new
      record.score = "lol"
      record.valid?
      record.errors[:score].should include("Invalid score value")
Severity: Minor
Found in hawk/spec/models/colocation_spec.rb and 5 other locations - About 15 mins to fix
hawk/spec/models/colocation_spec.rb on lines 5..10
hawk/spec/models/colocation_spec.rb on lines 56..61
hawk/spec/models/order_spec.rb on lines 5..10
hawk/spec/models/order_spec.rb on lines 12..17
hawk/spec/models/order_spec.rb on lines 53..58

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

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

Surrounding space missing for operator =>.
Open

      record.resources = [{"resources"=>["test01"], "sequential"=>"true", "action"=>"Started"},
Severity: Minor
Found in hawk/spec/models/colocation_spec.rb by rubocop

Checks that operators have space around them, except for ** which should not have surrounding space.

Example:

# bad
total = 3*4
"apple"+"juice"
my_number = 38/4
a ** b

# good
total = 3 * 4
"apple" + "juice"
my_number = 38 / 4
a**b

Surrounding space missing for operator =>.
Open

      record.resources = [{"resources"=>["test01"], "sequential"=>"true", "action"=>"Started"},
Severity: Minor
Found in hawk/spec/models/colocation_spec.rb by rubocop

Checks that operators have space around them, except for ** which should not have surrounding space.

Example:

# bad
total = 3*4
"apple"+"juice"
my_number = 38/4
a ** b

# good
total = 3 * 4
"apple" + "juice"
my_number = 38 / 4
a**b

Surrounding space missing for operator =>.
Open

      record.resources = [{"resources"=>["test01"], "sequential"=>"true", "action"=>"Started"},
Severity: Minor
Found in hawk/spec/models/colocation_spec.rb by rubocop

Checks that operators have space around them, except for ** which should not have surrounding space.

Example:

# bad
total = 3*4
"apple"+"juice"
my_number = 38/4
a ** b

# good
total = 3 * 4
"apple" + "juice"
my_number = 38 / 4
a**b

Space inside { missing.
Open

      record.resources = [{"resources"=>["test01"], "sequential"=>"true", "action"=>"Started"},
Severity: Minor
Found in hawk/spec/models/colocation_spec.rb by rubocop

Checks that braces used for hash literals have or don't have surrounding space depending on configuration.

Example: EnforcedStyle: space

# The `space` style enforces that hash literals have
# surrounding space.

# bad
h = {a: 1, b: 2}

# good
h = { a: 1, b: 2 }

Example: EnforcedStyle: no_space

# The `no_space` style enforces that hash literals have
# no surrounding space.

# bad
h = { a: 1, b: 2 }

# good
h = {a: 1, b: 2}

Example: EnforcedStyle: compact

# The `compact` style normally requires a space inside
# hash braces, with the exception that successive left
# braces or right braces are collapsed together in nested hashes.

# bad
h = { a: { b: 2 } }

# good
h = { a: { b: 2 }}

Surrounding space missing for operator =>.
Open

      record.resources = [{"resources"=>["test01"], "sequential"=>"true", "action"=>"Started"}]
Severity: Minor
Found in hawk/spec/models/colocation_spec.rb by rubocop

Checks that operators have space around them, except for ** which should not have surrounding space.

Example:

# bad
total = 3*4
"apple"+"juice"
my_number = 38/4
a ** b

# good
total = 3 * 4
"apple" + "juice"
my_number = 38 / 4
a**b

Space inside { missing.
Open

      record.resources = [{"resources"=>["test01"], "sequential"=>"true", "action"=>"Started"}]
Severity: Minor
Found in hawk/spec/models/colocation_spec.rb by rubocop

Checks that braces used for hash literals have or don't have surrounding space depending on configuration.

Example: EnforcedStyle: space

# The `space` style enforces that hash literals have
# surrounding space.

# bad
h = {a: 1, b: 2}

# good
h = { a: 1, b: 2 }

Example: EnforcedStyle: no_space

# The `no_space` style enforces that hash literals have
# no surrounding space.

# bad
h = { a: 1, b: 2 }

# good
h = {a: 1, b: 2}

Example: EnforcedStyle: compact

# The `compact` style normally requires a space inside
# hash braces, with the exception that successive left
# braces or right braces are collapsed together in nested hashes.

# bad
h = { a: { b: 2 } }

# good
h = { a: { b: 2 }}

Align the elements of an array literal if they span more than one line.
Open

      {"resources"=>["test02"], "sequential"=>"true", "action"=>"Started"}]
Severity: Minor
Found in hawk/spec/models/colocation_spec.rb by rubocop

Here we check if the elements of a multi-line array literal are aligned.

Example:

# bad
a = [1, 2, 3,
  4, 5, 6]
array = ['run',
     'forrest',
     'run']

# good
a = [1, 2, 3,
     4, 5, 6]
a = ['run',
     'forrest',
     'run']

Surrounding space missing for operator =>.
Open

      record.resources = [{"resources"=>["test01"], "sequential"=>"true", "action"=>"Started"},
Severity: Minor
Found in hawk/spec/models/colocation_spec.rb by rubocop

Checks that operators have space around them, except for ** which should not have surrounding space.

Example:

# bad
total = 3*4
"apple"+"juice"
my_number = 38/4
a ** b

# good
total = 3 * 4
"apple" + "juice"
my_number = 38 / 4
a**b

Surrounding space missing for operator =>.
Open

      record.resources = [{"resources"=>["test01"], "sequential"=>"true", "action"=>"Started"},
Severity: Minor
Found in hawk/spec/models/colocation_spec.rb by rubocop

Checks that operators have space around them, except for ** which should not have surrounding space.

Example:

# bad
total = 3*4
"apple"+"juice"
my_number = 38/4
a ** b

# good
total = 3 * 4
"apple" + "juice"
my_number = 38 / 4
a**b

Space inside } missing.
Open

        {"resources"=>["test02"], "sequential"=>"true", "action"=>"Started"}]
Severity: Minor
Found in hawk/spec/models/colocation_spec.rb by rubocop

Checks that braces used for hash literals have or don't have surrounding space depending on configuration.

Example: EnforcedStyle: space

# The `space` style enforces that hash literals have
# surrounding space.

# bad
h = {a: 1, b: 2}

# good
h = { a: 1, b: 2 }

Example: EnforcedStyle: no_space

# The `no_space` style enforces that hash literals have
# no surrounding space.

# bad
h = { a: 1, b: 2 }

# good
h = {a: 1, b: 2}

Example: EnforcedStyle: compact

# The `compact` style normally requires a space inside
# hash braces, with the exception that successive left
# braces or right braces are collapsed together in nested hashes.

# bad
h = { a: { b: 2 } }

# good
h = { a: { b: 2 }}

Surrounding space missing for operator =>.
Open

      {"resources"=>["test02"], "sequential"=>"true", "action"=>"Started"}]
Severity: Minor
Found in hawk/spec/models/colocation_spec.rb by rubocop

Checks that operators have space around them, except for ** which should not have surrounding space.

Example:

# bad
total = 3*4
"apple"+"juice"
my_number = 38/4
a ** b

# good
total = 3 * 4
"apple" + "juice"
my_number = 38 / 4
a**b

Space inside } missing.
Open

      record.resources = [{"resources"=>["test01"], "sequential"=>"true", "action"=>"Started"}]
Severity: Minor
Found in hawk/spec/models/colocation_spec.rb by rubocop

Checks that braces used for hash literals have or don't have surrounding space depending on configuration.

Example: EnforcedStyle: space

# The `space` style enforces that hash literals have
# surrounding space.

# bad
h = {a: 1, b: 2}

# good
h = { a: 1, b: 2 }

Example: EnforcedStyle: no_space

# The `no_space` style enforces that hash literals have
# no surrounding space.

# bad
h = { a: 1, b: 2 }

# good
h = {a: 1, b: 2}

Example: EnforcedStyle: compact

# The `compact` style normally requires a space inside
# hash braces, with the exception that successive left
# braces or right braces are collapsed together in nested hashes.

# bad
h = { a: { b: 2 } }

# good
h = { a: { b: 2 }}

Surrounding space missing for operator =>.
Open

      {"resources"=>["test02"], "sequential"=>"true", "action"=>"Started"}]
Severity: Minor
Found in hawk/spec/models/colocation_spec.rb by rubocop

Checks that operators have space around them, except for ** which should not have surrounding space.

Example:

# bad
total = 3*4
"apple"+"juice"
my_number = 38/4
a ** b

# good
total = 3 * 4
"apple" + "juice"
my_number = 38 / 4
a**b

Surrounding space missing for operator =>.
Open

      record.resources = [{"resources"=>["test01"], "sequential"=>"true", "action"=>"Started"}]
Severity: Minor
Found in hawk/spec/models/colocation_spec.rb by rubocop

Checks that operators have space around them, except for ** which should not have surrounding space.

Example:

# bad
total = 3*4
"apple"+"juice"
my_number = 38/4
a ** b

# good
total = 3 * 4
"apple" + "juice"
my_number = 38 / 4
a**b

Surrounding space missing for operator =>.
Open

        {"resources"=>["test02"], "sequential"=>"true", "action"=>"Started"}]
Severity: Minor
Found in hawk/spec/models/colocation_spec.rb by rubocop

Checks that operators have space around them, except for ** which should not have surrounding space.

Example:

# bad
total = 3*4
"apple"+"juice"
my_number = 38/4
a ** b

# good
total = 3 * 4
"apple" + "juice"
my_number = 38 / 4
a**b

Align the elements of an array literal if they span more than one line.
Open

        {"resources"=>["test02"], "sequential"=>"true", "action"=>"Started"}]
Severity: Minor
Found in hawk/spec/models/colocation_spec.rb by rubocop

Here we check if the elements of a multi-line array literal are aligned.

Example:

# bad
a = [1, 2, 3,
  4, 5, 6]
array = ['run',
     'forrest',
     'run']

# good
a = [1, 2, 3,
     4, 5, 6]
a = ['run',
     'forrest',
     'run']

Missing space after #.
Open

      record.valid? #run validation
Severity: Minor
Found in hawk/spec/models/colocation_spec.rb by rubocop

This cop checks whether comments have a leading space after the # denoting the start of the comment. The leading space is not required for some RDoc special syntax, like #++, #--, #:nodoc, =begin- and =end comments, "shebang" directives, or rackup options.

Example:

# bad
#Some comment

# good
# Some comment

Surrounding space missing for operator =>.
Open

        {"resources"=>["test02"], "sequential"=>"true", "action"=>"Started"}]
Severity: Minor
Found in hawk/spec/models/colocation_spec.rb by rubocop

Checks that operators have space around them, except for ** which should not have surrounding space.

Example:

# bad
total = 3*4
"apple"+"juice"
my_number = 38/4
a ** b

# good
total = 3 * 4
"apple" + "juice"
my_number = 38 / 4
a**b

Surrounding space missing for operator =>.
Open

      {"resources"=>["test02"], "sequential"=>"true", "action"=>"Started"}]
Severity: Minor
Found in hawk/spec/models/colocation_spec.rb by rubocop

Checks that operators have space around them, except for ** which should not have surrounding space.

Example:

# bad
total = 3*4
"apple"+"juice"
my_number = 38/4
a ** b

# good
total = 3 * 4
"apple" + "juice"
my_number = 38 / 4
a**b

Space inside { missing.
Open

        {"resources"=>["test02"], "sequential"=>"true", "action"=>"Started"}]
Severity: Minor
Found in hawk/spec/models/colocation_spec.rb by rubocop

Checks that braces used for hash literals have or don't have surrounding space depending on configuration.

Example: EnforcedStyle: space

# The `space` style enforces that hash literals have
# surrounding space.

# bad
h = {a: 1, b: 2}

# good
h = { a: 1, b: 2 }

Example: EnforcedStyle: no_space

# The `no_space` style enforces that hash literals have
# no surrounding space.

# bad
h = { a: 1, b: 2 }

# good
h = {a: 1, b: 2}

Example: EnforcedStyle: compact

# The `compact` style normally requires a space inside
# hash braces, with the exception that successive left
# braces or right braces are collapsed together in nested hashes.

# bad
h = { a: { b: 2 } }

# good
h = { a: { b: 2 }}

Surrounding space missing for operator =>.
Open

        {"resources"=>["test02"], "sequential"=>"true", "action"=>"Started"}]
Severity: Minor
Found in hawk/spec/models/colocation_spec.rb by rubocop

Checks that operators have space around them, except for ** which should not have surrounding space.

Example:

# bad
total = 3*4
"apple"+"juice"
my_number = 38/4
a ** b

# good
total = 3 * 4
"apple" + "juice"
my_number = 38 / 4
a**b

Space inside } missing.
Open

      record.resources = [{"resources"=>["test01"], "sequential"=>"true", "action"=>"Started"},
Severity: Minor
Found in hawk/spec/models/colocation_spec.rb by rubocop

Checks that braces used for hash literals have or don't have surrounding space depending on configuration.

Example: EnforcedStyle: space

# The `space` style enforces that hash literals have
# surrounding space.

# bad
h = {a: 1, b: 2}

# good
h = { a: 1, b: 2 }

Example: EnforcedStyle: no_space

# The `no_space` style enforces that hash literals have
# no surrounding space.

# bad
h = { a: 1, b: 2 }

# good
h = {a: 1, b: 2}

Example: EnforcedStyle: compact

# The `compact` style normally requires a space inside
# hash braces, with the exception that successive left
# braces or right braces are collapsed together in nested hashes.

# bad
h = { a: { b: 2 } }

# good
h = { a: { b: 2 }}

Surrounding space missing for operator =>.
Open

      record.resources = [{"resources"=>["test01"], "sequential"=>"true", "action"=>"Started"}]
Severity: Minor
Found in hawk/spec/models/colocation_spec.rb by rubocop

Checks that operators have space around them, except for ** which should not have surrounding space.

Example:

# bad
total = 3*4
"apple"+"juice"
my_number = 38/4
a ** b

# good
total = 3 * 4
"apple" + "juice"
my_number = 38 / 4
a**b

Surrounding space missing for operator =>.
Open

      record.resources = [{"resources"=>["test01"], "sequential"=>"true", "action"=>"Started"},
Severity: Minor
Found in hawk/spec/models/colocation_spec.rb by rubocop

Checks that operators have space around them, except for ** which should not have surrounding space.

Example:

# bad
total = 3*4
"apple"+"juice"
my_number = 38/4
a ** b

# good
total = 3 * 4
"apple" + "juice"
my_number = 38 / 4
a**b

Space inside } missing.
Open

      {"resources"=>["test02"], "sequential"=>"true", "action"=>"Started"}]
Severity: Minor
Found in hawk/spec/models/colocation_spec.rb by rubocop

Checks that braces used for hash literals have or don't have surrounding space depending on configuration.

Example: EnforcedStyle: space

# The `space` style enforces that hash literals have
# surrounding space.

# bad
h = {a: 1, b: 2}

# good
h = { a: 1, b: 2 }

Example: EnforcedStyle: no_space

# The `no_space` style enforces that hash literals have
# no surrounding space.

# bad
h = { a: 1, b: 2 }

# good
h = {a: 1, b: 2}

Example: EnforcedStyle: compact

# The `compact` style normally requires a space inside
# hash braces, with the exception that successive left
# braces or right braces are collapsed together in nested hashes.

# bad
h = { a: { b: 2 } }

# good
h = { a: { b: 2 }}

Space inside } missing.
Open

      record.resources = [{"resources"=>["test01"], "sequential"=>"true", "action"=>"Started"},
Severity: Minor
Found in hawk/spec/models/colocation_spec.rb by rubocop

Checks that braces used for hash literals have or don't have surrounding space depending on configuration.

Example: EnforcedStyle: space

# The `space` style enforces that hash literals have
# surrounding space.

# bad
h = {a: 1, b: 2}

# good
h = { a: 1, b: 2 }

Example: EnforcedStyle: no_space

# The `no_space` style enforces that hash literals have
# no surrounding space.

# bad
h = { a: 1, b: 2 }

# good
h = {a: 1, b: 2}

Example: EnforcedStyle: compact

# The `compact` style normally requires a space inside
# hash braces, with the exception that successive left
# braces or right braces are collapsed together in nested hashes.

# bad
h = { a: { b: 2 } }

# good
h = { a: { b: 2 }}

Space inside { missing.
Open

      {"resources"=>["test02"], "sequential"=>"true", "action"=>"Started"}]
Severity: Minor
Found in hawk/spec/models/colocation_spec.rb by rubocop

Checks that braces used for hash literals have or don't have surrounding space depending on configuration.

Example: EnforcedStyle: space

# The `space` style enforces that hash literals have
# surrounding space.

# bad
h = {a: 1, b: 2}

# good
h = { a: 1, b: 2 }

Example: EnforcedStyle: no_space

# The `no_space` style enforces that hash literals have
# no surrounding space.

# bad
h = { a: 1, b: 2 }

# good
h = {a: 1, b: 2}

Example: EnforcedStyle: compact

# The `compact` style normally requires a space inside
# hash braces, with the exception that successive left
# braces or right braces are collapsed together in nested hashes.

# bad
h = { a: { b: 2 } }

# good
h = { a: { b: 2 }}

Space inside { missing.
Open

      record.resources = [{"resources"=>["test01"], "sequential"=>"true", "action"=>"Started"},
Severity: Minor
Found in hawk/spec/models/colocation_spec.rb by rubocop

Checks that braces used for hash literals have or don't have surrounding space depending on configuration.

Example: EnforcedStyle: space

# The `space` style enforces that hash literals have
# surrounding space.

# bad
h = {a: 1, b: 2}

# good
h = { a: 1, b: 2 }

Example: EnforcedStyle: no_space

# The `no_space` style enforces that hash literals have
# no surrounding space.

# bad
h = { a: 1, b: 2 }

# good
h = {a: 1, b: 2}

Example: EnforcedStyle: compact

# The `compact` style normally requires a space inside
# hash braces, with the exception that successive left
# braces or right braces are collapsed together in nested hashes.

# bad
h = { a: { b: 2 } }

# good
h = { a: { b: 2 }}

Final newline missing.
Open

end
Severity: Minor
Found in hawk/spec/models/colocation_spec.rb by rubocop

Trailing whitespace detected.
Open

    end    
Severity: Minor
Found in hawk/spec/models/colocation_spec.rb by rubocop

There are no issues that match your filters.

Category
Status