RasaHQ/rasa_core

View on GitHub

Showing 243 of 245 total issues

File visualization.py has 415 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from collections import defaultdict, deque

import random
import re
from typing import Any, Text, List, Dict, Optional, TYPE_CHECKING
Severity: Minor
Found in rasa/core/training/visualization.py - About 5 hrs to fix

    Domain has 43 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Domain(object):
        """The domain specifies the universe in which the bot's policy acts.
    
        A Domain subclass provides the actions the bot can take, the intents
        and entities it can recognise"""
    Severity: Minor
    Found in rasa/core/domain.py - About 5 hrs to fix

      File action.py has 375 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import aiohttp
      import copy
      import json
      
      import logging
      Severity: Minor
      Found in rasa/core/actions/action.py - About 5 hrs to fix

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

        def test_binary_featurizer_handles_on_non_existing_probabilistic_features():
            f = BinarySingleStateFeaturizer()
            f.input_state_map = {"a": 0, "b": 3, "c": 2, "d": 1}
            f.num_features = len(f.input_state_map)
            encoded = f.encode({"a": 1.0, "b": 0.2, "c": 0.0, "e": 1.0})
        Severity: Major
        Found in tests/core/test_featurizer.py and 1 other location - About 5 hrs to fix
        tests/core/test_featurizer.py on lines 10..15

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

        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

        DialogueStateTracker has 38 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class DialogueStateTracker(object):
            """Maintains the state of a conversation.
        
            The field max_event_history will only give you these last events,
            it can be set in the tracker_store"""
        Severity: Minor
        Found in rasa/core/trackers.py - About 5 hrs to fix

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

          def test_binary_featurizer_handles_on_non_existing_features():
              f = BinarySingleStateFeaturizer()
              f.input_state_map = {"a": 0, "b": 3, "c": 2, "d": 1}
              f.num_features = len(f.input_state_map)
              encoded = f.encode({"a": 1.0, "b": 1.0, "c": 0.0, "e": 1.0})
          Severity: Major
          Found in tests/core/test_featurizer.py and 1 other location - About 5 hrs to fix
          tests/core/test_featurizer.py on lines 34..39

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

          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

          File processor.py has 374 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import json
          import logging
          from types import LambdaType
          from typing import Any, Dict, List, Optional, Text, Tuple
          
          
          Severity: Minor
          Found in rasa/core/processor.py - About 5 hrs to fix

            File trackers.py has 372 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import typing
            from collections import deque
            
            import copy
            import io
            Severity: Minor
            Found in rasa/core/trackers.py - About 4 hrs to fix

              Function requires_auth has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
              Open

              def requires_auth(app: Sanic,
                                token: Optional[Text] = None
                                ) -> Callable[[Any], Any]:
                  """Wraps a request handler with token authentication."""
              
              
              Severity: Minor
              Found in rasa/core/server.py - About 4 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 check_domain_sanity has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
              Open

              def check_domain_sanity(domain):
                  """Make sure the domain is properly configured.
              
                  Checks the settings and checks if there are duplicate actions,
                  intents, slots and entities."""
              Severity: Minor
              Found in rasa/core/domain.py - About 4 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 generate_all_prior_trackers has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
              Open

                  def generate_all_prior_trackers(self):
                      # type: () -> Generator[DialogueStateTracker, None, None]
                      """Returns a generator of the previous trackers of this tracker.
              
                      The resulting array is representing
              Severity: Minor
              Found in rasa/core/trackers.py - About 4 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 _merge_equivalent_nodes has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
              Open

              def _merge_equivalent_nodes(graph, max_history):
                  """Searches for equivalent nodes in the graph and merges them."""
              
                  changed = True
                  # every node merge changes the graph and can trigger previously
              Severity: Minor
              Found in rasa/core/training/visualization.py - About 4 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

              File test_trackers.py has 331 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import json
              
              import fakeredis
              import pytest
              import tempfile
              Severity: Minor
              Found in tests/core/test_trackers.py - About 3 hrs to fix

                Function _create_states has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                Open

                    def _create_states(self,
                                       tracker: DialogueStateTracker,
                                       domain: Domain,
                                       is_binary_training: bool = False
                                       ) -> List[Dict[Text, float]]:
                Severity: Minor
                Found in rasa/core/featurizers.py - About 3 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

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

                def test_binary_featurizer_uses_correct_dtype_int():
                    f = BinarySingleStateFeaturizer()
                    f.input_state_map = {"a": 0, "b": 3, "c": 2, "d": 1}
                    f.num_features = len(f.input_state_map)
                    encoded = f.encode({"a": 1.0, "b": 1.0, "c": 0.0})
                Severity: Major
                Found in tests/core/test_featurizer.py and 1 other location - About 3 hrs to fix
                tests/core/test_featurizer.py on lines 26..31

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

                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_binary_featurizer_uses_correct_dtype_float():
                    f = BinarySingleStateFeaturizer()
                    f.input_state_map = {"a": 0, "b": 3, "c": 2, "d": 1}
                    f.num_features = len(f.input_state_map)
                    encoded = f.encode({"a": 1.0, "b": 0.2, "c": 0.0})
                Severity: Major
                Found in tests/core/test_featurizer.py and 1 other location - About 3 hrs to fix
                tests/core/test_featurizer.py on lines 18..23

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

                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_get_core_directory(project):
                    data_dir = os.path.join(project, "data")
                    core_directory = data.get_core_directory([data_dir])
                    stories = os.listdir(core_directory)
                
                
                Severity: Major
                Found in tests/core/test_data.py and 1 other location - About 3 hrs to fix
                tests/core/test_data.py on lines 21..28

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

                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_get_nlu_directory(project):
                    data_dir = os.path.join(project, "data")
                    nlu_directory = data.get_nlu_directory([data_dir])
                
                    nlu_files = os.listdir(nlu_directory)
                Severity: Major
                Found in tests/core/test_data.py and 1 other location - About 3 hrs to fix
                tests/core/test_data.py on lines 12..18

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

                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

                File dsl.py has 322 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                # -*- coding: utf-8 -*-
                import asyncio
                import io
                import json
                import logging
                Severity: Minor
                Found in rasa/core/training/dsl.py - About 3 hrs to fix

                  File channel.py has 311 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import asyncio
                  from asyncio import Queue, CancelledError
                  
                  import inspect
                  import json
                  Severity: Minor
                  Found in rasa/core/channels/channel.py - About 3 hrs to fix
                    Severity
                    Category
                    Status
                    Source
                    Language