rasa/core/policies/policy.py

Summary

Maintainability
D
3 days
Test Coverage
B
88%

File policy.py has 553 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from __future__ import annotations
import abc
import copy
import logging
from enum import Enum
Severity: Major
Found in rasa/core/policies/policy.py - About 1 day to fix

    Function format_tracker_states has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
    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
    Severity: Minor
    Found in rasa/core/policies/policy.py - About 6 hrs to fix

    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

        def __init__(
    Severity: Major
    Found in rasa/core/policies/policy.py - About 1 hr to fix

      Function _prediction has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def _prediction(
      Severity: Major
      Found in rasa/core/policies/policy.py - About 50 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if TEXT in state[USER]:
                                    state_messages.append(f"user text: {state[USER][TEXT]!s}")
                                if INTENT in state[USER]:
        Severity: Major
        Found in rasa/core/policies/policy.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if ACTION_NAME in state[PREVIOUS_ACTION]:
                                      state_messages.append(
                                          f"previous action name: "
                                          f"{state[PREVIOUS_ACTION][ACTION_NAME]!s}"
                                      )
          Severity: Major
          Found in rasa/core/policies/policy.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if INTENT in state[USER]:
                                        state_messages.append(
                                            f"user intent: {state[USER][INTENT]!s}"
                                        )
                                    if ENTITIES in state[USER]:
            Severity: Major
            Found in rasa/core/policies/policy.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if ENTITIES in state[USER]:
                                          state_messages.append(
                                              f"user entities: {state[USER][ENTITIES]!s}"
                                          )
                                  if PREVIOUS_ACTION in state:
              Severity: Major
              Found in rasa/core/policies/policy.py - About 45 mins to fix

                Function load has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def load(
                Severity: Minor
                Found in rasa/core/policies/policy.py - About 35 mins to fix

                  Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def __init__(
                  Severity: Minor
                  Found in rasa/core/policies/policy.py - About 35 mins to fix

                    Function for_action_name has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def for_action_name(
                    Severity: Minor
                    Found in rasa/core/policies/policy.py - About 35 mins to fix

                      Function _featurize_for_training has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          def _featurize_for_training(
                      Severity: Minor
                      Found in rasa/core/policies/policy.py - About 35 mins to fix

                        Function create has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            def create(
                        Severity: Minor
                        Found in rasa/core/policies/policy.py - About 35 mins to fix

                          Function _featurize_for_prediction has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              def _featurize_for_prediction(
                          Severity: Minor
                          Found in rasa/core/policies/policy.py - About 35 mins to fix

                            There are no issues that match your filters.

                            Category
                            Status