rasa/shared/nlu/training_data/message.py

Summary

Maintainability
C
1 day
Test Coverage
A
92%

File message.py has 399 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from typing import Any, Optional, Tuple, Text, Dict, Set, List

import typing
import copy

Severity: Minor
Found in rasa/shared/nlu/training_data/message.py - About 5 hrs to fix

    Function as_dict has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def as_dict(self, only_output_properties: bool = False) -> Dict:
            """Gets dict representation of message."""
            if only_output_properties:
                d = {}
                for key, value in self.data.items():
    Severity: Minor
    Found in rasa/shared/nlu/training_data/message.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 build has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def build(
    Severity: Major
    Found in rasa/shared/nlu/training_data/message.py - About 50 mins to fix

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

          def build(
              cls,
              text: Text,
              intent: Optional[Text] = None,
              entities: Optional[List[Dict[Text, Any]]] = None,
      Severity: Minor
      Found in rasa/shared/nlu/training_data/message.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__(
      Severity: Minor
      Found in rasa/shared/nlu/training_data/message.py - About 35 mins to fix

        There are no issues that match your filters.

        Category
        Status