RasaHQ/rasa_core

View on GitHub
rasa/core/policies/embedding_policy.py

Summary

Maintainability
F
4 days
Test Coverage

File embedding_policy.py has 1090 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from collections import namedtuple
import copy
import json
import logging
import os
Severity: Major
Found in rasa/core/policies/embedding_policy.py - About 2 days to fix

    EmbeddingPolicy has 48 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class EmbeddingPolicy(Policy):
        """Recurrent Embedding Dialogue Policy (REDP)
    
        The policy that is used in our paper https://arxiv.org/abs/1811.11707
        """
    Severity: Minor
    Found in rasa/core/policies/embedding_policy.py - About 6 hrs to fix

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

          def __init__(
      Severity: Major
      Found in rasa/core/policies/embedding_policy.py - About 3 hrs to fix

        Function _train_tf has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def _train_tf(self,
                          session_data: SessionData,
                          loss: tf.Tensor,
                          mask: tf.Tensor) -> None:
                """Train tf graph."""
        Severity: Minor
        Found in rasa/core/policies/embedding_policy.py - About 1 hr 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 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def __init__(
                self,
                featurizer: Optional[FullDialogueTrackerFeaturizer] = None,
                priority: int = 1,
                encoded_all_actions: Optional[np.ndarray] = None,
        Severity: Minor
        Found in rasa/core/policies/embedding_policy.py - About 1 hr to fix

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

              def _create_attn_cell(self,
          Severity: Major
          Found in rasa/core/policies/embedding_policy.py - About 50 mins to fix

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

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

              Function _create_attn_cell has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _create_attn_cell(self,
                                        cell: tf.contrib.rnn.RNNCell,
                                        embed_utter: tf.Tensor,
                                        embed_prev_action: tf.Tensor,
                                        real_length: tf.Tensor,
              Severity: Minor
              Found in rasa/core/policies/embedding_policy.py - About 35 mins 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 _tf_sim has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _tf_sim(self,
                              embed_dialogue: tf.Tensor,
                              embed_action: tf.Tensor,
                              mask: Optional[tf.Tensor]
                              ) -> Tuple[tf.Tensor, tf.Tensor]:
              Severity: Minor
              Found in rasa/core/policies/embedding_policy.py - About 25 mins 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

              There are no issues that match your filters.

              Category
              Status