Konano/arknights-mower

View on GitHub

Showing 944 of 1,043 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    elif x['type'] == 0:
        zone[x['retroId']] = {
            'type': 'SIDESTORY',
            'name': x['name'],
            'chapterIndex': None,
Severity: Major
Found in data_update.py and 1 other location - About 1 hr to fix
data_update.py on lines 99..104

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 39.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    if x['type'] == 1:
        zone[x['retroId']] = {
            'type': 'BRANCHLINE',
            'name': x['name'],
            'chapterIndex': None,
Severity: Major
Found in data_update.py and 1 other location - About 1 hr to fix
data_update.py on lines 106..111

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 39.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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
                          Severity
                          Category
                          Status
                          Source
                          Language