django/django

View on GitHub
django/views/debug.py

Summary

Maintainability
F
3 days
Test Coverage

File debug.py has 548 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import functools
import inspect
import itertools
import re
import sys
Severity: Major
Found in django/views/debug.py - About 1 day to fix

    Function get_traceback_frame_variables has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_traceback_frame_variables(self, request, tb_frame):
            """
            Replace the values of variables marked as sensitive with
            stars (*********).
            """
    Severity: Minor
    Found in django/views/debug.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 get_traceback_data has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_traceback_data(self):
            """Return a dictionary containing traceback information."""
            if self.exc_type and issubclass(self.exc_type, TemplateDoesNotExist):
                self.template_does_not_exist = True
                self.postmortem = self.exc_value.chain or [self.exc_value]
    Severity: Minor
    Found in django/views/debug.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 get_post_parameters has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_post_parameters(self, request):
            """
            Replace the values of POST parameters marked as sensitive with
            stars (*********).
            """
    Severity: Minor
    Found in django/views/debug.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 get_exception_traceback_frames has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_exception_traceback_frames(self, exc_value, tb):
            exc_cause = self._get_explicit_or_implicit_cause(exc_value)
            exc_cause_explicit = getattr(exc_value, "__cause__", True)
            if tb is None:
                yield {
    Severity: Minor
    Found in django/views/debug.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 cleanse_setting has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def cleanse_setting(self, key, value):
            """
            Cleanse an individual setting key/value of sensitive content. If the
            value is a dictionary, recursively cleanse the keys in that dictionary.
            """
    Severity: Minor
    Found in django/views/debug.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 technical_404_response has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def technical_404_response(request, exception):
        """Create a technical 404 error response. `exception` is the Http404."""
        try:
            error_url = exception.args[0]["path"]
        except (IndexError, TypeError, KeyError):
    Severity: Minor
    Found in django/views/debug.py - About 55 mins 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

    Avoid deeply nested control flow statements.
    Open

                            if param in cleansed:
                                cleansed[param] = self.cleansed_substitute
                        return cleansed
    Severity: Major
    Found in django/views/debug.py - About 45 mins to fix

      Function get_traceback_frames has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_traceback_frames(self):
              # Get the exception and all its causes
              exceptions = []
              exc_value = self.exc_value
              while exc_value:
      Severity: Minor
      Found in django/views/debug.py - About 45 mins 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 _get_source has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def _get_source(self, filename, loader, module_name):
              source = None
              if hasattr(loader, "get_source"):
                  try:
                      source = loader.get_source(module_name)
      Severity: Minor
      Found in django/views/debug.py - About 45 mins 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 _get_lines_from_file has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def _get_lines_from_file(
              self, filename, lineno, context_lines, loader=None, module_name=None
          ):
              """
              Return context_lines before and after lineno from file.
      Severity: Minor
      Found in django/views/debug.py - About 45 mins 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 technical_500_response has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def technical_500_response(request, exc_type, exc_value, tb, status_code=500):
      Severity: Minor
      Found in django/views/debug.py - About 35 mins to fix

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

            def _get_lines_from_file(
        Severity: Minor
        Found in django/views/debug.py - About 35 mins to fix

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

              def __init__(self, request, exc_type, exc_value, tb, is_email=False):
          Severity: Minor
          Found in django/views/debug.py - About 35 mins to fix

            Function get_cleansed_multivaluedict has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_cleansed_multivaluedict(self, request, multivaluedict):
                    """
                    Replace the keys in a MultiValueDict marked as sensitive with stars.
                    This mitigates leaking sensitive POST parameters if something like
                    request.POST['nonexistent_key'] throws an exception (#21098).
            Severity: Minor
            Found in django/views/debug.py - About 35 mins 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

            There are no issues that match your filters.

            Category
            Status