setokinto/slack-shogi

View on GitHub

Showing 40 of 76 total issues

Function parse has a Cognitive Complexity of 146 (exceeds 5 allowed). Consider refactoring.
Open

    def parse(input_str, shogi):
        """
        parse input text and get (from, to) Coordinate.
        """
        is_first_turn = shogi.first
Severity: Minor
Found in app/modules/parse_input.py - About 2 days 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 movable has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

    def movable(self, from_x, from_y, to_x, to_y, promote):
        board = self.board
        from_koma = board[from_y][from_x]
        to_koma = board[to_y][to_x]

Severity: Minor
Found in app/modules/shogi.py - About 6 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 droppable has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

    def droppable(self, koma, to_x, to_y):
        if self.first:
            tegoma = self.first_tegoma
        else:
            tegoma = self.second_tegoma
Severity: Minor
Found in app/modules/shogi.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 shogi.py has 321 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from enum import IntEnum


class Koma(IntEnum):
    empty = 0
Severity: Minor
Found in app/modules/shogi.py - About 3 hrs to fix

    Function make_board_info_text has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    def make_board_info_text(board_info, reverse=False):
        return_text = ""
        x_labels = [1, 2, 3, 4, 5, 6, 7, 8, 9]
        y_labels = [9, 8, 7, 6, 5, 4, 3, 2, 1]
    
    
    Severity: Minor
    Found in app/modules/shogi_output.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 make_user_text has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def make_user_text(user_name, motigoma,
                       is_first=True, is_turn=True, reverse=False):
        return_text = ""
        if is_turn:
            return_text = "[手番]"
    Severity: Minor
    Found in app/modules/shogi_output.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 koma_move has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def koma_move(channel, message, position, dou, koma, sub_position=None, promote=None):
    Severity: Major
    Found in app/shogi.py - About 50 mins to fix

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

          def checkObstacle(self, from_x, from_y, to_x, to_y):
              if self.board[from_y][from_x].is_keima():
                  return True
              while True:
                  to_x = _approach(from_x, to_x)
      Severity: Minor
      Found in app/modules/shogi.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 add has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def add(self, from_x, from_y, to_x, to_y, promote, koma):
      Severity: Minor
      Found in app/kifu.py - About 45 mins to fix

        Consider simplifying this complex logical expression.
        Open

                            if (turn and t[0] < to_x and t[1] < to_y) or \
                               (not turn and t[0] > to_x and t[1] > to_y):
                                from_x, from_y = t
                                from_flag = 0
                                break
        Severity: Major
        Found in app/modules/parse_input.py - About 40 mins to fix

          Consider simplifying this complex logical expression.
          Open

                              if (turn and t[0] > to_x and t[1] < to_y) or \
                                 (not turn and t[0] < to_x and t[1] > to_y):
                                  from_x, from_y = t
                                  from_flag = 0
                                  break
          Severity: Major
          Found in app/modules/parse_input.py - About 40 mins to fix

            Consider simplifying this complex logical expression.
            Open

                                if (turn and t[0] < to_x and t[1] > to_y) or \
                                   (not turn and t[0] > to_x and t[1] < to_y):
                                    from_x, from_y = t
                                    from_flag = 0
                                    break
            Severity: Major
            Found in app/modules/parse_input.py - About 40 mins to fix

              Consider simplifying this complex logical expression.
              Open

                                  if (turn and t[0] > to_x and t[1] > to_y) or \
                                     (not turn and t[0] < to_x and t[1] < to_y):
                                      from_x, from_y = t
                                      from_flag = 0
                                      break
              Severity: Major
              Found in app/modules/parse_input.py - About 40 mins to fix

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

                    def basic_move(channel_id, from_x, from_y, to_x, to_y, promote):
                Severity: Minor
                Found in app/modules/shogi_input.py - About 35 mins to fix

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

                      def move(self, from_x, from_y, to_x, to_y, promote):
                  Severity: Minor
                  Found in app/modules/shogi_input.py - About 35 mins to fix

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

                    def make_user_text(user_name, motigoma,
                    Severity: Minor
                    Found in app/modules/shogi_output.py - About 35 mins to fix

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

                          def move(self, from_x, from_y, to_x, to_y, promote):
                      Severity: Minor
                      Found in app/modules/shogi.py - About 35 mins to fix

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

                            def movable(self, from_x, from_y, to_x, to_y, promote):
                        Severity: Minor
                        Found in app/modules/shogi.py - About 35 mins to fix

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

                          def input_emojis(id_, password, team_id, two_factor, force_update=False):
                          Severity: Minor
                          Found in input_emojis/input_emojis.py - About 35 mins to fix

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

                                def movable(self, from_x, from_y, to_x, to_y, promote):
                            Severity: Minor
                            Found in app/modules/shogi_input.py - About 35 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language