TheCorrespondingSquares/chess-app

View on GitHub
spec/models/concerns/obstructions_spec.rb

Summary

Maintainability
A
0 mins
Test Coverage

Block has too many lines. [59/25]
Open

RSpec.describe Piece, type: :model do
  let(:user) { FactoryGirl.create(:user) }
  let(:game) { FactoryGirl.create(:game, black_player_id: user.id)}
  before(:each) { game.pieces.destroy_all }

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

Block has too many lines. [54/25]
Open

  describe "#is_obstructed?" do
    subject(:is_obstructed?) { piece_to_move.is_obstructed?(destination_x, destination_y) }

    let(:piece_to_move) { FactoryGirl.create(:piece, color: "Black", name: name_to_move, x_pos: 3, y_pos: 2, game_id: game.id) }

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

Block has too many lines. [44/25]
Open

    describe 'Any obstructions' do      
      before(:each) { FactoryGirl.create(:rook, color: "White", x_pos: x_obstructs, y_pos: y_obstructs, game_id: game.id) }
      let(:name_to_move) { "Queen" }

      context 'for the horizontal direction' do

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

Space missing inside }.
Open

  let(:game) { FactoryGirl.create(:game, black_player_id: user.id)}

Checks that block braces have or don't have surrounding space inside them on configuration. For blocks taking parameters, it checks that the left brace has or doesn't have trailing space depending on configuration.

Example: EnforcedStyle: space (default)

# The `space` style enforces that block braces have
# surrounding space.

# bad
some_array.each {puts e}

# good
some_array.each { puts e }

Example: EnforcedStyle: no_space

# The `no_space` style enforces that block braces don't
# have surrounding space.

# bad
some_array.each { puts e }

# good
some_array.each {puts e}

Example: EnforcedStyleForEmptyBraces: no_space (default)

# The `no_space` EnforcedStyleForEmptyBraces style enforces that
# block braces don't have a space in between when empty.

# bad
some_array.each {   }
some_array.each {  }
some_array.each { }

# good
some_array.each {}

Example: EnforcedStyleForEmptyBraces: space

# The `space` EnforcedStyleForEmptyBraces style enforces that
# block braces have at least a spece in between when empty.

# bad
some_array.each {}

# good
some_array.each { }
some_array.each {  }
some_array.each {   }

Example: SpaceBeforeBlockParameters: true (default)

# The SpaceBeforeBlockParameters style set to `true` enforces that
# there is a space between `{` and `|`. Overrides `EnforcedStyle`
# if there is a conflict.

# bad
[1, 2, 3].each {|n| n * 2 }

# good
[1, 2, 3].each { |n| n * 2 }

Example: SpaceBeforeBlockParameters: true

# The SpaceBeforeBlockParameters style set to `false` enforces that
# there is no space between `{` and `|`. Overrides `EnforcedStyle`
# if there is a conflict.

# bad
[1, 2, 3].each { |n| n * 2 }

# good
[1, 2, 3].each {|n| n * 2 }

Carriage return character detected.
Open

require 'rails_helper'

RSpec.describe Piece, type: :model do

Line is too long. [123/80]
Open

      before(:each) { FactoryGirl.create(:rook, color: "White", x_pos: x_obstructs, y_pos: y_obstructs, game_id: game.id) }

Trailing whitespace detected.
Open

          let(:destination_y) { 6 }        

Line is too long. [128/80]
Open

    let(:piece_to_move) { FactoryGirl.create(:piece, color: "Black", name: name_to_move, x_pos: 3, y_pos: 2, game_id: game.id) }

Inconsistent indentation detected.
Open

        context 'when there is an obstruction' do
          let(:x_obstructs) { 5 }
          let(:y_obstructs) { 4 }

          it { is_expected.to eq(true) }

This cops checks for inconsistent indentation.

Example:

class A
  def test
    puts 'hello'
     puts 'world'
  end
end

Prefer single-quoted strings when you don't need string interpolation or special symbols.
Open

  describe "#is_obstructed?" do

Checks if uses of quotes match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
"No special symbols"
"No string interpolation"
"Just text"

# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"

Example: EnforcedStyle: double_quotes

# bad
'Just some text'
'No special chars or interpolation'

# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"

Prefer single-quoted strings when you don't need string interpolation or special symbols.
Open

    let(:piece_to_move) { FactoryGirl.create(:piece, color: "Black", name: name_to_move, x_pos: 3, y_pos: 2, game_id: game.id) }

Checks if uses of quotes match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
"No special symbols"
"No string interpolation"
"Just text"

# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"

Example: EnforcedStyle: double_quotes

# bad
'Just some text'
'No special chars or interpolation'

# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"

Use 2 (not 4) spaces for indentation.
Open

          let(:destination_x) { 7 }

This cops checks for indentation that doesn't use the specified number of spaces.

See also the IndentationConsistency cop which is the companion to this one.

Example:

# bad
class A
 def test
  puts 'hello'
 end
end

# good
class A
  def test
    puts 'hello'
  end
end

Example: IgnoredPatterns: ['^\s*module']

# bad
module A
class B
  def test
  puts 'hello'
  end
end
end

# good
module A
class B
  def test
    puts 'hello'
  end
end
end

Prefer single-quoted strings when you don't need string interpolation or special symbols.
Open

      let(:name_to_move) { "Knight" }

Checks if uses of quotes match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
"No special symbols"
"No string interpolation"
"Just text"

# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"

Example: EnforcedStyle: double_quotes

# bad
'Just some text'
'No special chars or interpolation'

# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"

Extra empty line detected at block body end.
Open


end

This cops checks if empty lines around the bodies of blocks match the configuration.

Example: EnforcedStyle: empty_lines

# good

foo do |bar|

  # ...

end

Example: EnforcedStyle: noemptylines (default)

# good

foo do |bar|
  # ...
end

Final newline missing.
Open

end

Line is too long. [91/80]
Open

    subject(:is_obstructed?) { piece_to_move.is_obstructed?(destination_x, destination_y) }

Trailing whitespace detected.
Open

    describe 'Any obstructions' do      

Inconsistent indentation detected.
Open

        context 'when there is no obstruction' do
          let(:x_obstructs) { 7 }
          let(:y_obstructs) { 6 }

          it { is_expected.to eq(false) }

This cops checks for inconsistent indentation.

Example:

class A
  def test
    puts 'hello'
     puts 'world'
  end
end

Prefer single-quoted strings when you don't need string interpolation or special symbols.
Open

      before(:each) { FactoryGirl.create(:rook, color: "White", x_pos: x_obstructs, y_pos: y_obstructs, game_id: game.id) }

Checks if uses of quotes match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
"No special symbols"
"No string interpolation"
"Just text"

# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"

Example: EnforcedStyle: double_quotes

# bad
'Just some text'
'No special chars or interpolation'

# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"

Prefer single-quoted strings when you don't need string interpolation or special symbols.
Open

      let(:name_to_move) { "Queen" }

Checks if uses of quotes match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
"No special symbols"
"No string interpolation"
"Just text"

# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"

Example: EnforcedStyle: double_quotes

# bad
'Just some text'
'No special chars or interpolation'

# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"

There are no issues that match your filters.

Category
Status