RasaHQ/rasa_core

View on GitHub

Showing 243 of 245 total issues

File embedding_policy.py has 1090 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from collections import namedtuple
import copy
import json
import logging
import os
Severity: Major
Found in rasa/core/policies/embedding_policy.py - About 2 days to fix

    File interactive.py has 1050 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import asyncio
    import logging
    import os
    import tempfile
    import textwrap
    Severity: Major
    Found in rasa/core/training/interactive.py - About 2 days to fix

      File __init__.py has 747 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import time
      import typing
      
      import json
      import jsonpickle
      Severity: Major
      Found in rasa/core/events/__init__.py - About 1 day to fix

        File tf_utils.py has 679 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        from collections import namedtuple
        import tensorflow as tf
        
        
        class TimedNTM(object):
        Severity: Major
        Found in rasa/core/policies/tf_utils.py - About 1 day to fix

          Function as_story_string has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
          Open

              def as_story_string(self, flat=False, e2e=False):
                  # if the result should be flattened, we
                  # will exclude the caption and any checkpoints.
          
                  for s in self.start_checkpoints:
          Severity: Minor
          Found in rasa/core/training/structures.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 server.py has 605 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import glob
          import logging
          import os
          import tempfile
          import zipfile
          Severity: Major
          Found in rasa/core/server.py - About 1 day to fix

            File agent.py has 574 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import asyncio
            import logging
            import os
            import shutil
            import tempfile
            Severity: Major
            Found in rasa/core/agent.py - About 1 day to fix

              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

                File test.py has 543 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import argparse
                import asyncio
                import json
                import logging
                import os
                Severity: Major
                Found in rasa/core/test.py - About 1 day to fix

                  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 structures.py has 524 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  from collections import deque, defaultdict
                  
                  import io
                  import sys
                  import json
                  Severity: Major
                  Found in rasa/core/training/structures.py - About 1 day to fix

                    File test_channels.py has 511 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import json
                    import logging
                    import mock
                    import pytest
                    import sanic
                    Severity: Major
                    Found in tests/core/test_channels.py - About 1 day to fix

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

                      def test_label_tokenizer_featurizer_uses_correct_dtype_float():
                          f = LabelTokenizerSingleStateFeaturizer()
                          f.user_labels = ["a_d"]
                          f.bot_labels = ["c_b"]
                          f.user_vocab = {"a": 0, "d": 1}
                      Severity: Major
                      Found in tests/core/test_featurizer.py and 1 other location - About 1 day to fix
                      tests/core/test_featurizer.py on lines 64..75

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

                      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_label_tokenizer_featurizer_uses_correct_dtype_int():
                          f = LabelTokenizerSingleStateFeaturizer()
                          f.user_labels = ["a_d"]
                          f.bot_labels = ["c_b"]
                          f.user_vocab = {"a": 0, "d": 1}
                      Severity: Major
                      Found in tests/core/test_featurizer.py and 1 other location - About 1 day to fix
                      tests/core/test_featurizer.py on lines 78..89

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

                      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 domain.py has 502 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      import collections
                      import json
                      import logging
                      import os
                      import typing
                      Severity: Major
                      Found in rasa/core/domain.py - About 1 day to fix

                        Function create_app has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def create_app(agent=None,
                                       cors_origins: Union[Text, List[Text]] = "*",
                                       auth_token: Optional[Text] = None,
                                       jwt_secret: Optional[Text] = None,
                                       jwt_method: Text = "HS256",
                        Severity: Minor
                        Found in rasa/core/server.py - About 7 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 featurizers.py has 469 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        import io
                        import jsonpickle
                        import logging
                        import numpy as np
                        import os
                        Severity: Minor
                        Found in rasa/core/featurizers.py - About 7 hrs to fix

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

                                def with_cycles_removed(self) -> 'StoryGraph':
                                    """Create a graph with the cyclic edges removed from this graph."""
                            
                                    story_end_checkpoints = self.story_end_checkpoints.copy()
                                    cyclic_edge_ids = self.cyclic_edge_ids
                            Severity: Minor
                            Found in rasa/core/training/structures.py - About 6 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

                            EmbeddingPolicy has 48 functions (exceeds 20 allowed). Consider refactoring.
                            Open

                            class EmbeddingPolicy(Policy):
                                """Recurrent Embedding Dialogue Policy (REDP)
                            
                                The policy that is used in our paper https://arxiv.org/abs/1811.11707
                                """
                            Severity: Minor
                            Found in rasa/core/policies/embedding_policy.py - About 6 hrs to fix
                              Severity
                              Category
                              Status
                              Source
                              Language