RasaHQ/rasa_core

View on GitHub
rasa/core/domain.py

Summary

Maintainability
F
3 days
Test Coverage

File domain.py has 502 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import collections
import json
import logging
import os
import typing
Severity: Major
Found in rasa/core/domain.py - About 1 day to fix

    Domain has 43 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Domain(object):
        """The domain specifies the universe in which the bot's policy acts.
    
        A Domain subclass provides the actions the bot can take, the intents
        and entities it can recognise"""
    Severity: Minor
    Found in rasa/core/domain.py - About 5 hrs to fix

      Function check_domain_sanity has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
      Open

      def check_domain_sanity(domain):
          """Make sure the domain is properly configured.
      
          Checks the settings and checks if there are duplicate actions,
          intents, slots and entities."""
      Severity: Minor
      Found in rasa/core/domain.py - About 4 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 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 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

      Function persist_clean has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def persist_clean(self, filename: Text) -> None:
              """Write domain to a file.
      
               Strips redundant keys with default values."""
      
      
      Severity: Minor
      Found in rasa/core/domain.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 collect_intent_properties has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def collect_intent_properties(intent_list):
              intent_properties = {}
              for intent in intent_list:
                  if isinstance(intent, dict):
                      for properties in intent.values():
      Severity: Minor
      Found in rasa/core/domain.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 merge has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def merge(self, domain: 'Domain', override: bool = False) -> 'Domain':
              """Merge this domain with another one, combining their attributes.
      
              List attributes like ``intents`` and ``actions`` will be deduped
              and merged. Single attributes will be taken from ``self`` unless
      Severity: Minor
      Found in rasa/core/domain.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 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

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

        Avoid deeply nested control flow statements.
        Open

                                if s.type_name == 'list':
                                    slot_events.append(SlotSet(s.name,
                                                               matching_entities))
                                else:
                                    slot_events.append(SlotSet(s.name,
        Severity: Major
        Found in rasa/core/domain.py - About 45 mins to fix

          Function collect_templates has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def collect_templates(
                  yml_templates: Dict[Text, List[Any]]
              ) -> Dict[Text, List[Dict[Text, Any]]]:
                  """Go through the templates and make sure they are all in dict format
                  """
          Severity: Minor
          Found in rasa/core/domain.py - About 45 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