Konano/arknights-mower

View on GitHub

Showing 99 of 1,043 total issues

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

    def __run(self, cmd: str, restart: bool = True) -> Optional[bytes]:
        """ run command with Session """
        error_limit = 3
        while True:
            try:
Severity: Minor
Found in arknights_mower/utils/device/adb_client/core.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 run has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def run(self, cmd: str) -> Optional[bytes]:
        """ run adb exec command """
        logger.debug(f'command: {cmd}')
        error_limit = 3
        while True:
Severity: Minor
Found in arknights_mower/utils/device/adb_client/core.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 load_from_disk has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def load_from_disk(self, cmd_list=None, matcher: Callable = None) -> bool:
        if cmd_list is None:
            cmd_list = []
        try:
            with self.schedule_log_path.open('r', encoding='utf8') as f:
Severity: Minor
Found in arknights_mower/solvers/schedule.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 handle_error has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def handle_error(self,force = False):
        # 如果有任何报错,则生成一个空
        if self.scene() == Scene.UNKNOWN:
            self.device.exit('com.hypergryph.arknights')
        if self.error or force:
Severity: Minor
Found in arknights_mower/solvers/base_schedule.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 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 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.
Open

            return -1
Severity: Major
Found in arknights_mower/utils/segment.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                    return (good_matches_rate, good_area_rate, hash, ssim)
    Severity: Major
    Found in arknights_mower/utils/matcher.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

          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 stable has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def stable(f):
                    @functools.wraps(f)
                    def inner(self: Client, *args, **kwargs):
                        try_count = 0
                        while try_count < 3:
            Severity: Minor
            Found in arknights_mower/utils/device/scrcpy/core.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

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

                def check_in_and_out(self):
                    res = {}
                    for x, y in self.currentPlan.items():
                        if not x.startswith('room'): continue
                        if any(('但书' in obj['replacement'] or '龙舌兰' in obj['replacement']) for obj in y):
            Severity: Minor
            Found in arknights_mower/solvers/base_schedule.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

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

                def run(self) -> bool:
                    logger.info(f'task: {self.cmd.__name__} {self.cmd_args}')
                    if self.cmd.__name__ == 'operation':
                        if operation_one(self.cmd_args, self.device):
                            self.finish += 1
            Severity: Minor
            Found in arknights_mower/solvers/schedule.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

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

                def request(self, cmd: str, reconnect: bool = False) -> Session:
                    """ make a service request to ADB server, consult ADB sources for available services """
                    cmdbytes = cmd.encode()
                    data = b'%04X%b' % (len(cmdbytes), cmdbytes)
                    while self.timeout <= 60:
            Severity: Minor
            Found in arknights_mower/utils/device/adb_client/session.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

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

                def __init_adb(self) -> None:
                    if self.adb_bin is not None:
                        return
                    for adb_bin in config.ADB_BINARY:
                        logger.debug(f'try adb binary: {adb_bin}')
            Severity: Minor
            Found in arknights_mower/utils/device/adb_client/core.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

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

                    def __init__(self, device: Device, client: ADBClient = None, touch_device: str = None) -> None:
                        self.device = device
                        self.minitouch = None
                        self.scrcpy = None
            
            
            Severity: Minor
            Found in arknights_mower/utils/device/device.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

            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

            Severity
            Category
            Status
            Source
            Language