File visualization.py
has 492 lines of code (exceeds 250 allowed). Consider refactoring. Open
from collections import defaultdict, deque
import random
from typing import (
Any,
Function visualize_neighborhood
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
def visualize_neighborhood(
current: Optional[List[Event]],
event_sequences: List[List[Event]],
output_file: Optional[Text] = None,
max_history: int = 2,
- 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 _merge_equivalent_nodes
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def _merge_equivalent_nodes(graph: "networkx.MultiDiGraph", max_history: int) -> None:
"""Searches for equivalent nodes in the graph and merges them."""
changed = True
# every node merge changes the graph and can trigger previously
# impossible node merges - we need to repeat until
- 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 _replace_edge_labels_with_nodes
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def _replace_edge_labels_with_nodes(
graph: "networkx.MultiDiGraph", next_id: int, nlu_training_data: "TrainingData"
) -> None:
"""Replaces edge labels with nodes.
- 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 visualize_neighborhood
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def visualize_neighborhood(
Function _fingerprint_node
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _fingerprint_node(
graph: "networkx.MultiDiGraph", node: int, max_history: int
) -> Set[Text]:
"""Fingerprint a node in a graph.
- 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 visualize_stories
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def visualize_stories(
Function _add_edge
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _add_edge(
Avoid deeply nested control flow statements. Open
if graph.has_node(j) and _nodes_are_equivalent(
graph, i, j, max_history
):
# make sure we keep special styles
_transfer_style(
Function _add_message_edge
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _add_message_edge(
Function _remove_auxiliary_nodes
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _remove_auxiliary_nodes(
graph: "networkx.MultiDiGraph", special_node_idx: int
) -> None:
"""Remove any temporary or unused nodes."""
graph.remove_node(TMP_NODE_ID)
- 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 _length_of_common_action_prefix
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _length_of_common_action_prefix(this: List[Event], other: List[Event]) -> int:
"""Calculate number of actions that two conversations have in common."""
num_common_actions = 0
t_cleaned = cast(
List[Union[ActionExecuted, UserUttered]],
- 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"