rasa/core/policies/policy.py
File policy.py
has 553 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
from __future__ import annotations
import abc
import copy
import logging
from enum import Enum
Function format_tracker_states
has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring. Open
Open
def format_tracker_states(states: List[Dict]) -> Text:
"""Format tracker states to human readable format on debug log.
Args:
states: list of tracker states dicts
- 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 11 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def __init__(
Function _prediction
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def _prediction(
Avoid deeply nested control flow statements. Open
Open
if TEXT in state[USER]:
state_messages.append(f"user text: {state[USER][TEXT]!s}")
if INTENT in state[USER]:
Avoid deeply nested control flow statements. Open
Open
if ACTION_NAME in state[PREVIOUS_ACTION]:
state_messages.append(
f"previous action name: "
f"{state[PREVIOUS_ACTION][ACTION_NAME]!s}"
)
Avoid deeply nested control flow statements. Open
Open
if INTENT in state[USER]:
state_messages.append(
f"user intent: {state[USER][INTENT]!s}"
)
if ENTITIES in state[USER]:
Avoid deeply nested control flow statements. Open
Open
if ENTITIES in state[USER]:
state_messages.append(
f"user entities: {state[USER][ENTITIES]!s}"
)
if PREVIOUS_ACTION in state:
Function load
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def load(
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def __init__(
Function for_action_name
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def for_action_name(
Function _featurize_for_training
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def _featurize_for_training(
Function create
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def create(
Function _featurize_for_prediction
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def _featurize_for_prediction(