TheCorrespondingSquares/chess-app

View on GitHub

Showing 927 of 927 total issues

Missing top-level module documentation comment.
Open

module Squares
Severity: Minor
Found in app/models/concerns/squares.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

Line is too long. [85/80]
Open

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

Trailing whitespace detected.
Open

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

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

      Pawn.create(color: 'Black', game_id: self.id, x_pos: i, y_pos: 6, icon:"♟")
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"

Use normalcase for variable numbers.
Open

    y_up_1 = @opponent_pawn.y_pos + 1
Severity: Minor
Found in app/models/pawn.rb by rubocop

This cop makes sure that all numbered variables use the configured style, snakecase, normalcase or noninteger, for their numbering.

Example: EnforcedStyle: snake_case

# bad

variable1 = 1

# good

variable_1 = 1

Example: EnforcedStyle: normalcase (default)

# bad

variable_1 = 1

# good

variable1 = 1

Example: EnforcedStyle: non_integer

# bad

variable1 = 1

variable_1 = 1

# good

variableone = 1

variable_one = 1

Use y_pos.zero? instead of y_pos == 0.
Open

    y_pos == 0 && is_black?
Severity: Minor
Found in app/models/pawn.rb by rubocop

This cop checks for usage of comparison operators (==, >, <) to test numbers as zero, positive, or negative. These can be replaced by their respective predicate methods. The cop can also be configured to do the reverse.

The cop disregards #nonzero? as it its value is truthy or falsey, but not true and false, and thus not always interchangeable with != 0.

The cop ignores comparisons to global variables, since they are often populated with objects which can be compared with integers, but are not themselves Interger polymorphic.

Example: EnforcedStyle: predicate (default)

# bad

foo == 0
0 > foo
bar.baz > 0

# good

foo.zero?
foo.negative?
bar.baz.positive?

Example: EnforcedStyle: comparison

# bad

foo.zero?
foo.negative?
bar.baz.positive?

# good

foo == 0
0 > foo
bar.baz > 0

Line is too long. [95/80]
Open

        if !is_on_square?(x, y) && valid_move?(x, y) && !game.possible_check?(self.color, x, y)
Severity: Minor
Found in app/models/king.rb by rubocop

Trailing whitespace detected.
Open

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

Redundant self detected.
Open

    opposite_color = "White" if self.color == "Black"
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

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

    opposite_color = "Black" if self.color == "White"
Severity: Minor
Found in app/models/pawn.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"

Use 2 (not 1) spaces for indentation.
Open

      CheckMate.new(self, color).call
Severity: Minor
Found in app/models/game.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

Inconsistent indentation detected.
Open

  def icon
    # if color == "White"
    #   '&#9816;'
    # else
    #   '&#9822;'
Severity: Minor
Found in app/models/knight.rb by rubocop

This cops checks for inconsistent indentation.

Example:

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

Trailing whitespace detected.
Open

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

Line is too long. [104/80]
Open

      (pawn_move_vertical?(to_x, to_y) && vertical_move_only?(to_x, to_y)) || can_enpassant?(to_x, to_y)
Severity: Minor
Found in app/models/pawn.rb by rubocop

Line is too long. [97/80]
Open

    @opponent_pawn = game.pieces.find_by(x_pos: x, y_pos: y, name: "Pawn", color: opposite_color)
Severity: Minor
Found in app/models/pawn.rb by rubocop

%w-literals should be delimited by [ and ].
Open

    %w(King Queen Bishop Knight Rook Pawn)
Severity: Minor
Found in app/models/piece.rb by rubocop

This cop enforces the consistent usage of %-literal delimiters.

Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.

Example:

# Style/PercentLiteralDelimiters:
#   PreferredDelimiters:
#     default: '[]'
#     '%i':    '()'

# good
%w[alpha beta] + %i(gamma delta)

# bad
%W(alpha #{beta})

# bad
%I(alpha beta)

Redundant self detected.
Open

    self.transaction do
Severity: Minor
Found in app/models/piece.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

Space missing after comma.
Open

      user.password = Devise.friendly_token[0,20]
Severity: Minor
Found in app/models/user.rb by rubocop

Checks for comma (,) not followed by some kind of space.

Example:

# bad
[1,2]
{ foo:bar,}

# good
[1, 2]
{ foo:bar, }

Trailing whitespace detected.
Open

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

Trailing whitespace detected.
Open

  end  
Severity
Category
Status
Source
Language