RasaHQ/rasa_core

View on GitHub

Showing 243 of 245 total issues

File ensemble.py has 304 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import importlib
import json
import logging
import os
import sys
Severity: Minor
Found in rasa/core/policies/ensemble.py - About 3 hrs to fix

    File test_server.py has 303 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # -*- coding: utf-8 -*-
    import json
    import os
    import tempfile
    import uuid
    Severity: Minor
    Found in tests/core/test_server.py - About 3 hrs to fix

      Function get_parsing_states has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_parsing_states(self,
                                 tracker: 'DialogueStateTracker'
                                 ) -> Dict[Text, float]:
      
              state_dict = {}
      Severity: Minor
      Found in rasa/core/domain.py - About 3 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 encode has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          def encode(self, state: Dict[Text, float]) -> np.ndarray:
              if not self.num_features:
                  raise Exception("LabelTokenizerSingleStateFeaturizer "
                                  "was not prepared before encoding.")
      
      
      Severity: Minor
      Found in rasa/core/featurizers.py - About 3 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 training_states_and_actions has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          def training_states_and_actions(
              self,
              trackers: List[DialogueStateTracker],
              domain: Domain
          ) -> Tuple[List[List[Dict]], List[List[Text]]]:
      Severity: Minor
      Found in rasa/core/featurizers.py - About 3 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 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

        File tracker_store.py has 289 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import itertools
        import json
        import logging
        import pickle
        # noinspection PyPep8Naming
        Severity: Minor
        Found in rasa/core/tracker_store.py - About 2 hrs to fix

          Function blueprint has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

              def blueprint(self, on_new_message):
                  telegram_webhook = Blueprint('telegram_webhook', __name__)
                  out_channel = TelegramOutput(self.access_token)
          
                  @telegram_webhook.route("/", methods=['GET'])
          Severity: Minor
          Found in rasa/core/channels/telegram.py - About 2 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 training_states_and_actions has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

              def training_states_and_actions(
                  self,
                  trackers: List[DialogueStateTracker],
                  domain: Domain
              ) -> Tuple[List[List[Dict]], List[List[Text]]]:
          Severity: Minor
          Found in rasa/core/featurizers.py - About 2 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 _add_states_to_lookup has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

              def _add_states_to_lookup(self, trackers_as_states, trackers_as_actions,
                                        domain, online=False):
                  """Add states to lookup dict"""
                  if not trackers_as_states:
                      return
          Severity: Minor
          Found in rasa/core/policies/memoization.py - About 2 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 _issue_unused_checkpoint_notification has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

              def _issue_unused_checkpoint_notification(
                  self,
                  unused_checkpoints: Set[Text]
              ) -> None:
                  """Warns about unused story blocks.
          Severity: Minor
          Found in rasa/core/training/generator.py - About 2 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 _process_step has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

              def _process_step(
                  self,
                  step: StoryStep,
                  incoming_trackers: List[TrackerWithCachedStates]
              ) -> TrackersTuple:
          Severity: Minor
          Found in rasa/core/training/generator.py - About 2 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 call has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              def call(self, inputs, state):
                  """Perform a step of attention-wrapped RNN.
          
                  The order has changed:
                  - Step 1: Calculate attention inputs based on the previous cell state
          Severity: Minor
          Found in rasa/core/policies/tf_utils.py - About 2 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 slots_for_entities has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              def slots_for_entities(self, entities):
                  if self.store_entities_as_slots:
                      slot_events = []
                      for s in self.slots:
                          if s.auto_fill:
          Severity: Minor
          Found in rasa/core/domain.py - About 2 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

          Agent has 21 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class Agent(object):
              """The Agent class provides a convenient interface for the most important
               Rasa Core functionality.
          
               This includes training, handling messages, loading a dialogue model,
          Severity: Minor
          Found in rasa/core/agent.py - About 2 hrs to fix

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

                def __init__(self, cell,
            Severity: Major
            Found in rasa/core/policies/tf_utils.py - About 2 hrs to fix

              Function _chat_history_table has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
              Open

              def _chat_history_table(evts: List[Dict[Text, Any]]) -> Text:
                  """Create a table containing bot and user messages.
              
                  Also includes additional information, like any events and
                  prediction probabilities."""
              Severity: Minor
              Found in rasa/core/training/interactive.py - About 2 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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                      if (not isinstance(self._keep_prob, float)) or self._keep_prob < 1:
                          new_h = tf.nn.dropout(new_h, self._keep_prob, seed=self._seed)
              Severity: Major
              Found in rasa/core/policies/tf_utils.py and 1 other location - About 2 hrs to fix
              rasa/core/policies/tf_utils.py on lines 919..920

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 50.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              def test_tracker_store_from_invalid_module(default_domain):
                  endpoints_path = "data/test_endpoints/custom_tracker_endpoints.yml"
                  store_config = utils.read_endpoint_config(endpoints_path, "tracker_store")
                  store_config.type = "a.module.which.cannot.be.found"
              
              
              Severity: Major
              Found in tests/core/test_tracker_stores.py and 1 other location - About 2 hrs to fix
              tests/core/test_tracker_stores.py on lines 117..125

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 50.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                      if (not isinstance(self._keep_prob, float)) or self._keep_prob < 1:
                          g = tf.nn.dropout(g, self._keep_prob, seed=self._seed)
              Severity: Major
              Found in rasa/core/policies/tf_utils.py and 1 other location - About 2 hrs to fix
              rasa/core/policies/tf_utils.py on lines 933..934

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 50.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Severity
              Category
              Status
              Source
              Language