Konano/arknights-mower

View on GitHub

Showing 99 of 1,043 total issues

Function __set_lib_properties has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def __set_lib_properties():
        Asst.__lib.AsstSetUserDir.restype = ctypes.c_bool
        Asst.__lib.AsstSetUserDir.argtypes = (
            ctypes.c_char_p,)

Severity: Minor
Found in arknights_mower/utils/asst.py - About 1 hr to fix

    Function swipe has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def swipe(self, points: list[tuple[int, int]], display_frames: tuple[int, int, int], pressure: int = 100, duration: Union[list[int], int] = None, up_wait: int = 0, part: int = 10, fall: bool = True, lift: bool = True) -> None:
    Severity: Major
    Found in arknights_mower/utils/device/minitouch/core.py - About 1 hr to fix

      Function swipe has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def swipe(self, x0, y0, x1, y1, move_duraion: float = 1, hold_before_release: float = 0, fall: bool = True, lift: bool = True):
      Severity: Major
      Found in arknights_mower/utils/device/scrcpy/core.py - About 1 hr to fix

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

            def swipe(self, x0, y0, x1, y1, move_duraion: float = 1, hold_before_release: float = 0, fall: bool = True, lift: bool = True):
                frame_time = 1 / 60
        
                start_time = time.perf_counter()
                end_time = start_time + move_duraion
        Severity: Minor
        Found in arknights_mower/utils/device/scrcpy/core.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 clear_clue_mask has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def clear_clue_mask(self) -> None:
                """ 清空界面内被选中的线索 """
                try:
                    while True:
                        mask = False
        Severity: Minor
        Found in arknights_mower/solvers/base_schedule.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 base has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        def base(img: tp.Image, central: tp.Scope, draw: bool = False) -> dict[ str, tp.Rectangle ]:
            """
            基建布局的图像分割算法
            """
            try:
        Severity: Minor
        Found in arknights_mower/utils/segment.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 read_screen has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def read_screen(img, type="mood", langurage="eng", limit=24, cord=None, change_color=False, draw=False) -> int:
        Severity: Major
        Found in arknights_mower/utils/segment.py - About 50 mins to fix

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

              def __swipe(self, points: list[tuple[int, int]], display_frames: tuple[int, int, int], pressure: int = 100, duration: Union[list[int], int] = None, up_wait: int = 0, fall: bool = True, lift: bool = True) -> None:
          Severity: Major
          Found in arknights_mower/utils/device/minitouch/core.py - About 50 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                        while self.scene() not in [Scene.INFRA_ARRANGE, Scene.INFRA_MAIN] and self.scene() // 100 != 1:
                                            pre_scene = self.scene()
                                            self.back(interval=3)
                                            if self.scene() == pre_scene:
                                                break
            Severity: Major
            Found in arknights_mower/solvers/base_construct.py - About 45 mins to fix

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

                      def swipe_ext(self, points: list[tuple[int, int]], durations: list[int], up_wait: int) -> None:
                          if self.minitouch:
                              self.minitouch.swipe(
                                  points, self.device.display_frames(), duration=durations, up_wait=up_wait)
                          elif self.scrcpy:
              Severity: Minor
              Found in arknights_mower/utils/device/device.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 name in agent_name & agent:
                                          self.tap((y[1][0]), interval=0, rebuild=False)
                                          agent.remove(name)
                                  # for name in agent_name & agent:
                                  #     for y in ret:
              Severity: Major
              Found in arknights_mower/solvers/base_construct.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if _room not in result.keys():
                                            result[_room] = ['Current'] * len(self.currentPlan[_room])
                                        result[_room][self.operators[_item_name]['index']] = _item_name
                Severity: Major
                Found in arknights_mower/solvers/base_schedule.py - About 45 mins to fix

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

                      def __swipe(self, points: list[tuple[int, int]], display_frames: tuple[int, int, int], pressure: int = 100, duration: Union[list[int], int] = None, up_wait: int = 0, fall: bool = True, lift: bool = True) -> None:
                          """
                          swipe between points one by one, with pressure and duration
                  
                          :param points: list, look like [(x1, y1), (x2, y2), ...]
                  Severity: Minor
                  Found in arknights_mower/utils/device/minitouch/core.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 self.scene() != Scene.INFRA_ARRANGE:
                                                  raise e
                                              continue
                  Severity: Major
                  Found in arknights_mower/solvers/base_construct.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if self.scene() == Scene.INFRA_ARRANGE_CONFIRM:
                                                x = self.recog.w // 3 * 2  # double confirm
                                                y = self.recog.h - 10
                                                self.tap((x, y), rebuild=True)
                                            finished = True
                    Severity: Major
                    Found in arknights_mower/solvers/base_construct.py - About 45 mins to fix

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

                          def read_time(self, cord, upperlimit, error_count=0):
                              # 刷新图片
                              self.recog.update()
                              time_str = segment.read_screen(self.recog.img, type='time', cord=cord)
                              logger.debug(str(time_str))
                      Severity: Minor
                      Found in arknights_mower/solvers/base_schedule.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

                                                  for current_idx, _name in enumerate(plan[room]):
                                                      if _name == 'Current':
                                                          current_name = self.current_base[room][current_idx]["agent"]
                                                          if current_name in agent_list:
                                                              plan[room][current_idx] = current_name
                      Severity: Major
                      Found in arknights_mower/solvers/base_schedule.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if len(agent) == 0:
                                                    break
                                                # 否则滑动到最左边
                                                self.sleep(interval=0.5, rebuild=False)
                        Severity: Major
                        Found in arknights_mower/solvers/base_construct.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  while self.scene() == Scene.CONNECTING:
                                                      self.sleep(3)
                                          idx += 1
                          Severity: Major
                          Found in arknights_mower/solvers/base_construct.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                    if x[0] not in agent and x[0] not in exclude:
                                                        # 不选择已进驻的干员,如果非宿舍则进一步不选择精神涣散的干员
                                                        if not (self.find('agent_on_shift', scope=(status_coord[0], status_coord[2]))
                                                                or self.find('agent_resting', scope=(status_coord[0], status_coord[2]))
                                                                or self.find('agent_in_dormitory', scope=(room_coord[0], room_coord[2]))
                            Severity: Major
                            Found in arknights_mower/solvers/base_construct.py - About 45 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language