TheCorrespondingSquares/chess-app

View on GitHub
app/models/concerns/obstructions.rb

Summary

Maintainability
A
0 mins
Test Coverage

Assignment Branch Condition size for is_obstructed? is too high. [17.26/15]
Open

  def is_obstructed?(destination_x, destination_y)
    # Knights can't be obstructed
    return false if self.name == "Knight"

    logger.info "is_obstructed called:
Severity: Minor
Found in app/models/concerns/obstructions.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method has too many lines. [11/10]
Open

  def is_obstructed?(destination_x, destination_y)
    # Knights can't be obstructed
    return false if self.name == "Knight"

    logger.info "is_obstructed called:
Severity: Minor
Found in app/models/concerns/obstructions.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

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

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

Redundant return detected.
Open

    return false
Severity: Minor
Found in app/models/concerns/obstructions.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.

Line is too long. [103/80]
Open

    elsif starting_point_x == destination_x                 # If x doesn't change, movement is vertical
Severity: Minor
Found in app/models/concerns/obstructions.rb by rubocop

Line is too long. [101/80]
Open

    else                                                    # If x and y change, movement is diagonal
Severity: Minor
Found in app/models/concerns/obstructions.rb by rubocop

Redundant return detected.
Open

    return false
Severity: Minor
Found in app/models/concerns/obstructions.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.

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

Extra empty line detected at module body beginning.
Open


  # Check for obstructions
Severity: Minor
Found in app/models/concerns/obstructions.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

Redundant self detected.
Open

    return false if self.name == "Knight"
Severity: Minor
Found in app/models/concerns/obstructions.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

    return false if self.name == "Knight"
Severity: Minor
Found in app/models/concerns/obstructions.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"

Redundant return detected.
Open

    return false
Severity: Minor
Found in app/models/concerns/obstructions.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.

Extra empty line detected at module body end.
Open


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

Missing top-level module documentation comment.
Open

module Obstructions
Severity: Minor
Found in app/models/concerns/obstructions.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/concerns/obstructions.rb by rubocop

There are no issues that match your filters.

Category
Status