File decider.py
has 512 lines of code (exceeds 250 allowed). Consider refactoring. Open
# Copyright (c) 2019-2024 r3w0p
# The following code can be redistributed and/or
# modified under the terms of the MIT License.
"""
Function on_distributed_update
has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring. Open
def on_distributed_update(
self,
completed: List[BoboRunSerial],
halted: List[BoboRunSerial],
updated: List[BoboRunSerial]) -> None:
- 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_against_patterns
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
def _check_against_patterns(self, event: BoboEvent) -> \
Tuple[List[BoboRun], List[BoboRun]]:
"""
:param event: An event.
- 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_against_runs
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
def _check_against_runs(self, event: BoboEvent) -> \
Tuple[List[BoboRun], List[BoboRun], List[BoboRun]]:
"""
:param event: An event.
- 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
BoboDecider
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
class BoboDecider(BoboEngineTask,
BoboDeciderPublisher,
BoboReceiverSubscriber,
BoboDistributedSubscriber):
"""
Function snapshot
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def snapshot(self) -> Tuple[
List[BoboRunSerial], List[BoboRunSerial], List[BoboRunSerial]
]:
"""
A snapshot of the current state of the Decider.
- 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
if runremote.run_id != runlocal.run_id:
runlocalserial = runlocal.serialize()
remlist[k] = runlocalserial
self._maybe_cache(
Avoid deeply nested control flow statements. Open
if run.is_halted():
runs_to_remove.append((
phenomenon_name, pattern_name, run.run_id))
if run.is_complete():
runs_halted_complete.append(run)
Avoid deeply nested control flow statements. Open
if (
(not pattern.singleton) or
(pattern.singleton and len(runs) == 0)
):
self._add_run(
Avoid deeply nested control flow statements. Open
if i == 0:
remove_indices_completed.append(k)
else:
remove_indices_halted.append(k)
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self,
Function update
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def update(self) -> bool:
"""
Performs an update cycle of the decider that takes an event from its
queue and checks it against phenomena and existing runs.
- 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 _maybe_cache
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _maybe_cache(
self,
completed: List[BoboRunSerial],
halted: List[BoboRunSerial]) -> None:
"""
- 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 __init__
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self,
phenomena: List[BoboPhenomenon],
gen_event_id: BoboGenEventID,
gen_run_id: BoboGenEventID,
max_cache: int = 0,
- 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 _get_pattern
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _get_pattern(self,
phenomenon_name: str,
pattern_name: str) -> Optional[BoboPattern]:
"""
:param phenomenon_name: A phenomenon name.
- 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 all_runs
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def all_runs(self) -> Tuple[BoboRun, ...]:
"""
:return: All active runs in the decider.
"""
with self._lock:
- 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"