rasa/shared/core/training_data/story_writer/yaml_story_writer.py

Summary

Maintainability
D
1 day
Test Coverage
A
97%

Function process_user_utterance has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

    def process_user_utterance(
        user_utterance: UserUttered, is_test_story: bool = False
    ) -> OrderedDict:
        """Converts a single user utterance into an ordered dict.

Severity: Minor
Found in rasa/shared/core/training_data/story_writer/yaml_story_writer.py - About 6 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

File yaml_story_writer.py has 347 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from collections import OrderedDict
from pathlib import Path
from typing import Any, Dict, List, Text, Union, Optional

from ruamel import yaml
Severity: Minor
Found in rasa/shared/core/training_data/story_writer/yaml_story_writer.py - About 4 hrs to fix

    Function process_rule_step has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def process_rule_step(self, rule_step: RuleStep) -> OrderedDict:
            """Converts a RuleStep into an ordered dict.
    
            Args:
                rule_step: RuleStep object.
    Severity: Minor
    Found in rasa/shared/core/training_data/story_writer/yaml_story_writer.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 process_action has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def process_action(action: ActionExecuted) -> Optional[OrderedDict]:
            """Converts a single action into an ordered dict.
    
            Args:
                action: Original action object.
    Severity: Minor
    Found in rasa/shared/core/training_data/story_writer/yaml_story_writer.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

    Avoid deeply nested control flow statements.
    Open

                            for predicted in user_utterance.predicted_entities:  # type: ignore[attr-defined] # noqa: E501
                                if predicted["start"] == entity["start"]:
                                    commented_entity = user_utterance.inline_comment_for_entity(  # noqa: E501
                                        predicted, entity
                                    )
    Severity: Major
    Found in rasa/shared/core/training_data/story_writer/yaml_story_writer.py - About 45 mins to fix

      Avoid too many return statements within this function.
      Open

              return None
      Severity: Major
      Found in rasa/shared/core/training_data/story_writer/yaml_story_writer.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return self.process_active_loop(event)
        Severity: Major
        Found in rasa/shared/core/training_data/story_writer/yaml_story_writer.py - About 30 mins to fix

          Function stories_to_yaml has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def stories_to_yaml(
                  self, story_steps: List[StoryStep], is_test_story: bool = False
              ) -> Dict[Text, Any]:
                  """Converts a sequence of story steps into yaml format.
          
          
          Severity: Minor
          Found in rasa/shared/core/training_data/story_writer/yaml_story_writer.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