Showing 543 of 559 total issues

File validator.py has 354 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import logging
from collections import defaultdict
from typing import Set, Text, Optional, Dict, Any, List

import rasa.core.training.story_conflict
Severity: Minor
Found in rasa/validator.py - About 4 hrs to fix

    File convert_featurizer.py has 349 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    from __future__ import annotations
    import logging
    import os
    from typing import Any, Dict, List, Optional, Text, Tuple, Type
    
    
    Severity: Minor
    Found in rasa/nlu/featurizers/dense_featurizer/convert_featurizer.py - About 4 hrs to fix

      File facebook.py has 348 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import copy
      import hashlib
      import hmac
      import logging
      import structlog
      Severity: Minor
      Found in rasa/core/channels/facebook.py - About 4 hrs to fix

        File yaml_story_writer.py has 347 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        from collections import OrderedDict
        from pathlib import Path
        from typing import Any, Dict, List, Text, Union, Optional
        
        from ruamel import yaml
        Severity: Minor
        Found in rasa/shared/core/training_data/story_writer/yaml_story_writer.py - About 4 hrs to fix

          File bilou_utils.py has 346 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import logging
          import operator
          from collections import defaultdict, Counter
          from typing import List, Tuple, Text, Optional, Dict, Any, TYPE_CHECKING
          
          
          Severity: Minor
          Found in rasa/nlu/utils/bilou_utils.py - About 4 hrs to fix

            TrainingData has 33 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class TrainingData:
                """Holds loaded intent and entity training data."""
            
                # Validation will ensure and warn if these lower limits are not met
                MIN_EXAMPLES_PER_INTENT = 2
            Severity: Minor
            Found in rasa/shared/nlu/training_data/training_data.py - About 4 hrs to fix

              Function _process_step has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _process_step(
                      self, step: StoryStep, incoming_trackers: List[TrackerWithCachedStates]
                  ) -> TrackersTuple:
                      """Processes a steps events with all trackers.
              
              
              Severity: Minor
              Found in rasa/shared/core/generator.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 precomputation.py has 333 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              from __future__ import annotations
              from typing import Optional, Text, Dict, List, Union, Iterable, Any
              from collections.abc import ValuesView, KeysView
              
              from rasa.engine.graph import GraphComponent
              Severity: Minor
              Found in rasa/core/featurizers/precomputation.py - About 4 hrs to fix

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

                    def prepare_batch(
                        data: Data,
                        start: Optional[int] = None,
                        end: Optional[int] = None,
                        tuple_sizes: Optional[Dict[Text, int]] = None,
                Severity: Minor
                Found in rasa/utils/tensorflow/data_generator.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

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

                def _merge_equivalent_nodes(graph: "networkx.MultiDiGraph", max_history: int) -> None:
                    """Searches for equivalent nodes in the graph and merges them."""
                    changed = True
                    # every node merge changes the graph and can trigger previously
                    # impossible node merges - we need to repeat until
                Severity: Minor
                Found in rasa/shared/core/training_data/visualization.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

                File migrate.py has 328 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import copy
                import shutil
                from pathlib import Path
                from typing import List, Dict, Text, Any, Tuple, Optional, Union
                
                
                Severity: Minor
                Found in rasa/core/migrate.py - About 3 hrs to fix

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

                  import json
                  import logging
                  import uuid
                  import jwt
                  from sanic import Sanic, Blueprint
                  Severity: Minor
                  Found in rasa/core/channels/channel.py - About 3 hrs to fix

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

                    class DialogueStateTracker:
                        """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/shared/core/trackers.py - About 3 hrs to fix

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

                          def as_story_string(self, flat: bool = False, e2e: bool = False) -> Text:
                              """Returns a story as a string."""
                              # if the result should be flattened, we
                              # will exclude the caption and any checkpoints.
                              if flat:
                      Severity: Minor
                      Found in rasa/shared/core/training_data/structures.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

                      File twilio_voice.py has 315 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      from sanic import Blueprint, response
                      from sanic.request import Request
                      from sanic.response import HTTPResponse
                      from twilio.twiml.voice_response import VoiceResponse, Gather
                      from typing import Text, Callable, Awaitable, List, Any, Dict, Optional
                      Severity: Minor
                      Found in rasa/core/channels/twilio_voice.py - About 3 hrs to fix

                        File features.py has 313 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        from __future__ import annotations
                        from typing import Iterable, Union, Text, Optional, List, Any, Tuple, Dict, Set
                        import itertools
                        
                        import numpy as np
                        Severity: Minor
                        Found in rasa/shared/nlu/training_data/features.py - About 3 hrs to fix

                          File single_state_featurizer.py has 312 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          import logging
                          import numpy as np
                          import scipy.sparse
                          from typing import List, Optional, Dict, Text, Set, Any
                          
                          
                          Severity: Minor
                          Found in rasa/core/featurizers/single_state_featurizer.py - About 3 hrs to fix

                            File data_generator.py has 310 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            import math
                            from typing import List, Union, Text, Optional, Any, Tuple, Dict, cast
                            
                            import logging
                            import scipy.sparse
                            Severity: Minor
                            Found in rasa/utils/tensorflow/data_generator.py - About 3 hrs to fix

                              Function _extract_features has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                              Open

                              def _extract_features(
                                  features: List[List[List["Features"]]],
                                  fake_features: List["Features"],
                                  attribute: Text,
                              ) -> Tuple[
                              Severity: Minor
                              Found in rasa/utils/tensorflow/model_data_utils.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

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

                                  def blueprint(
                                      self, on_new_message: Callable[[UserMessage], Awaitable[Any]]
                                  ) -> Blueprint:
                                      telegram_webhook = Blueprint("telegram_webhook", __name__)
                                      out_channel = self.get_output_channel()
                              Severity: Minor
                              Found in rasa/core/channels/telegram.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

                              Severity
                              Category
                              Status
                              Source
                              Language