Konano/arknights-mower

View on GitHub
arknights_mower/command.py

Summary

Maintainability
A
1 hr
Test Coverage

Function base has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Wontfix

def base(args: list[str] = [], device: Device = None):
    """
    base [plan] [-c] [-d[F][N]] [-f[F][N]]
        自动处理基建的信赖/货物/订单/线索/无人机
        plan 表示选择的基建干员排班计划(建议搭配配置文件使用, 也可命令行直接输入)
Severity: Minor
Found in arknights_mower/command.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 schedule has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Wontfix

def schedule(args: list[str] = [], device: Device = None):
    """
    schedule
        执行配置文件中的计划任务
        计划执行时会自动存档至本地磁盘,启动时若检测到有存档,则会使用存档内容继续完成计划
Severity: Minor
Found in arknights_mower/command.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 add_tasks has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def add_tasks(solver: ScheduleSolver = None, tag: str = ''):
    """
    为 schedule 模块添加任务
    """
    plan = config.SCHEDULE_PLAN.get(tag)
Severity: Minor
Found in arknights_mower/command.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

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

def base(args: list[str] = [], device: Device = None):
Severity: Critical
Found in arknights_mower/command.py by sonar-python

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 p[1] == 'n':
Severity: Major
Found in arknights_mower/command.py by sonar-python

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

    
Severity: Minor
Found in arknights_mower/command.py by pep8

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

    
Severity: Minor
Found in arknights_mower/command.py by pep8

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

                        agents[-1].append(p)                
Severity: Minor
Found in arknights_mower/command.py by pep8

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