LordDarkula/chess_py

View on GitHub

Showing 43 of 71 total issues

Function incomplete_alg has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
Open

def incomplete_alg(alg_str, input_color, position):
    """
    Converts a string written in short algebraic form into an incomplete move.
    These incomplete moves do not have the initial location specified and
    therefore cannot be used to update the board. IN order to fully utilize
Severity: Minor
Found in chess_py/core/algebraic/converter.py - About 7 hrs 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

File board.py has 313 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-

"""
Constructs board object which stores the get_location of all the pieces.

Severity: Minor
Found in chess_py/core/board.py - About 3 hrs to fix

    File converter.py has 309 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # -*- coding: utf-8 -*-
    
    """
    Methods that take external input and attempt
    to turn them into usable commands.
    Severity: Minor
    Found in chess_py/core/algebraic/converter.py - About 3 hrs to fix

      Function in_check has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          def in_check(self, position, location=None):
              """
              Finds if the king is in check or if both kings are touching.
      
              :type: position: Board
      Severity: Minor
      Found in chess_py/pieces/king.py - About 3 hrs 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

      Board has 26 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Board:
          """
          Standard starting position in a chess game.
          Initialized upon startup and is used when init_default constructor is used
      
      
      Severity: Minor
      Found in chess_py/core/board.py - About 3 hrs to fix

        Function _get_piece_start_location has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

        def _get_piece_start_location(end_location,
                                      input_color,
                                      piece_in_move,
                                      position,
                                      start_rank=None,
        Severity: Minor
        Found in chess_py/core/algebraic/converter.py - About 2 hrs 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

        Function _calc_all_possible_moves has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            def _calc_all_possible_moves(self, input_color):
                """
                Returns list of all possible moves
        
                :type: input_color: Color
        Severity: Minor
        Found in chess_py/core/board.py - About 2 hrs 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

        Location has 22 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Location:
            def __init__(self, rank, file):
                """
                Creates a location on a chessboard given x and y coordinates.
        
        
        Severity: Minor
        Found in chess_py/core/algebraic/location.py - About 2 hrs to fix

          Function update has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              def update(self, move):
                  """
                  Updates position by applying selected move
          
                  :type: move: Move
          Severity: Minor
          Found in chess_py/core/board.py - About 2 hrs 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

          Function no_moves has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def no_moves(self, input_color):
          
                  # Loops through columns
                  for piece in self:
          
          
          Severity: Minor
          Found in chess_py/core/board.py - 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

          Function possible_moves has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def possible_moves(self, position):
                  """
                  Finds all possible knight moves
                  :type: position Board
                  :rtype: list
          Severity: Minor
          Found in chess_py/pieces/knight.py - 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

          Function forward_moves has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def forward_moves(self, position):
                  """
                  Finds possible moves one step and two steps in front
                  of Pawn.
          
          
          Severity: Minor
          Found in chess_py/pieces/pawn.py - 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

          Function val has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def val(self, piece, ref_color):
                  """
                  Finds value of ``Piece``
          
                  :type: piece: Piece
          Severity: Minor
          Found in chess_py/pieces/piece_const.py - 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

          Function play has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def play(self):
                  """
                  Starts game and returns one of 3 results . 
                  Iterates between methods ``white_move()`` and
                  ``black_move()`` until game ends. Each
          Severity: Minor
          Found in chess_py/game/game.py - About 45 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

          Function _get_piece_start_location has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def _get_piece_start_location(end_location,
          Severity: Minor
          Found in chess_py/core/algebraic/converter.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if type(en_passant_pawn) is Pawn and \
                                        en_passant_pawn.color != input_color and \
                                        position.is_square_empty(end_location):
                                    return Move(end_loc=end_location,
                                                piece=position.piece_at_square(pawn_location),
            Severity: Major
            Found in chess_py/core/algebraic/converter.py - About 45 mins to fix

              Function init_manual has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def init_manual(cls, pawn_value, knight_value, bishop_value, rook_value, queen_value, king_value):
              Severity: Minor
              Found in chess_py/pieces/piece_const.py - About 45 mins to fix

                Function add_castle has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def add_castle(self, position):
                        """
                        Adds kingside and queenside castling moves if legal
                
                        :type: position: Board
                Severity: Minor
                Found in chess_py/pieces/king.py - About 45 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

                Avoid deeply nested control flow statements.
                Open

                                        if move.end_loc == location:
                                            return True
                                else:
                Severity: Major
                Found in chess_py/pieces/king.py - About 45 mins to fix

                  Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def __init__(self,
                  Severity: Minor
                  Found in chess_py/core/algebraic/move.py - About 35 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language