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
- Read upRead up
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)
- Read upRead up
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
- Exclude checks
Trailing whitespace detected. Open
piece.transaction do
- Exclude checks
Redundant self
detected. Open
Pawn.create(color: 'White', game_id: self.id, x_pos: i, y_pos: 1, icon: "♙")
- Read upRead up
- Exclude checks
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
- Exclude checks
Use normalcase for variable numbers. Open
y_down_1 = @opponent_pawn.y_pos - 1
- Read upRead up
- Exclude checks
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)
- Read upRead up
- Exclude checks
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?
- Read upRead up
- Exclude checks
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}"
- Exclude checks
Extra empty line detected at class body end. Open
end
- Read upRead up
- Exclude checks
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
- Read upRead up
- Exclude checks
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|
- Read upRead up
- Exclude checks
Checks for spaces inside ordinary round parentheses.
Example:
# bad
f( 3)
g = (a + 3 )
# good
f(3)
g = (a + 3)
Trailing whitespace detected. Open
- Exclude checks
Line is too long. [96/80] Open
starting_point_x: #{starting_point_x.inspect}, starting_point_y: #{starting_point_y.inspect}
- Exclude checks
Line is too long. [105/80] Open
if starting_point_y == destination_y # If y doesn't change, movement is horizontal
- Exclude checks
Missing space after #
. Open
#makes sure both present to start game
- Read upRead up
- Exclude checks
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
- Read upRead up
- Exclude checks
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
- Exclude checks
Line is too long. [88/80] Open
Pawn.create(color: 'White', game_id: self.id, x_pos: i, y_pos: 1, icon: "♙")
- Exclude checks