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.
- Read upRead up
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
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.
- Read upRead up
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.
- Read upRead up
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
)
Avoid too many return
statements within this function. Open
return None
Avoid too many return
statements within this function. Open
return self.process_active_loop(event)
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.
- Read upRead up
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"