RasaHQ/rasa_core

View on GitHub
rasa/core/training/generator.py

Summary

Maintainability
F
3 days
Test Coverage

Function generate has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
Open

    def generate(self, silent: bool = False) -> List[TrackerWithCachedStates]:
        if (self.config.remove_duplicates and
                self.config.unique_last_num_states):
            logger.debug("Generated trackers will be deduplicated "
                         "based on their unique last {} states."
Severity: Minor
Found in rasa/core/training/generator.py - About 1 day 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

File generator.py has 459 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
from collections import defaultdict, namedtuple, deque

import copy
import logging
Severity: Minor
Found in rasa/core/training/generator.py - About 7 hrs to fix

    Function _issue_unused_checkpoint_notification has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def _issue_unused_checkpoint_notification(
            self,
            unused_checkpoints: Set[Text]
        ) -> None:
            """Warns about unused story blocks.
    Severity: Minor
    Found in rasa/core/training/generator.py - About 2 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 _process_step has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def _process_step(
            self,
            step: StoryStep,
            incoming_trackers: List[TrackerWithCachedStates]
        ) -> TrackersTuple:
    Severity: Minor
    Found in rasa/core/training/generator.py - About 2 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 _mark_first_action_in_story_steps_as_unpredictable has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def _mark_first_action_in_story_steps_as_unpredictable(self) -> None:
            """Mark actions which shouldn't be used during ML training.
    
            If a story starts with an action, we can not use
            that first action as a training example, as there is no
    Severity: Minor
    Found in rasa/core/training/generator.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 _remove_duplicate_trackers has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def _remove_duplicate_trackers(self,
                                       trackers: List[TrackerWithCachedStates]
                                       ) -> TrackersTuple:
            """Removes trackers that create equal featurizations
                for current story step.
    Severity: Minor
    Found in rasa/core/training/generator.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 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

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

      Function update has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def update(self, event: Event, skip_states: bool = False) -> None:
              """Modify the state of the tracker according to an ``Event``. """
      
              # if `skip_states` is `True`, this function behaves exactly like the
              # normal update of the `DialogueStateTracker`
      Severity: Minor
      Found in rasa/core/training/generator.py - About 55 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 __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self, sender_id, slots,
      Severity: Minor
      Found in rasa/core/training/generator.py - About 35 mins to fix

        There are no issues that match your filters.

        Category
        Status