TheCorrespondingSquares/chess-app

View on GitHub

Showing 927 of 927 total issues

Method new_with_session has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.new_with_session(params, session)
    super.tap do |user|
      if data = session["devise.facebook_data"] && session["devise.facebook_data"]["extra"]["raw_info"]
        user.email = data["email"] if user.email.blank?
      end
Severity: Minor
Found in app/models/user.rb - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method pawn_first_move? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def pawn_first_move?(to_y)
    if is_white?
      self.y_pos == 1 ? to_y < 4 : vertical_move_one_square?(to_y)
    else
      self.y_pos == 6 ? to_y > 3 : vertical_move_one_square?(to_y)
Severity: Minor
Found in app/models/pawn.rb - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Trailing whitespace detected.
Open

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

Trailing whitespace detected.
Open

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

Redundant self detected.
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

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

Final newline missing.
Open

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

Use normalcase for variable numbers.
Open

    y_down_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

Redundant return detected.
Open

    return opponent_pawn_exists?(x, y)
Severity: Minor
Found in app/models/pawn.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.

Rename is_black? to black?.
Open

  def is_black?
Severity: Minor
Found in app/models/piece.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

Line is too long. [85/80]
Open

    destination_x: #{destination_x.inspect}, destination_y: #{destination_y.inspect}"
Severity: Minor
Found in app/models/concerns/obstructions.rb by rubocop

Extra empty line detected at class body end.
Open


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

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

Example: EnforcedStyle: empty_lines

# good

class Foo

  def bar
    # ...
  end

end

Example: EnforcedStyle: emptylinesexcept_namespace

# good

class Foo
  class Bar

    # ...

  end
end

Example: EnforcedStyle: emptylinesspecial

# good
class Foo

  def bar; end

end

Example: EnforcedStyle: noemptylines (default)

# good

class Foo
  def bar
    # ...
  end
end

Inconsistent indentation detected.
Open

  def knight_move_wide?(to_x, to_y)
    (starting_point_x - to_x).abs == 2 && (starting_point_y - to_y).abs == 1
  end
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

Space inside parentheses detected.
Open

      ((y_pos - 1 )..(y_pos + 1)).each do |y|
Severity: Minor
Found in app/models/king.rb by rubocop

Checks for spaces inside ordinary round parentheses.

Example:

# bad
f( 3)
g = (a + 3 )

# good
f(3)
g = (a + 3)

Trailing whitespace detected.
Open

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

Line is too long. [96/80]
Open

    starting_point_x: #{starting_point_x.inspect}, starting_point_y: #{starting_point_y.inspect}
Severity: Minor
Found in app/models/concerns/obstructions.rb by rubocop

Line is too long. [105/80]
Open

    if starting_point_y == destination_y                    # If y doesn't change, movement is horizontal
Severity: Minor
Found in app/models/concerns/obstructions.rb by rubocop

Missing space after #.
Open

  #makes sure both present to start game
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

Missing space after #.
Open

  #for later use to attach pawn-promotion to UI
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

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

Line is too long. [88/80]
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
Severity
Category
Status
Source
Language