rasa/shared/core/generator.py

Summary

Maintainability
F
4 days
Test Coverage
A
95%

File generator.py has 664 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from collections import defaultdict, namedtuple, deque

import copy
import logging
import random
Severity: Major
Found in rasa/shared/core/generator.py - About 1 day to fix

    Function _generate has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
    Open

        def _generate(
            self, story_steps: List[StoryStep], is_rule_data: bool = False
        ) -> List[TrackerWithCachedStates]:
            if not story_steps:
                logger.debug(f"No {'rules' if is_rule_data else 'story blocks'} found.")
    Severity: Minor
    Found in rasa/shared/core/generator.py - About 1 day 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 28 (exceeds 5 allowed). Consider refactoring.
    Open

        def _process_step(
            self, step: StoryStep, incoming_trackers: List[TrackerWithCachedStates]
        ) -> TrackersTuple:
            """Processes a steps events with all trackers.
    
    
    Severity: Minor
    Found in rasa/shared/core/generator.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 _issue_unused_checkpoint_notification has a Cognitive Complexity of 15 (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/shared/core/generator.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 _mark_first_action_in_story_steps_as_unpredictable has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def _mark_first_action_in_story_steps_as_unpredictable(self) -> None:
            """Mark actions which shouldn't be used during ML training.
    
            If a story starts with an action, we can not use
            that first action as a training example, as there is no
    Severity: Minor
    Found in rasa/shared/core/generator.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 _remove_duplicate_trackers has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def _remove_duplicate_trackers(
            self, trackers: List[TrackerWithCachedStates]
        ) -> TrackersTuple:
            """Removes trackers that create equal featurizations
                for current story step.
    Severity: Minor
    Found in rasa/shared/core/generator.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 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

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

      Function update has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def update(
              self,
              event: Event,
              domain: Optional[Domain] = None,
          ) -> None:
      Severity: Minor
      Found in rasa/shared/core/generator.py - About 55 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_events has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def from_events(
      Severity: Major
      Found in rasa/shared/core/generator.py - About 50 mins to fix

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

            def __init__(
        Severity: Minor
        Found in rasa/shared/core/generator.py - About 45 mins to fix

          There are no issues that match your filters.

          Category
          Status