LordDarkula/chess_py

View on GitHub

Showing 71 of 71 total issues

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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              if self._file is None:
                  file_str = ""
              else:
                  file_str = chr(self._file + 97)
      Severity: Minor
      Found in chess_py/core/algebraic/location.py and 1 other location - About 45 mins to fix
      chess_py/core/algebraic/location.py on lines 118..121

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 35.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  if self._rank is None:
                      rank_str = ""
                  else:
                      rank_str = str(self._rank + 1)
          Severity: Minor
          Found in chess_py/core/algebraic/location.py and 1 other location - About 45 mins to fix
          chess_py/core/algebraic/location.py on lines 123..126

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 35.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          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

            Function __eq__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def __eq__(self, other):
                    if not isinstance(other, self.__class__):
                        raise TypeError("Cannot compare other type to Board")
            
                    for i, row in enumerate(self.position):
            Severity: Minor
            Found in chess_py/core/board.py - About 35 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 moves_in_direction has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def moves_in_direction(self, direction, position):
                    """
                    Finds moves in a given direction
            
                    :type: direction: lambda
            Severity: Minor
            Found in chess_py/pieces/rook.py - About 35 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 _one_diagonal_capture_square has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def _one_diagonal_capture_square(self, capture_square, position):
                    """
                    Adds specified diagonal as a capture move if it is one
                    """
                    if self.contains_opposite_color_piece(capture_square, position):
            Severity: Minor
            Found in chess_py/pieces/pawn.py - About 35 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 __str__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def __str__(self):
                    board_string = ""
                    for i, row in enumerate(self.position):
                        board_string += str(8 - i) + " "
                        for j, square in enumerate(row):
            Severity: Minor
            Found in chess_py/core/board.py - About 35 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 make_legal has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            def make_legal(move, position):
                """
                Converts an incomplete move (initial ``Location`` not specified)
                and the corresponding position into the a complete move
                with the most likely starting point specified. If no moves match, ``None``
            Severity: Minor
            Found in chess_py/core/algebraic/converter.py - About 35 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 too many return statements within this function.
            Open

                        return Move(end_loc=end_location,
            Severity: Major
            Found in chess_py/core/algebraic/converter.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return 0
              Severity: Major
              Found in chess_py/pieces/piece_const.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return Move(end_loc=end_location,
                Severity: Major
                Found in chess_py/core/algebraic/converter.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return Move(end_loc=promote_capture_end_loc,
                  Severity: Major
                  Found in chess_py/core/algebraic/converter.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                    return Move(end_loc=end_location,
                    Severity: Major
                    Found in chess_py/core/algebraic/converter.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                  return Move(end_loc=promote_end_loc,
                      Severity: Major
                      Found in chess_py/core/algebraic/converter.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                                return Move(end_loc=end_location,
                        Severity: Major
                        Found in chess_py/core/algebraic/converter.py - About 30 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language