Konano/arknights-mower

View on GitHub
arknights_mower/solvers/operation.py

Summary

Maintainability
A
3 hrs
Test Coverage

File operation.py has 430 lines of code (exceeds 250 allowed). Consider refactoring.
Wontfix

from __future__ import annotations

import time
import traceback

Severity: Minor
Found in arknights_mower/solvers/operation.py - About 6 hrs to fix

    Function choose_zone_theme has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Wontfix

        def choose_zone_theme(self, zone: list, scope: tp.Scope) -> None:
            """ 识别主题曲区域 """
            # 定位 Chapter 编号
            ocr = []
            act_id = 999
    Severity: Minor
    Found in arknights_mower/solvers/operation.py - About 4 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 choose_zone_supple has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Wontfix

        def choose_zone_supple(self, zone: list, scope: tp.Scope) -> None:
            """ 识别别传/插曲区域 """
            try_times = 5
            zoneIndex = {}
            for x in zone_list.values():
    Severity: Minor
    Found in arknights_mower/solvers/operation.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 transition has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Wontfix

        def transition(self) -> bool:
            # 选择剩余次数不为 0 的任务
            while len(self.plan) > 0 and self.plan[0][1] == 0:
                self.switch_plan()
            # 如果任务列表为空则退出
    Severity: Minor
    Found in arknights_mower/solvers/operation.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 choose_level has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Wontfix

        def choose_level(self, level: str) -> None:
            """ 在终端主界面选择关卡 """
            if level == 'pre_ope':
                logger.info(f'前往上一次关卡')
                self.tap_element('terminal_pre')
    Severity: Minor
    Found in arknights_mower/solvers/operation.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 choose_zone_resource has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Wontfix

        def choose_zone_resource(self, zone: list) -> None:
            """ 识别资源收集区域 """
            ocr = ocrhandle.predict(self.recog.img)
            unable = list(filter(lambda x: x[1] in ['不可进入', '本日16:00开启'], ocr))
            ocr = list(filter(lambda x: x[1] in weekly_zones, ocr))
    Severity: Minor
    Found in arknights_mower/solvers/operation.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 run has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Wontfix

        def run(self, level: str = None, times: int = -1, potion: int = 0, originite: int = 0, eliminate: int = 0, plan: list = None):
            """
            :param level: str, 指定关卡,默认为前往上一次关卡或当前界面关卡
            :param times: int, 作战的次数上限,-1 为无限制,默认为 -1
            :param potion: int, 使用药剂恢复体力的次数上限,-1 为无限制,默认为 0
    Severity: Minor
    Found in arknights_mower/solvers/operation.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 operator_before_elimi has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Wontfix

        def operator_before_elimi(self) -> bool:
            # 如果每周剿灭完成情况未知,退回到终端主界面选择关卡
            if self.eliminate_state == 0:
                self.get_navigation()
                self.tap_element('nav_terminal')
    Severity: Minor
    Found in arknights_mower/solvers/operation.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 operator_before has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Wontfix

        def operator_before(self) -> bool:
            # 关卡未选定,退回到终端主界面选择关卡
            if not self.level_choosed:
                self.get_navigation()
                self.tap_element('nav_terminal')
    Severity: Minor
    Found in arknights_mower/solvers/operation.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 run has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Wontfix

        def run(self, level: str = None, times: int = -1, potion: int = 0, originite: int = 0, eliminate: int = 0, plan: list = None):
    Severity: Minor
    Found in arknights_mower/solvers/operation.py - About 45 mins to fix

      Function terminal_main has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def terminal_main(self) -> bool:
              if self.eliminate_state != 3:
                  eliminate_todo = self.find('terminal_eliminate')
                  # 检查每周剿灭完成情况
                  if eliminate_todo is not None:
      Severity: Minor
      Found in arknights_mower/solvers/operation.py - About 35 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 ope_ongoing has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Wontfix

          def ope_ongoing(self) -> None:
              if self.wait_total < self.wait_start:
                  if self.wait_total == 0:
                      logger.info(f'等待 {self.wait_start} 秒')
                  self.wait_total += self.wait_pre
      Severity: Minor
      Found in arknights_mower/solvers/operation.py - About 35 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 recover_originite has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def recover_originite(self) -> bool:
              if self.originite == 0:
                  if self.potion != 0:
                      # 转而去使用药剂恢复
                      self.tap_element('ope_recover_potion')
      Severity: Minor
      Found in arknights_mower/solvers/operation.py - About 35 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 recover_potion has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def recover_potion(self) -> bool:
              if self.potion == 0:
                  if self.originite != 0:
                      # 转而去使用源石恢复
                      self.tap_element('ope_recover_originite')
      Severity: Minor
      Found in arknights_mower/solvers/operation.py - About 35 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 too many return statements within this function.
      Wontfix

                  return self.recover_potion()
      Severity: Major
      Found in arknights_mower/solvers/operation.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Wontfix

                    return self.recover_originite()
        Severity: Major
        Found in arknights_mower/solvers/operation.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return
          Severity: Major
          Found in arknights_mower/solvers/operation.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Wontfix

                        return True
            Severity: Major
            Found in arknights_mower/solvers/operation.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return
              Severity: Major
              Found in arknights_mower/solvers/operation.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return
                Severity: Major
                Found in arknights_mower/solvers/operation.py - About 30 mins to fix

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

                      def ope_finish(self) -> None:
                          # 更新 wait_start
                          if self.wait_total > 0:
                              if self.wait_start == 0:
                                  self.wait_start = self.wait_total - self.wait_pre
                  Severity: Minor
                  Found in arknights_mower/solvers/operation.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

                  Refactor this function to reduce its Cognitive Complexity from 23 to the 15 allowed.
                  Wontfix

                      def choose_level(self, level: str) -> None:

                  Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

                  See

                  Refactor this function to reduce its Cognitive Complexity from 27 to the 15 allowed.
                  Open

                      def choose_zone_supple(self, zone: list, scope: tp.Scope) -> None:

                  Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

                  See

                  Refactor this function to reduce its Cognitive Complexity from 20 to the 15 allowed.
                  Wontfix

                      def choose_zone_resource(self, zone: list) -> None:

                  Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

                  See

                  Refactor this function to reduce its Cognitive Complexity from 30 to the 15 allowed.
                  Wontfix

                      def choose_zone_theme(self, zone: list, scope: tp.Scope) -> None:

                  Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

                  See

                  Refactor this function to reduce its Cognitive Complexity from 23 to the 15 allowed.
                  Wontfix

                      def transition(self) -> bool:

                  Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

                  See

                  There are no issues that match your filters.

                  Category
                  Status