RasaHQ/rasa_core

View on GitHub
rasa/core/events/__init__.py

Summary

Maintainability
D
2 days
Test Coverage

File __init__.py has 747 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import time
import typing

import json
import jsonpickle
Severity: Major
Found in rasa/core/events/__init__.py - About 1 day to fix

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

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

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

          def as_story_string(self, e2e=False):
              if self.intent:
                  if self.entities:
                      ent_string = json.dumps({ent['entity']: ent['value']
                                               for ent in self.entities})
      Severity: Minor
      Found in rasa/core/events/__init__.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

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

      def first_key(d, default_key):
          if len(d) > 1:
              for k, v in d.items():
                  if k != default_key:
                      # we return the first key that is not the default key
      Severity: Minor
      Found in rasa/core/events/__init__.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

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

          def __init__(self, action_name, trigger_date_time, name=None,
      Severity: Minor
      Found in rasa/core/events/__init__.py - About 35 mins to fix

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

        def deserialise_events(serialized_events: List[Dict[Text, Any]]
                               ) -> List['Event']:
            """Convert a list of dictionaries to a list of corresponding events.
        
            Example format:
        Severity: Minor
        Found in rasa/core/events/__init__.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 resolve_by_type has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def resolve_by_type(
                type_name: Text,
                default: Optional[Type['Event']] = None
            ) -> Optional[Type['Event']]:
                """Returns a slots class by its type name."""
        Severity: Minor
        Found in rasa/core/events/__init__.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