RasaHQ/rasa_core

View on GitHub

Showing 243 of 245 total issues

Function from_dict has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def from_dict(cls, dictionary: Dict[Text, Any]) -> List[Policy]:
        policies = dictionary.get('policies') or dictionary.get('policy')
        if policies is None:
            raise InvalidPolicyConfig("You didn't define any policies. "
                                      "Please define them under 'policies:' "
Severity: Minor
Found in rasa/core/policies/ensemble.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 10 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(self, host,
Severity: Major
Found in rasa/core/broker.py - About 1 hr to fix

    Function collect_intent_properties has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def collect_intent_properties(intent_list):
            intent_properties = {}
            for intent in intent_list:
                if isinstance(intent, dict):
                    for properties in intent.values():
    Severity: Minor
    Found in rasa/core/domain.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 merge has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def merge(self, domain: 'Domain', override: bool = False) -> 'Domain':
            """Merge this domain with another one, combining their attributes.
    
            List attributes like ``intents`` and ``actions`` will be deduped
            and merged. Single attributes will be taken from ``self`` unless
    Severity: Minor
    Found in rasa/core/domain.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 test_missing_classes_filled_correctly has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def test_missing_classes_filled_correctly(
                self, default_domain, trackers, tracker, featurizer, priority):
            # Pretend that a couple of classes are missing and check that
            # those classes are predicted as 0, while the other class
            # probabilities are predicted normally.
    Severity: Minor
    Found in tests/core/test_policies.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 message_for_data has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def message_for_data(self, structured_info):
            """Find a data sample with the same intent and entities.
    
            Given the parsed data from a message (intent and entities) finds a
            message in the data that has the same intent and entities."""
    Severity: Minor
    Found in rasa/core/training/visualization.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 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def __init__(
            self,
            featurizer: Optional[FullDialogueTrackerFeaturizer] = None,
            priority: int = 1,
            encoded_all_actions: Optional[np.ndarray] = None,
    Severity: Minor
    Found in rasa/core/policies/embedding_policy.py - About 1 hr to fix

      Function __init__ has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(
      Severity: Major
      Found in rasa/core/policies/sklearn_policy.py - About 1 hr to fix

        Function _compute_time_attention has 9 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def _compute_time_attention(attention_mechanism, attn_inputs, attention_state,
        Severity: Major
        Found in rasa/core/policies/tf_utils.py - About 1 hr to fix

          Function __init__ has 9 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(self,
          Severity: Major
          Found in rasa/core/processor.py - About 1 hr to fix

            Function _back_to_the_future_again has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def _back_to_the_future_again(tracker):
                    """Send Marty to the past to get
                        the new featurization for the future"""
            
                    idx_of_first_action = None
            Severity: Minor
            Found in rasa/core/policies/memoization.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 test_ensemble_from_dict has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            def test_ensemble_from_dict():
                def check_memoization(p):
                    assert p.max_history == 5
                    assert p.priority == 3
            
            
            Severity: Minor
            Found in tests/core/test_config.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 probabilities_using_best_policy has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def probabilities_using_best_policy(self,
                                                    tracker: DialogueStateTracker,
                                                    domain: Domain
                                                    ) -> Tuple[List[float], Text]:
                    result = None
            Severity: Minor
            Found in rasa/core/policies/ensemble.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 encode has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def encode(self, state: Dict[Text, float]) -> np.ndarray:
                    """Returns a binary vector indicating which features are active.
            
                        Given a dictionary of states (e.g. 'intent_greet',
                        'prev_action_listen',...) return a binary vector indicating which
            Severity: Minor
            Found in rasa/core/featurizers.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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            def test_nlu_fingerprint_unchanged():
                fingerprint1 = _fingerprint()
                fingerprint2 = _fingerprint(core_version="other", stories=[])
            
                assert nlu_fingerprint_changed(fingerprint1, fingerprint2) is False
            Severity: Major
            Found in tests/core/test_model.py and 1 other location - About 1 hr to fix
            tests/core/test_model.py on lines 75..79

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 39.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Function _collect_messages has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            def _collect_messages(evts: List[Dict[Text, Any]]) -> List[Message]:
                """Collect the message text and parsed data from the UserMessage events
                into a list"""
                from rasa_nlu.extractors.duckling_http_extractor import \
                    DucklingHTTPExtractor
            Severity: Minor
            Found in rasa/core/training/interactive.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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            def test_core_fingerprint_unchanged():
                fingerprint1 = _fingerprint()
                fingerprint2 = _fingerprint(nlu_version="other", nlu=[])
            
                assert core_fingerprint_changed(fingerprint1, fingerprint2) is False
            Severity: Major
            Found in tests/core/test_model.py and 1 other location - About 1 hr to fix
            tests/core/test_model.py on lines 82..86

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 39.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Function _emulate_form_rejection has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            def _emulate_form_rejection(processor, partial_tracker):
                from rasa.core.policies import FormPolicy
                if partial_tracker.active_form.get("name"):
                    for p in processor.policy_ensemble.policies:
                        if isinstance(p, FormPolicy):
            Severity: Minor
            Found in rasa/core/test.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 _collect_user_uttered_predictions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            def _collect_user_uttered_predictions(event,
                                                  partial_tracker,
                                                  fail_on_prediction_errors):
                from rasa.core.utils import (
                    pad_list_to_size)
            Severity: Minor
            Found in rasa/core/test.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 add_checkpoint has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def add_checkpoint(self,
                                   name: Text,
                                   conditions: Optional[Dict[Text, Any]]) -> None:
            
                    # Depending on the state of the story part this
            Severity: Minor
            Found in rasa/core/training/dsl.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

            Severity
            Category
            Status
            Source
            Language