Showing 9 of 927 total issues
Class PiecesController
has 27 methods (exceeds 20 allowed). Consider refactoring. Open
class PiecesController < ApplicationController
before_action :require_game_player, only: [:update, :create, :destroy]
def show
render json: current_piece
Class Pawn
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class Pawn < Piece
def icon
'♟'
end
Function handlePieceDrop
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
function handlePieceDrop( event, ui ) {
var $this = $(this);
var xPos = $this.data('xPos');
var yPos = $this.data('yPos');
destinationPieceId = $this.children().data('pieceId');
Method move_if_possible
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def move_if_possible
piece = current_piece
if !@game.game_full?
redirect_to game_path(piece.game)
elsif piece.valid_move?(@new_x_pos, @new_y_pos)
- 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 is_able_to_escape_check?
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. 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)
- 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 move_if_possible
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def move_if_possible
piece = current_piece
if !@game.game_full?
redirect_to game_path(piece.game)
elsif piece.valid_move?(@new_x_pos, @new_y_pos)
Method king_can_be_blocked?
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def king_can_be_blocked?
obstruction_path = []
starting_x = @piece_making_check.x_pos
starting_y = @piece_making_check.y_pos
- 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
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"