TheCorrespondingSquares/chess-app

View on GitHub

Showing 927 of 927 total issues

Redundant return detected.
Open

    return pieces.where(color: color).where(captured: false)
Severity: Minor
Found in app/models/game.rb by rubocop

This cop checks for redundant return expressions.

Example:

def test
  return something
end

def test
  one
  two
  three
  return something
end

It should be extended to handle methods whose body is if/else or a case expression with a default branch.

Trailing whitespace detected.
Open

  def valid_move?(to_x, to_y)    
Severity: Minor
Found in app/models/knight.rb by rubocop

Inconsistent indentation detected.
Open

  def valid_move?(to_x, to_y)
    return false if friendly_piece_on_square?(to_x, to_y)
    horizontal_move_one_square_only?(to_x, to_y) || vertical_move_one_square_only?(to_x, to_y) || diagonal_move_one_square?(to_x, to_y)
  end
Severity: Minor
Found in app/models/king.rb by rubocop

This cops checks for inconsistent indentation.

Example:

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

Carriage return character detected.
Open

module Obstructions

  # Check for obstructions
Severity: Minor
Found in app/models/concerns/obstructions.rb by rubocop

Rename is_obstructed? to obstructed?.
Open

  def is_obstructed?(destination_x, destination_y)
Severity: Minor
Found in app/models/concerns/obstructions.rb by rubocop

This cop makes sure that predicates are named properly.

Example:

# bad
def is_even?(value)
end

# good
def even?(value)
end

# bad
def has_value?
end

# good
def value?
end

Redundant self detected.
Open

      Piece.create(name: piece, color: 'Black', game_id: self.id, x_pos: i, y_pos: 7)
Severity: Minor
Found in app/models/game.rb by rubocop

This cop checks for redundant uses of self.

The usage of self is only needed when:

  • Sending a message to same object with zero arguments in presence of a method name clash with an argument or a local variable.

  • Calling an attribute writer to prevent an local variable assignment.

Note, with using explicit self you can only send messages with public or protected scope, you cannot send private messages this way.

Note we allow uses of self with operators because it would be awkward otherwise.

Example:

# bad
def foo(bar)
  self.baz
end

# good
def foo(bar)
  self.bar  # Resolves name clash with the argument.
end

def foo
  bar = 1
  self.bar  # Resolves name clash with the local variable.
end

def foo
  %w[x y z].select do |bar|
    self.bar == bar  # Resolves name clash with argument of the block.
  end
end

Inconsistent indentation detected.
Open

  def is_able_to_escape_check?
    ((x_pos - 1)..(x_pos + 1)).each do |x|
      next if x_out_of_range?(x)
      ((y_pos - 1 )..(y_pos + 1)).each do |y|
        next if y_out_of_range?(y)
Severity: Minor
Found in app/models/king.rb by rubocop

This cops checks for inconsistent indentation.

Example:

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

Missing top-level class documentation comment.
Open

class King < Piece
Severity: Minor
Found in app/models/king.rb by rubocop

This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

Example:

# bad
class Person
  # ...
end

# good
# Description/Explanation of Person class
class Person
  # ...
end

Trailing whitespace detected.
Open

  
Severity: Minor
Found in app/models/pawn.rb by rubocop

Line is too long. [86/80]
Open

    opposite_is_on_square?(color, to_x, to_y) && diagonal_move_one_square?(to_x, to_y)
Severity: Minor
Found in app/models/pawn.rb by rubocop

Redundant self detected.
Open

      self.y_pos == 1 ? to_y < 4 : vertical_move_one_square?(to_y)
Severity: Minor
Found in app/models/pawn.rb by rubocop

This cop checks for redundant uses of self.

The usage of self is only needed when:

  • Sending a message to same object with zero arguments in presence of a method name clash with an argument or a local variable.

  • Calling an attribute writer to prevent an local variable assignment.

Note, with using explicit self you can only send messages with public or protected scope, you cannot send private messages this way.

Note we allow uses of self with operators because it would be awkward otherwise.

Example:

# bad
def foo(bar)
  self.baz
end

# good
def foo(bar)
  self.bar  # Resolves name clash with the argument.
end

def foo
  bar = 1
  self.bar  # Resolves name clash with the local variable.
end

def foo
  %w[x y z].select do |bar|
    self.bar == bar  # Resolves name clash with argument of the block.
  end
end

Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
Open

      if game.check?(self.color)
Severity: Minor
Found in app/models/piece.rb by rubocop

Checks for if and unless statements that would fit on one line if written as a modifier if/unless. The maximum line length is configured in the Metrics/LineLength cop.

Example:

# bad
if condition
  do_stuff(bar)
end

unless qux.empty?
  Foo.do_something
end

# good
do_stuff(bar) if condition
Foo.do_something unless qux.empty?

Missing space after #.
Open

  #end
Severity: Minor
Found in app/models/game.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

Trailing whitespace detected.
Open

  end 
Severity: Minor
Found in app/models/game.rb by rubocop

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

      Pawn.create(color: 'White', game_id: self.id, x_pos: i, y_pos: 1, icon: "&#9817;")
Severity: Minor
Found in app/models/game.rb by rubocop

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"

Missing top-level module documentation comment.
Open

module Movements
Severity: Minor
Found in app/models/concerns/movements.rb by rubocop

This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

Example:

# bad
class Person
  # ...
end

# good
# Description/Explanation of Person class
class Person
  # ...
end

Missing top-level class documentation comment.
Open

class ApplicationRecord < ActiveRecord::Base
Severity: Minor
Found in app/models/application_record.rb by rubocop

This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

Example:

# bad
class Person
  # ...
end

# good
# Description/Explanation of Person class
class Person
  # ...
end

Extra empty line detected at module body end.
Open


end
Severity: Minor
Found in app/models/concerns/squares.rb by rubocop

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

Example: EnforcedStyle: empty_lines

# good

module Foo

  def bar
    # ...
  end

end

Example: EnforcedStyle: emptylinesexcept_namespace

# good

module Foo
  module Bar

    # ...

  end
end

Example: EnforcedStyle: emptylinesspecial

# good
module Foo

  def bar; end

end

Example: EnforcedStyle: noemptylines (default)

# good

module Foo
  def bar
    # ...
  end
end

Use 2 (not 0) spaces for indentation.
Open

after_create :icon
Severity: Minor
Found in app/models/knight.rb by rubocop

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

Trailing whitespace detected.
Open

  
Severity: Minor
Found in app/models/concerns/squares.rb by rubocop
Severity
Category
Status
Source
Language