mfinzi/OMGchess

View on GitHub

Showing 24 of 52 total issues

Function main has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

def main():
    board = chess.Board()
    agent = 
    forced = False
    color = WHITE
Severity: Minor
Found in chess/uci.py - About 5 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 drn.py has 320 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import pdb

import torch.nn as nn
import math
import torch.utils.model_zoo as model_zoo
Severity: Minor
Found in chess/drn.py - About 3 hrs to fix

    Function __init__ has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(self, block, layers, num_classes=1000,
                     channels=(16, 32, 64, 128, 256, 512, 512, 512),
                     out_map=False, out_middle=False, pool_size=28, arch='D'):
            super(DRN, self).__init__()
            self.inplanes = channels[0]
    Severity: Minor
    Found in chess/drn.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 move_won has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def move_won(self,i):
            j,i = self.col_length[i]-1,i
            color = self.array[j,i]
            if color==0:
                return False
    Severity: Minor
    Found in quarto.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 move_won has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def move_won(self,i):
            j,i = self.col_length[i]-1,i
            color = self.array[j,i]
            if color==0:
                return False
    Severity: Minor
    Found in connect4.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 work has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def work(self):
            while True:
                if not self.empty():
                    mb_boards = []
                    ids = []
    Severity: Minor
    Found in chess/aMCTS.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 get_moves has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_moves(self):
            moves = []
            if not self.num_moves_made%2: 
                for i in range(16): # Placement turn
                    if not self.array[i//4,i%4]:
    Severity: Minor
    Found in quarto.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 __call__ has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def __call__(self,pgns):
            out = []
            for pgn in pgns:
                try:
                    game = chess.pgn.read_game(io.StringIO(pgn))
    Severity: Minor
    Found in chess/create_dataset.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 __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, block, layers, num_classes=1000,
    Severity: Major
    Found in chess/drn.py - About 1 hr to fix

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

          def forward(self, x):
              y = list()
      
              if self.arch == 'C':
                  x = self.conv1(x)
      Severity: Minor
      Found in chess/drn.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 __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self,hidden_dim,vocab_size,num_blocks,inner_dim,num_heads=4,embed_dim=16,dropout=0):
      Severity: Major
      Found in chess/transformer.py - About 50 mins to fix

        Function _make_layer has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def _make_layer(self, block, planes, blocks, stride=1, dilation=1,
        Severity: Major
        Found in chess/drn.py - About 50 mins to fix

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

          def fen2tensor(fen_string):
              board_array = np.zeros((18,8,8))
              brd,color,castling,enps,hc,mvnum = fen_string.split(' ')
              # Encode p1 and p2 pieces,
              piece2plane = {'PRNBQKprnbqk'[i]:i for i in range(12)}
          Severity: Minor
          Found in chess/chess_dataset.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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(self, inplanes, planes, stride=1, downsample=None,
          Severity: Minor
          Found in chess/drn.py - About 45 mins to fix

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

                def __init__(self, inplanes, planes, stride=1, downsample=None,
            Severity: Minor
            Found in chess/drn.py - About 45 mins to fix

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

              def conv3x3(in_planes, out_planes, stride=1, padding=1, dilation=1):
              Severity: Minor
              Found in chess/drn.py - About 35 mins to fix

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

                    def __init__(self,GameType,network,movetime=1,bs=12,num_threads=30):
                Severity: Minor
                Found in chess/aMCTS.py - About 35 mins to fix

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

                      def __init__(self,hidden_dim,inner_dim,num_heads=4,dropout=0,rel_pos=True):
                  Severity: Minor
                  Found in chess/transformer.py - About 35 mins to fix

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

                        def _make_layer(self, block, planes, blocks, stride=1, dilation=1):
                    Severity: Minor
                    Found in chess/drn.py - About 35 mins to fix

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

                          def __init__(self,M=5,N=15,k=24,drop_rate=0,coords=True):
                      Severity: Minor
                      Found in chess/chess_network.py - About 35 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language