rasa/shared/core/domain.py

Summary

Maintainability
F
5 days
Test Coverage
A
94%

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

import copy
import collections
import json
import logging
import os
Severity: Major
Found in rasa/shared/core/domain.py - About 4 days to fix

    Function merge_domain_dicts has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Wontfix

        def merge_domain_dicts(
            domain_dict: Dict,
            combined: Dict,
            override: bool = False,
        ) -> Dict:
    Severity: Minor
    Found in rasa/shared/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 12 arguments (exceeds 4 allowed). Consider refactoring.
    Open

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

      Avoid deeply nested control flow statements.
      Open

                              if (
                                  ENTITY_FEATURIZATION_KEY in sub_labels
                                  and sub_labels[ENTITY_FEATURIZATION_KEY] is False
                              ):
                                  entity_properties.default_ignored_entities.append(_entity)
      Severity: Major
      Found in rasa/shared/core/domain.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if ENTITY_ROLES_KEY in sub_labels:
                                    entity_properties.roles[_entity] = sub_labels[
                                        ENTITY_ROLES_KEY
                                    ]
                                if ENTITY_GROUPS_KEY in sub_labels:
        Severity: Major
        Found in rasa/shared/core/domain.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if ENTITY_GROUPS_KEY in sub_labels:
                                      entity_properties.groups[_entity] = sub_labels[
                                          ENTITY_GROUPS_KEY
                                      ]
                                  if (
          Severity: Major
          Found in rasa/shared/core/domain.py - About 45 mins to fix

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

                def domain_warnings(
            Severity: Minor
            Found in rasa/shared/core/domain.py - About 35 mins to fix

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

                  def states_for_tracker_history(
              Severity: Minor
              Found in rasa/shared/core/domain.py - About 35 mins to fix

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

                    def _reset_intent_flags(intent: Dict[Text, Any]) -> None:
                        for intent_property in intent.values():
                            if (
                                USE_ENTITIES_KEY in intent_property.keys()
                                and not intent_property[USE_ENTITIES_KEY]
                Severity: Minor
                Found in rasa/shared/core/domain.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 from_directory has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def from_directory(cls, path: Text) -> "Domain":
                        """Loads and merges multiple domain files recursively from a directory tree."""
                        combined: Dict[Text, Any] = {}
                        for root, _, files in os.walk(path, followlinks=True):
                            for file in files:
                Severity: Minor
                Found in rasa/shared/core/domain.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