rasa/nlu/featurizers/sparse_featurizer/count_vectors_featurizer.py

Summary

Maintainability
D
2 days
Test Coverage
A
94%

File count_vectors_featurizer.py has 636 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from __future__ import annotations
import logging
import re
import scipy.sparse
from typing import Any, Dict, List, Optional, Text, Tuple, Set, Type
Severity: Major
Found in rasa/nlu/featurizers/sparse_featurizer/count_vectors_featurizer.py - About 1 day to fix

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

        def _check_OOV_present(self, all_tokens: List[List[Text]], attribute: Text) -> None:
            """Check if an OOV word is present."""
            if not self.OOV_token or self.OOV_words or not all_tokens:
                return
    
    
    Severity: Minor
    Found in rasa/nlu/featurizers/sparse_featurizer/count_vectors_featurizer.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 _replace_with_oov_token has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def _replace_with_oov_token(
            self, tokens: List[Text], attribute: Text
        ) -> List[Text]:
            """Replace OOV words with OOV token."""
            if self.OOV_token and self.analyzer == "word":
    Severity: Minor
    Found in rasa/nlu/featurizers/sparse_featurizer/count_vectors_featurizer.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 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(
    Severity: Major
    Found in rasa/nlu/featurizers/sparse_featurizer/count_vectors_featurizer.py - About 50 mins to fix

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

          def load(
      Severity: Minor
      Found in rasa/nlu/featurizers/sparse_featurizer/count_vectors_featurizer.py - About 45 mins to fix

        Function _check_analyzer has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def _check_analyzer(self) -> None:
                if self.analyzer != "word":
                    if self.OOV_token is not None:
                        logger.warning(
                            "Analyzer is set to character, "
        Severity: Minor
        Found in rasa/nlu/featurizers/sparse_featurizer/count_vectors_featurizer.py - About 35 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 _merge_new_vocabulary_tokens has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def _merge_new_vocabulary_tokens(
                self, existing_vocabulary: Dict[Text, int], vocabulary: Set[Text]
            ) -> None:
                """Merges new vocabulary tokens with the existing vocabulary.
        
        
        Severity: Minor
        Found in rasa/nlu/featurizers/sparse_featurizer/count_vectors_featurizer.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