TheCorrespondingSquares/chess-app

View on GitHub
spec/controllers/pieces_controller_spec.rb

Summary

Maintainability
A
0 mins
Test Coverage

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

RSpec.describe PiecesController, type: :controller do
  let(:white_player) { FactoryGirl.create(:user) }
  let(:black_player) { FactoryGirl.create(:user) }
  let(:game) { FactoryGirl.create(:game, white_player_id: white_player.id, black_player_id: black_player.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. [175/25]
Open

  describe 'pieces#update action' do
    
    context 'When a piece making a check' do
      before(:each) { game.pieces.destroy_all } 
      let!(:white_bishop) { FactoryGirl.create(:bishop, color: "White", x_pos: 5, y_pos: 3, 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. [111/25]
Open

    context 'When both players have joined' do
      let!(:white_pawn) { FactoryGirl.create(:pawn, color: "White", x_pos: 4, y_pos: 1, game_id: game.id) }
      let!(:black_pawn) { FactoryGirl.create(:pawn, color: "Black", x_pos: 4, y_pos: 6, game_id: game.id) }
      before(:each) { game.update_attributes(turn: 0) }
      before(:each) { sign_out white_player }

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. [31/25]
Open

    context 'When there is a check condition' do
      before(:each) { game.pieces.destroy_all } 
      let!(:white_bishop) { FactoryGirl.create(:bishop, color: "White", x_pos: 4, y_pos: 4, game_id: game.id) }
      let!(:black_bishop) { FactoryGirl.create(:bishop, color: "Black", x_pos: 6, y_pos: 4, game_id: game.id) }
      let!(:black_king) { FactoryGirl.create(:king, color: "Black", x_pos: 7, y_pos: 7, 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.

Trailing whitespace detected.
Open

    

Line is too long. [107/80]
Open

      let!(:black_pawn) { FactoryGirl.create(:pawn, color: "Black", x_pos: 4, y_pos: 6, game_id: game.id) }

Line is too long. [90/80]
Open

        patch :update, params: { game_id: game.id, id: white_pawn.id, x_pos: 4, y_pos: 2 }

Line is too long. [81/80]
Open

          expect(flash[:alert]).to match("Sorry, you are not part of this game.")

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

      let!(:white_king) { FactoryGirl.create(:king, color: "White", x_pos: 2, y_pos: 0, 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"

Line is too long. [111/80]
Open

      let!(:black_bishop) { FactoryGirl.create(:bishop, color: "Black", x_pos: 6, y_pos: 4, game_id: game.id) }

Line is too long. [90/80]
Open

        expect(flash[:alert]).to match("Sorry, that move would leave your King in check.")

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

    let(:rook) { FactoryGirl.create(:rook, color: "Black", x_pos: 7, y_pos: 7, 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!(:white_bishop) { FactoryGirl.create(:bishop, color: "White", x_pos: 4, y_pos: 4, 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"

Line is too long. [107/80]
Open

      let!(:white_king) { FactoryGirl.create(:king, color: "White", x_pos: 4, y_pos: 0, game_id: game.id) }

Line is too long. [117/80]
Open

      let(:player1_pawn) { FactoryGirl.create(:pawn, color: "White", x_pos: 5, y_pos: 1, game_id: game_not_full.id) }

Line is too long. [90/80]
Open

        patch :update, params: { game_id: game.id, id: black_pawn.id, x_pos: 4, y_pos: 5 }

Line is too long. [111/80]
Open

      let!(:white_bishop) { FactoryGirl.create(:bishop, color: "White", x_pos: 5, y_pos: 3, game_id: game.id) }

Line is too long. [92/80]
Open

        patch :update, params: { game_id: game.id, id: white_bishop.id, x_pos: 4, y_pos: 4 }

Line is too long. [107/80]
Open

      let!(:black_king) { FactoryGirl.create(:king, color: "Black", x_pos: 7, y_pos: 7, game_id: game.id) }

Line is too long. [90/80]
Open

        patch :update, params: { game_id: game.id, id: black_pawn.id, x_pos: 4, y_pos: 4 }

Space inside } missing.
Open

        patch :update, params: {game_id: game_not_full.id, id: player1_pawn.id, x_pos: 5, y_pos: 2}

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 }}

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

      let!(:white_bishop) { FactoryGirl.create(:bishop, color: "White", x_pos: 5, y_pos: 3, 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"

Trailing whitespace detected.
Open

          game.reload          

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

        expect(flash[:alert]).to match("Sorry, that move would leave your King in check.")

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"

Trailing whitespace detected.
Open

    end   

Line is too long. [87/80]
Open

      it 'should not allow Black piece/player to move on White piece/player\'s turn' do

Line is too long. [90/80]
Open

        patch :update, params: { game_id: game.id, id: white_pawn.id, x_pos: 4, y_pos: 2 }

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

      let!(:white_king) { FactoryGirl.create(:king, color: "White", x_pos: 4, y_pos: 0, 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"

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

Line is too long. [98/80]
Open

    let(:rook) { FactoryGirl.create(:rook, color: "Black", x_pos: 7, y_pos: 7, game_id: game.id) }

Line is too long. [87/80]
Open

      it 'should not allow White piece/player to move on Black piece/player\'s turn' do

Space inside { missing.
Open

        patch :update, params: {game_id: game_not_full.id, id: player1_pawn.id, x_pos: 5, y_pos: 2}

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 }}

Line is too long. [110/80]
Open

  let(:game) { FactoryGirl.create(:game, white_player_id: white_player.id, black_player_id: black_player.id) }

Line is too long. [107/80]
Open

      let!(:black_king) { FactoryGirl.create(:king, color: "Black", x_pos: 7, y_pos: 7, game_id: game.id) }

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

          expect(flash[:alert]).to match("Sorry, you are not part of this game.")

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!(:black_pawn) { FactoryGirl.create(:pawn, color: "Black", x_pos: 4, y_pos: 6, 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"

Trailing whitespace detected.
Open

          expect(game.turn).to eq(16)              

Line is too long. [92/80]
Open

        patch :update, params: { game_id: game.id, id: black_bishop.id, x_pos: 7, y_pos: 3 }

Line is too long. [92/80]
Open

          patch :update, params: { game_id: game.id, id: white_pawn.id, x_pos: 4, y_pos: 2 }

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

      let!(:black_king) { FactoryGirl.create(:king, color: "Black", x_pos: 7, y_pos: 7, 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"

Trailing whitespace detected.
Open

          expect(game.turn).to eq(23)          

Line is too long. [107/80]
Open

      let!(:white_king) { FactoryGirl.create(:king, color: "White", x_pos: 2, y_pos: 0, game_id: game.id) }

Trailing whitespace detected.
Open

      before(:each) { game.pieces.destroy_all } 

Line is too long. [81/80]
Open

          expect(flash[:alert]).to match("Sorry, you are not part of this game.")

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

      let!(:black_king) { FactoryGirl.create(:king, color: "Black", x_pos: 7, y_pos: 7, 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"

Trailing whitespace detected.
Open

      before(:each) { game.pieces.destroy_all } 

Line is too long. [92/80]
Open

        patch :update, params: { game_id: game.id, id: black_bishop.id, x_pos: 5, y_pos: 5 }

Line is too long. [81/80]
Open

        # expect(flash[:alert]).to match("Waiting for another player to join...")

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

        expect(game.check?("Black")).to eq(true)

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"

Line is too long. [90/80]
Open

        patch :update, params: { game_id: game.id, id: black_pawn.id, x_pos: 4, y_pos: 4 }

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

      let!(:black_bishop) { FactoryGirl.create(:bishop, color: "Black", x_pos: 6, y_pos: 4, 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"

Trailing whitespace detected.
Open

        expect(game.turn).to eq(19)        

Line is too long. [111/80]
Open

      let!(:white_bishop) { FactoryGirl.create(:bishop, color: "White", x_pos: 4, y_pos: 4, game_id: game.id) }

Line is too long. [90/80]
Open

        patch :update, params: { game_id: game.id, id: black_pawn.id, x_pos: 4, y_pos: 5 }

Line is too long. [92/80]
Open

          patch :update, params: { game_id: game.id, id: black_pawn.id, x_pos: 4, y_pos: 5 }

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

          expect(flash[:alert]).to match("Sorry, you are not part of this game.")

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"

Trailing whitespace detected.
Open

        expect(black_bishop.y_pos).to eq 4     

Trailing whitespace detected.
Open

  end 

Line is too long. [111/80]
Open

      let(:game_not_full) { FactoryGirl.create(:game, white_player_id: white_player.id, black_player_id: nil) }

Line is too long. [99/80]
Open

        patch :update, params: {game_id: game_not_full.id, id: player1_pawn.id, x_pos: 5, y_pos: 2}

Line is too long. [107/80]
Open

      let!(:white_pawn) { FactoryGirl.create(:pawn, color: "White", x_pos: 4, y_pos: 1, game_id: game.id) }

Line is too long. [90/80]
Open

        patch :update, params: { game_id: game.id, id: white_pawn.id, x_pos: 4, y_pos: 3 }

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

      let(:player1_pawn) { FactoryGirl.create(:pawn, color: "White", x_pos: 5, y_pos: 1, game_id: game_not_full.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!(:white_pawn) { FactoryGirl.create(:pawn, color: "White", x_pos: 4, y_pos: 1, 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"

There are no issues that match your filters.

Category
Status