errbot/flow.py
File flow.py
has 417 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import atexit
import logging
from multiprocessing.pool import ThreadPool
from threading import RLock
from typing import Any, Callable, List, Mapping, Optional, Tuple, Union
Function execute
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
Open
def execute(self, flow: Flow) -> None:
"""
This is where the flow execution happens from one of the thread of the pool.
"""
while True:
- Read upRead up
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_inflight_flow_triggered
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
def check_inflight_flow_triggered(
self, cmd: str, user: Identifier
) -> Tuple[Optional[Flow], Optional[FlowNode]]:
"""
Check if a command from a specific user was expected in one of the running flow.
- Read upRead up
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
Open
if next_step.command == cmd:
log.debug(
"Requestor has a flow in flight waiting for this command!"
)
return flow, next_step