RasaHQ/rasa_core

View on GitHub
tests/core/test_policies.py

Summary

Maintainability
D
1 day
Test Coverage

File test_policies.py has 549 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from unittest.mock import patch

import numpy as np
import pytest

Severity: Major
Found in tests/core/test_policies.py - About 1 day to fix

    Consider simplifying this complex logical expression.
    Open

                if states[0] is not None and states[-1] is not None:
                    # explicitly set intents and actions before listen after
                    # which FormPolicy should not predict a form action and
                    # should add FormValidation(False) event
                    # @formatter:off
    Severity: Critical
    Found in tests/core/test_policies.py - About 1 hr to fix

      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 test_cv_not_none_param_grid_none_triggers_search_without_params has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def test_cv_not_none_param_grid_none_triggers_search_without_params(
      Severity: Minor
      Found in tests/core/test_policies.py - About 35 mins to fix

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

            def test_cv_not_none_param_grid_none_triggers_search_with_params(
        Severity: Minor
        Found in tests/core/test_policies.py - About 35 mins to fix

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

              def test_cv_none_does_not_trigger_search(self,
          Severity: Minor
          Found in tests/core/test_policies.py - About 35 mins to fix

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

                def test_missing_classes_filled_correctly(
            Severity: Minor
            Found in tests/core/test_policies.py - About 35 mins to fix

              There are no issues that match your filters.

              Category
              Status