LordDarkula/chess_py

View on GitHub
chess_py/pieces/king.py

Summary

Maintainability
B
5 hrs
Test Coverage

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

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 loc_adjacent_to_opponent_king has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def loc_adjacent_to_opponent_king(self, location, position):
            """
            Finds if 2 kings are touching given the position of one of the kings.
    
            :type: location: Location
    Severity: Minor
    Found in chess_py/pieces/king.py - 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

    There are no issues that match your filters.

    Category
    Status