Konano/arknights-mower

View on GitHub
arknights_mower/solvers/base_construct.py

Summary

Maintainability
C
1 day
Test Coverage

Function choose_agent has a Cognitive Complexity of 102 (exceeds 5 allowed). Consider refactoring.
Wontfix

    def choose_agent(self, agent: list[str], skip_free: int = 0, order: ArrangeOrder = None) -> None:
        """
        :param order: ArrangeOrder, 选择干员时右上角的排序功能
        """
        logger.info(f'安排干员:{agent}')
Severity: Minor
Found in arknights_mower/solvers/base_construct.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 agent_arrange has a Cognitive Complexity of 78 (exceeds 5 allowed). Consider refactoring.
Wontfix

    def agent_arrange(self, plan: tp.BasePlan) -> None:
        """ 基建排班 """
        logger.info('基建:排班')

        # 进入进驻总览
Severity: Minor
Found in arknights_mower/solvers/base_construct.py - About 1 day 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 base_construct.py has 683 lines of code (exceeds 250 allowed). Consider refactoring.
Wontfix

from __future__ import annotations

from enum import Enum

import numpy as np
Severity: Major
Found in arknights_mower/solvers/base_construct.py - About 1 day to fix

    Function fia has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
    Wontfix

        def fia(self, room: str):
            """
            使用菲亚梅塔恢复指定房间心情最差的干员的心情,同时保持工位顺序不变
            目前仅支持制造站、贸易站、发电站 (因为其他房间在输入命令时较为繁琐,且需求不大)
            使用前需要菲亚梅塔位于任意一间宿舍
    Severity: Minor
    Found in arknights_mower/solvers/base_construct.py - About 1 day 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_agent_in_order has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
    Wontfix

        def choose_agent_in_order(self, agent: list[str], exclude: list[str] = None, exclude_checked_in: bool = False, dormitory: bool = False):
            """
            按照顺序选择干员,只选择未在工作、未注意力涣散、未在休息的空闲干员
    
            :param agent: 指定入驻干员列表
    Severity: Minor
    Found in arknights_mower/solvers/base_construct.py - About 7 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 recog_view_mask_right has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Wontfix

        def recog_view_mask_right(self) -> int:
            """ 识别线索视图中右边黑色 mask 边缘的位置 """
            x3 = x2
            while True:
                max_abs = 0
    Severity: Minor
    Found in arknights_mower/solvers/base_construct.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 clue has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Wontfix

        def clue(self) -> None:
            # 一些识别时会用到的参数
            global x1, x2, x3, x4, y0, y1, y2
            x1, x2, x3, x4 = 0, 0, 0, 0
            y0, y1, y2 = 0, 0, 0
    Severity: Minor
    Found in arknights_mower/solvers/base_construct.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

    BaseConstructSolver has 22 functions (exceeds 20 allowed). Consider refactoring.
    Wontfix

    class BaseConstructSolver(BaseSolver):
        """
        收集基建的产物:物资、赤金、信赖
        """
    
    
    Severity: Minor
    Found in arknights_mower/solvers/base_construct.py - About 2 hrs to fix

      Function ori_clue has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Wontfix

          def ori_clue(self):
              """ 获取界面内有多少线索 """
              clues = []
              y3 = y1
              status = -2
      Severity: Minor
      Found in arknights_mower/solvers/base_construct.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 transition has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Wontfix

          def transition(self) -> None:
              if self.scene() == Scene.INDEX:
                  self.tap_element('index_infrastructure')
              elif self.scene() == Scene.INFRA_MAIN:
                  return self.infra_main()
      Severity: Minor
      Found in arknights_mower/solvers/base_construct.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 infra_main has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Wontfix

          def infra_main(self) -> None:
              """ 位于基建首页 """
              if self.find('control_central') is None:
                  self.back()
                  return
      Severity: Minor
      Found in arknights_mower/solvers/base_construct.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 clear_clue_mask has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Wontfix

          def clear_clue_mask(self) -> None:
              """ 清空界面内被选中的线索 """
              try:
                  while True:
                      mask = False
      Severity: Minor
      Found in arknights_mower/solvers/base_construct.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

      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

        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 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

              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

                    Avoid deeply nested control flow statements.
                    Open

                                            if x[0] == agent[idx]:
                                                self.tap(x[1], x_rate=0.5, y_rate=0.5, interval=0)
                                                found = 1
                                                break
                    
                    
                    Severity: Major
                    Found in arknights_mower/solvers/base_construct.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              for y in ret:
                                                  if y[0] == '菲亚梅塔':
                                                      self.tap((y[1][0]), interval=0, rebuild=False)
                                                      break
                                              agent.remove('菲亚梅塔')
                      Severity: Major
                      Found in arknights_mower/solvers/base_construct.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                for _ in range(9):
                                                    self.swipe_only((w//2, h//2), (w//2, 0), interval=0.5)
                                                self.swipe((w//2, h//2), (w//2, 0), interval=3, rebuild=False)
                        Severity: Major
                        Found in arknights_mower/solvers/base_construct.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                      if error_count >= 3:
                                                          raise e
                                                      # 返回基建干员进驻总览
                                                      self.recog.update()
                          Severity: Major
                          Found in arknights_mower/solvers/base_construct.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                    if self.find('arrange_empty_room') is None:
                                                        if self.find('arrange_clean') is not None:
                                                            self.tap_element('arrange_clean')
                                                        else:
                                                            # 对于只有一个干员的房间,没有清空按钮,需要点击干员清空
                            Severity: Major
                            Found in arknights_mower/solvers/base_construct.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                          if base_room_list[idx].startswith('dormitory'):
                                                              default_order = ArrangeOrder.FEELING
                                                          else:
                                                              default_order = ArrangeOrder.SKILL
                                                          self.choose_agent(
                              Severity: Major
                              Found in arknights_mower/solvers/base_construct.py - About 45 mins to fix

                                Function get_clue_mask has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                Wontfix

                                    def get_clue_mask(self) -> None:
                                        """ 界面内是否有被选中的线索 """
                                        try:
                                            mask = []
                                            for y in range(y1, y2):
                                Severity: Minor
                                Found in arknights_mower/solvers/base_construct.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

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

                                    def choose_agent_in_order(self, agent: list[str], exclude: list[str] = None, exclude_checked_in: bool = False, dormitory: bool = False):

                                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 78 to the 15 allowed.
                                Wontfix

                                    def agent_arrange(self, plan: tp.BasePlan) -> 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 58 to the 15 allowed.
                                Open

                                    def fia(self, room: str):

                                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 clue(self) -> 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 102 to the 15 allowed.
                                Open

                                    def choose_agent(self, agent: list[str], skip_free: int = 0, order: ArrangeOrder = None) -> 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 26 to the 15 allowed.
                                Wontfix

                                    def recog_view_mask_right(self) -> int:

                                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

                                Merge this if statement with the enclosing one.
                                Open

                                                            if not (self.find('agent_on_shift', scope=(status_coord[0], status_coord[2]))

                                Merging collapsible if statements increases the code's readability.

                                Noncompliant Code Example

                                if condition1:
                                    if condition2:
                                        # ...
                                

                                Compliant Solution

                                if condition1 and condition2:
                                    # ...
                                

                                Blank line contains whitespace
                                Open

                                                        

                                Trailing whitespace is superfluous.

                                The warning returned varies on whether the line itself is blank,
                                for easier filtering for those who want to indent their blank lines.
                                
                                Okay: spam(1)\n#
                                W291: spam(1) \n#
                                W293: class Foo(object):\n    \n    bang = 12

                                Continuation line over-indented for visual indent
                                Open

                                                            or self.find('fia_full_elite2', scope=(block[0], block[2]))

                                Continuation lines indentation.

                                Continuation lines should align wrapped elements either vertically
                                using Python's implicit line joining inside parentheses, brackets
                                and braces, or using a hanging indent.
                                
                                When using a hanging indent these considerations should be applied:
                                - there should be no arguments on the first line, and
                                - further indentation should be used to clearly distinguish itself
                                  as a continuation line.
                                
                                Okay: a = (\n)
                                E123: a = (\n    )
                                
                                Okay: a = (\n    42)
                                E121: a = (\n   42)
                                E122: a = (\n42)
                                E123: a = (\n    42\n    )
                                E124: a = (24,\n     42\n)
                                E125: if (\n    b):\n    pass
                                E126: a = (\n        42)
                                E127: a = (24,\n      42)
                                E128: a = (24,\n    42)
                                E129: if (a or\n    b):\n    pass
                                E131: a = (\n    42\n 24)

                                Trailing whitespace
                                Open

                                            self.back(interval=2)        

                                Trailing whitespace is superfluous.

                                The warning returned varies on whether the line itself is blank,
                                for easier filtering for those who want to indent their blank lines.
                                
                                Okay: spam(1)\n#
                                W291: spam(1) \n#
                                W293: class Foo(object):\n    \n    bang = 12

                                Blank line contains whitespace
                                Open

                                            

                                Trailing whitespace is superfluous.

                                The warning returned varies on whether the line itself is blank,
                                for easier filtering for those who want to indent their blank lines.
                                
                                Okay: spam(1)\n#
                                W291: spam(1) \n#
                                W293: class Foo(object):\n    \n    bang = 12

                                Expected 2 blank lines after class or function definition, found 1
                                Open

                                arrange_order_res = {

                                Separate top-level function and class definitions with two blank lines.

                                Method definitions inside a class are separated by a single blank
                                line.
                                
                                Extra blank lines may be used (sparingly) to separate groups of
                                related functions.  Blank lines may be omitted between a bunch of
                                related one-liners (e.g. a set of dummy implementations).
                                
                                Use blank lines in functions, sparingly, to indicate logical
                                sections.
                                
                                Okay: def a():\n    pass\n\n\ndef b():\n    pass
                                Okay: def a():\n    pass\n\n\nasync def b():\n    pass
                                Okay: def a():\n    pass\n\n\n# Foo\n# Bar\n\ndef b():\n    pass
                                Okay: default = 1\nfoo = 1
                                Okay: classify = 1\nfoo = 1
                                
                                E301: class Foo:\n    b = 0\n    def bar():\n        pass
                                E302: def a():\n    pass\n\ndef b(n):\n    pass
                                E302: def a():\n    pass\n\nasync def b(n):\n    pass
                                E303: def a():\n    pass\n\n\n\ndef b(n):\n    pass
                                E303: def a():\n\n\n\n    pass
                                E304: @decorator\n\ndef a():\n    pass
                                E305: def a():\n    pass\na()
                                E306: def a():\n    def b():\n        pass\n    def c():\n        pass

                                Blank line contains whitespace
                                Open

                                                

                                Trailing whitespace is superfluous.

                                The warning returned varies on whether the line itself is blank,
                                for easier filtering for those who want to indent their blank lines.
                                
                                Okay: spam(1)\n#
                                W291: spam(1) \n#
                                W293: class Foo(object):\n    \n    bang = 12

                                Blank line contains whitespace
                                Open

                                                    

                                Trailing whitespace is superfluous.

                                The warning returned varies on whether the line itself is blank,
                                for easier filtering for those who want to indent their blank lines.
                                
                                Okay: spam(1)\n#
                                W291: spam(1) \n#
                                W293: class Foo(object):\n    \n    bang = 12

                                Blank line contains whitespace
                                Open

                                            

                                Trailing whitespace is superfluous.

                                The warning returned varies on whether the line itself is blank,
                                for easier filtering for those who want to indent their blank lines.
                                
                                Okay: spam(1)\n#
                                W291: spam(1) \n#
                                W293: class Foo(object):\n    \n    bang = 12

                                Trailing whitespace
                                Open

                                                x = self.recog.w // 3 * 2  

                                Trailing whitespace is superfluous.

                                The warning returned varies on whether the line itself is blank,
                                for easier filtering for those who want to indent their blank lines.
                                
                                Okay: spam(1)\n#
                                W291: spam(1) \n#
                                W293: class Foo(object):\n    \n    bang = 12

                                There are no issues that match your filters.

                                Category
                                Status