Konano/arknights-mower

View on GitHub
arknights_mower/utils/device/minitouch/core.py

Summary

Maintainability
A
3 hrs
Test Coverage

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

      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

      Function tap has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def tap(self, points: list[tuple[int, int]], display_frames: tuple[int, int, int], pressure: int = 100, duration: int = None, lift: bool = True) -> None:
      Severity: Minor
      Found in arknights_mower/utils/device/minitouch/core.py - About 35 mins to fix

        Rename field "client"
        Open

                self.client = client

        It's confusing to have a class member with the same name (case differences aside) as its enclosing class. This is particularly so when you consider the common practice of naming a class instance for the class itself.

        Best practice dictates that any field or member with the same name as the enclosing class be renamed to be more descriptive of the particular aspect of the class it represents or holds.

        Noncompliant Code Example

        class Foo:
          foo = ''
        
          def getFoo(self):
            ...
        
        foo = Foo()
        foo.getFoo() # what does this return?
        

        Compliant Solution

        class Foo:
          name = ''
        
          def getName(self):
            ...
        
        foo = Foo()
        foo.getName()
        

        Method "__swipe" has 8 parameters, which is greater than the 7 authorized.
        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:

        A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the function is doing too many things.

        Noncompliant Code Example

        With a maximum number of 4 parameters:

        def do_something(param1, param2, param3, param4, param5):
            ...
        

        Compliant Solution

        def do_something(param1, param2, param3, param4):
            ...
        

        Method "swipe" has 9 parameters, which is greater than the 7 authorized.
        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:

        A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the function is doing too many things.

        Noncompliant Code Example

        With a maximum number of 4 parameters:

        def do_something(param1, param2, param3, param4, param5):
            ...
        

        Compliant Solution

        def do_something(param1, param2, param3, param4):
            ...
        

        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

        There are no issues that match your filters.

        Category
        Status