itsVale/Vale.py

View on GitHub
cogs/games/checkers.py

Summary

Maintainability
B
5 hrs
Test Coverage

Function jumps_from has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    def jumps_from(self, square):
        """Generates all jumps from a particular square in the current position."""

        board = self._board
        captures = _CAPTURES[board[square]]
Severity: Minor
Found in cogs/games/checkers.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 move has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def move(self, move):
        """Takes a move and apply it to the game."""

        if move not in self.legal_moves():
            raise ValueError(f'illegal move: {move!r}')
Severity: Minor
Found in cogs/games/checkers.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 legal_moves has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def legal_moves(self):
        """Generates all legal moves in the current position.

        If there are any jumps one could make, those get generated instead,
        as jumps must be made according to the rules of Checkers.
Severity: Minor
Found in cogs/games/checkers.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 6 (exceeds 5 allowed). Consider refactoring.
Open

    def __str__(self):
        rows = list(self._tiles())
        if self._last_move:
            last_move_tile = self.TILES[['WH_LAST_MOVE', 'BK_LAST_MOVE'][self.turn]]
            if last_move_tile:
Severity: Minor
Found in cogs/games/checkers.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