File visualization.py
has 415 lines of code (exceeds 250 allowed). Consider refactoring. Open
from collections import defaultdict, deque
import random
import re
from typing import Any, Text, List, Dict, Optional, TYPE_CHECKING
Function _merge_equivalent_nodes
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
def _merge_equivalent_nodes(graph, max_history):
"""Searches for equivalent nodes in the graph and merges them."""
changed = True
# every node merge changes the graph and can trigger previously
- 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 message_for_data
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def message_for_data(self, structured_info):
"""Find a data sample with the same intent and entities.
Given the parsed data from a message (intent and entities) finds a
message in the data that has the same intent and entities."""
- 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 _fingerprint_node
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _fingerprint_node(graph, node, max_history):
"""Fingerprint a node in a graph.
Can be used to identify nodes that are similar and can be merged within the
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
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(graph.nodes(data=True)[j],
graph.nodes(data=True)[i])
Function _remove_auxiliary_nodes
has a Cognitive Complexity of 8 (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 _add_edge
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _add_edge(graph, u, v, key, label=None, **kwargs):
Function _add_message_edge
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _add_message_edge(graph: 'networkx.MultiDiGraph',
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
- 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"