rasa/utils/tensorflow/model_data_utils.py

Summary

Maintainability
D
1 day
Test Coverage
A
100%

File model_data_utils.py has 386 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import typing
import copy
import numpy as np
import scipy.sparse
from collections import defaultdict, OrderedDict
Severity: Minor
Found in rasa/utils/tensorflow/model_data_utils.py - About 5 hrs to fix

    Function _extract_features has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

    def _extract_features(
        features: List[List[List["Features"]]],
        fake_features: List["Features"],
        attribute: Text,
    ) -> Tuple[
    Severity: Minor
    Found in rasa/utils/tensorflow/model_data_utils.py - About 3 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 _feature_arrays_for_attribute has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def _feature_arrays_for_attribute(
        attribute: Text,
        absent_features: List[Any],
        attribute_to_features: Dict[Text, List[List[List["Features"]]]],
        training: bool,
    Severity: Minor
    Found in rasa/utils/tensorflow/model_data_utils.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 featurize_training_examples has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def featurize_training_examples(
        training_examples: List[Message],
        attributes: List[Text],
        entity_tag_specs: Optional[List["EntityTagSpec"]] = None,
        featurizers: Optional[List[Text]] = None,
    Severity: Minor
    Found in rasa/utils/tensorflow/model_data_utils.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 _surface_attributes has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def _surface_attributes(
        features: List[List[Dict[Text, List["Features"]]]],
        featurizers: Optional[List[Text]] = None,
    ) -> DefaultDict[Text, List[List[Optional[List["Features"]]]]]:
        """Restructure the input.
    Severity: Minor
    Found in rasa/utils/tensorflow/model_data_utils.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 _feature_arrays_for_attribute has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def _feature_arrays_for_attribute(
    Severity: Minor
    Found in rasa/utils/tensorflow/model_data_utils.py - About 45 mins to fix

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

      def featurize_training_examples(
      Severity: Minor
      Found in rasa/utils/tensorflow/model_data_utils.py - About 35 mins to fix

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

        def convert_to_data_format(
            features: Union[
                List[List[Dict[Text, List["Features"]]]], List[Dict[Text, List["Features"]]]
            ],
            fake_features: Optional[Dict[Text, List["Features"]]] = None,
        Severity: Minor
        Found in rasa/utils/tensorflow/model_data_utils.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