RasaHQ/rasa_core

View on GitHub

Showing 243 of 245 total issues

Avoid too many return statements within this function.
Open

            return RasaNLUHttpInterpreter(name_parts[1],
Severity: Major
Found in rasa/core/interpreter.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                return TrackerStore.load_tracker_from_module_string(domain, store)
    Severity: Major
    Found in rasa/core/tracker_store.py - About 30 mins to fix

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

          @pytest.fixture(params=[{"a": "b"}, 1, True, "asd", "🌴"])
          def invalid_value(self, request):
              return request.param
      Severity: Minor
      Found in tests/core/test_slots.py and 1 other location - About 30 mins to fix
      tests/core/test_slots.py on lines 148..150

      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 32.

      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

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

          @pytest.fixture(params=[{"a": "b"}, 2, True, "asd", "🌴"])
          def invalid_value(self, request):
              return request.param
      Severity: Minor
      Found in tests/core/test_slots.py and 1 other location - About 30 mins to fix
      tests/core/test_slots.py on lines 114..116

      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 32.

      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 from_endpoint_config has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def from_endpoint_config(broker_config: Optional[EndpointConfig]
                               ) -> Optional['EventChannel']:
          """Instantiate an event channel based on its configuration."""
      
          if broker_config is None:
      Severity: Minor
      Found in rasa/core/broker.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

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

          def blueprint(self, on_new_message):
              sio = AsyncServer(async_mode='sanic')
              socketio_webhook = SocketBlueprint(sio, self.socketio_path,
                                                 'socketio_webhook', __name__)
      
      
      Severity: Minor
      Found in rasa/core/channels/socketio.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

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

          def blueprint(self, on_new_message):
              custom_webhook = Blueprint(
                  'custom_webhook_{}'.format(type(self).__name__),
                  inspect.getmodule(self).__name__)
      
      
      Severity: Minor
      Found in rasa/core/channels/channel.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

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

          def resolve_by_type(
              type_name: Text,
              default: Optional[Type['Event']] = None
          ) -> Optional[Type['Event']]:
              """Returns a slots class by its type name."""
      Severity: Minor
      Found in rasa/core/events/__init__.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

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

          def state_size(self):
              """The `state_size` property of `TimeAttentionWrapper`.
              Returns:
                  A `TimeAttentionWrapperState` tuple containing shapes
                  used by this object.
      Severity: Minor
      Found in rasa/core/policies/tf_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

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

          def _training_events_from_trackers(training_trackers):
              events_metadata = defaultdict(set)
      
              for t in training_trackers:
                  tracker = t.init_copy()
      Severity: Minor
      Found in rasa/core/policies/ensemble.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

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

          def validate_outdoor_seating(value: Text,
                                       dispatcher: CollectingDispatcher,
                                       tracker: Tracker,
                                       domain: Dict[Text, Any]) -> Any:
              """Validate outdoor_seating value."""
      Severity: Minor
      Found in examples/formbot/actions.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

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

          def create(
              obj: Union['NaturalLanguageGenerator', EndpointConfig, None],
              domain: Optional[Domain]
          ) -> 'NaturalLanguageGenerator':
              """Factory to create a generator."""
      Severity: Minor
      Found in rasa/core/nlg/generator.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

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

          def _recall_using_delorean(self, old_states, tracker, domain):
              """Recursively go to the past to correctly forget slots,
                  and then back to the future to recall."""
      
              logger.debug("Launch DeLorean...")
      Severity: Minor
      Found in rasa/core/policies/memoization.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

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

          def find_tracker_store(domain, store=None, event_broker=None):
              if store is None or store.type is None:
                  return InMemoryTrackerStore(domain, event_broker=event_broker)
              elif store.type == 'redis':
                  return RedisTrackerStore(domain=domain,
      Severity: Minor
      Found in rasa/core/tracker_store.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

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

      def train_core(args: argparse.Namespace,
                     train_path: Optional[Text] = None) -> Optional[Text]:
          from rasa.train import train_core
          import asyncio
      
      
      Severity: Minor
      Found in rasa/cli/train.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

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

          def call(self, inputs, state):
              """LSTM cell with layer normalization and recurrent dropout."""
              c, h = state
              args = tf.concat([inputs, h], 1)
              concat = self._linear(args)
      Severity: Minor
      Found in rasa/core/policies/tf_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

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

          def _tf_sim(self,
                      embed_dialogue: tf.Tensor,
                      embed_action: tf.Tensor,
                      mask: Optional[tf.Tensor]
                      ) -> Tuple[tf.Tensor, tf.Tensor]:
      Severity: Minor
      Found in rasa/core/policies/embedding_policy.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

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

          def predict_action_probabilities(self,
                                           tracker: DialogueStateTracker,
                                           domain: Domain) -> List[float]:
              """Predicts the next action the bot should take
                  after seeing the tracker.
      Severity: Minor
      Found in rasa/core/policies/memoization.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

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

          def retrieve(self, sender_id):
              stored = self.conversations.find_one({"sender_id": sender_id})
      
              # look for conversations which have used an `int` sender_id in the past
              # and update them.
      Severity: Minor
      Found in rasa/core/tracker_store.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

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

      def _predict_tracker_actions(tracker, agent: 'Agent',
                                   fail_on_prediction_errors=False,
                                   use_e2e=False):
          from rasa.core.trackers import DialogueStateTracker
      
      
      Severity: Minor
      Found in rasa/core/test.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

      Severity
      Category
      Status
      Source
      Language