RasaHQ/rasa_core

View on GitHub

Showing 243 of 245 total issues

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

def test_tracker_store_from_invalid_string(default_domain):
    endpoints_path = "data/test_endpoints/custom_tracker_endpoints.yml"
    store_config = utils.read_endpoint_config(endpoints_path, "tracker_store")
    store_config.type = "any string"

Severity: Major
Found in tests/core/test_tracker_stores.py and 1 other location - About 2 hrs to fix
tests/core/test_tracker_stores.py on lines 106..114

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

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

    def persist_clean(self, filename: Text) -> None:
        """Write domain to a file.

         Strips redundant keys with default 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

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

def test_create_single_input_channels():
    channels = run.create_http_input_channels("facebook", CREDENTIALS_FILE)
    assert len(channels) == 1
    assert channels[0].name() == "facebook"
Severity: Major
Found in tests/core/test_run.py and 1 other location - About 1 hr to fix
tests/core/test_run.py on lines 23..27

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

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

def test_create_single_input_channels_by_class():
    channels = run.create_http_input_channels(
        "rasa.core.channels.channel.RestInput", CREDENTIALS_FILE)
    assert len(channels) == 1
    assert channels[0].name() == "rest"
Severity: Major
Found in tests/core/test_run.py and 1 other location - About 1 hr to fix
tests/core/test_run.py on lines 17..20

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

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

    def applied_events(self) -> List[Event]:
        """Returns all actions that should be applied - w/o reverted events."""

        def undo_till_previous(event_type, done_events):
            """Removes events from `done_events` until `event_type` is
Severity: Minor
Found in rasa/core/trackers.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 visualize has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def visualize(self, output_file=None):
        import networkx as nx
        from rasa.core.training import visualization
        from colorhash import ColorHash

Severity: Minor
Found in rasa/core/training/structures.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 _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

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

        def predict_action_probabilities(self,
                                         tracker: DialogueStateTracker,
                                         domain: Domain) -> List[float]:
            """Predicts the assigned action.
    
    
    Severity: Minor
    Found in rasa/core/policies/mapping_policy.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 a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(self, cell,
                     attention_mechanism,
                     sequence_len,
                     attn_shift_range=0,
                     sparse_attention=False,
    Severity: Minor
    Found in rasa/core/policies/tf_utils.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 _train_tf has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def _train_tf(self,
                      session_data: SessionData,
                      loss: tf.Tensor,
                      mask: tf.Tensor) -> None:
            """Train tf graph."""
    Severity: Minor
    Found in rasa/core/policies/embedding_policy.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 format_bot_output has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def format_bot_output(
        message: Dict[Text, Any]
    ) -> Text:
        """Format a bot response to be displayed in the history table."""
    
    
    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

    Function _warn_about_new_slots has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def _warn_about_new_slots(self, tracker, action_name, events):
            # these are the events from that action we have seen during training
    
            if action_name not in self.policy_ensemble.action_fingerprints:
                return
    Severity: Minor
    Found in rasa/core/processor.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 print_bot_output has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def print_bot_output(message, color=rasa.cli.utils.bcolors.OKBLUE):
        if "text" in message:
            rasa.cli.utils.print_color(message.get("text"),
                                       color)
    
    
    Severity: Minor
    Found in rasa/core/channels/console.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 predict_action_probabilities has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def predict_action_probabilities(self,
                                         tracker: DialogueStateTracker,
                                         domain: Domain) -> List[float]:
            """Predicts the corresponding form action if there is an active form"""
            result = [0.0] * domain.num_actions
    Severity: Minor
    Found in rasa/core/policies/form_policy.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 predict_action_probabilities has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def predict_action_probabilities(self,
                                         tracker: DialogueStateTracker,
                                         domain: Domain) -> List[float]:
            """Predicts the next action if NLU confidence is low.
            """
    Severity: Minor
    Found in rasa/core/policies/two_stage_fallback.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 11 arguments (exceeds 4 allowed). Consider refactoring.
    Open

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

      Function serve_application has 11 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def serve_application(core_model=None,
      Severity: Major
      Found in rasa/core/run.py - About 1 hr to fix

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

        def _find_core_nlu_files_in_directory(directory: Text
                                              ) -> Tuple[Set[Text], Set[Text]]:
            story_files = set()
            nlu_data_files = set()
            for root, _, files in os.walk(directory):
        Severity: Minor
        Found in rasa/data.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