TheCorrespondingSquares/chess-app

View on GitHub

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
Severity: Minor
Found in app/controllers/pieces_controller.rb - About 3 hrs to fix

    Class Pawn has 22 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Pawn < Piece
    
      def icon
        '&#9823;'
      end
    Severity: Minor
    Found in app/models/pawn.rb - About 2 hrs to fix

      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');
      Severity: Minor
      Found in app/assets/javascripts/games.js - About 1 hr to fix

        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)
        Severity: Minor
        Found in app/controllers/pieces_controller.rb - About 1 hr 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 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)
        Severity: Minor
        Found in app/models/king.rb - About 1 hr 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 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)
        Severity: Minor
        Found in app/controllers/pieces_controller.rb - About 1 hr to fix

          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
          Severity: Minor
          Found in app/services/check_mate.rb - About 55 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

          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

          Severity
          Category
          Status
          Source
          Language