mfinzi/OMGchess

View on GitHub

Showing 24 of 52 total issues

Avoid too many return statements within this function.
Open

        return False
Severity: Major
Found in connect4.py - About 30 mins to fix

    Function _make_layer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def _make_layer(self, block, planes, blocks, stride=1, dilation=1,
                        new_level=True, residual=True):
            assert dilation == 1 or dilation % 2 == 0
            downsample = None
            if stride != 1 or self.inplanes != planes * block.expansion:
    Severity: Minor
    Found in chess/drn.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

    Function update_path has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def update_path(self,board):
            color = board.color_to_move()
            
            # leaf node, either terminal or unvisited
            if len(self.children)==0:
    Severity: Minor
    Found in mcts.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

    Function sample_kfen_history has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def sample_kfen_history(game,k=4):
        num_moves = len([0 for _ in game.mainline()])
        if num_moves <=1: raise StopIteration("Not enough moves in the pgn")
        sampled_move_id = np.random.randint(num_moves-1)#exclude checkmates
        start_board_fen = chess.Board().fen()
    Severity: Minor
    Found in chess/create_dataset.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

    Severity
    Category
    Status
    Source
    Language