RasaHQ/rasa_core

View on GitHub
rasa/core/server.py

Summary

Maintainability
F
4 days
Test Coverage

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

    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

    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 __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, status, reason, message, details=None, help_url=None):
    Severity: Minor
    Found in rasa/core/server.py - About 35 mins to fix

      Function create_app has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def create_app(agent=None,
      Severity: Minor
      Found in rasa/core/server.py - About 35 mins to fix

        Avoid too many return statements within this function.
        Open

                    return response.json(responses)
        Severity: Major
        Found in rasa/core/server.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return response.json(domain)
          Severity: Major
          Found in rasa/core/server.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return response.json(tracker.current_state(verbosity))
            Severity: Major
            Found in rasa/core/server.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return response.json(keys)
              Severity: Major
              Found in rasa/core/server.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return response.text(state)
                Severity: Major
                Found in rasa/core/server.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                                  return response.json(evaluation)
                  Severity: Major
                  Found in rasa/core/server.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return response.json(tracker.current_state(verbosity))
                    Severity: Major
                    Found in rasa/core/server.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return response.json(state)
                      Severity: Major
                      Found in rasa/core/server.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                            return app
                        Severity: Major
                        Found in rasa/core/server.py - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                  return response.text('', 204)
                          Severity: Major
                          Found in rasa/core/server.py - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                        return response.text('', 204)
                            Severity: Major
                            Found in rasa/core/server.py - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                      return response.json(parse_data)
                              Severity: Major
                              Found in rasa/core/server.py - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                            return ErrorResponse(400, "FailedIntentEvaluation",
                                Severity: Major
                                Found in rasa/core/server.py - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                              return response.text(domain_yaml,
                                  Severity: Major
                                  Found in rasa/core/server.py - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                                    return ErrorResponse(400, "FailedIntentEvaluation",
                                    Severity: Major
                                    Found in rasa/core/server.py - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                                  return await response.file(model_path)
                                      Severity: Major
                                      Found in rasa/core/server.py - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                                return response.json({
                                        Severity: Major
                                        Found in rasa/core/server.py - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                                      return response.json(responses)
                                          Severity: Major
                                          Found in rasa/core/server.py - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                                    return response.json({
                                            Severity: Major
                                            Found in rasa/core/server.py - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                          return response.json(evaluation)
                                              Severity: Major
                                              Found in rasa/core/server.py - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                        return response.json(tracker.current_state(verbosity))
                                                Severity: Major
                                                Found in rasa/core/server.py - About 30 mins to fix

                                                  There are no issues that match your filters.

                                                  Category
                                                  Status