django/django

View on GitHub
django/http/request.py

Summary

Maintainability
D
2 days
Test Coverage

File request.py has 475 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import cgi
import codecs
import copy
from io import BytesIO
from itertools import chain
Severity: Minor
Found in django/http/request.py - About 7 hrs to fix

    HttpRequest has 32 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class HttpRequest:
        """A basic HTTP request."""
    
        # The encoding used in GET/POST dicts. None means use default setting.
        _encoding = None
    Severity: Minor
    Found in django/http/request.py - About 4 hrs to fix

      Function _load_post_and_files has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def _load_post_and_files(self):
              """Populate self._post and self._files if the content-type is a form type"""
              if self.method != 'POST':
                  self._post, self._files = QueryDict(encoding=self._encoding), MultiValueDict()
                  return
      Severity: Minor
      Found in django/http/request.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 build_absolute_uri has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def build_absolute_uri(self, location=None):
              """
              Build an absolute URI from the location and the variables available in
              this request. If no ``location`` is specified, build the absolute URI
              using request.get_full_path(). If the location is absolute, convert it
      Severity: Minor
      Found in django/http/request.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 body has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def body(self):
              if not hasattr(self, '_body'):
                  if self._read_started:
                      raise RawPostDataException("You cannot access body after reading from request's data stream")
      
      
      Severity: Minor
      Found in django/http/request.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

      Function _get_raw_host has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def _get_raw_host(self):
              """
              Return the HTTP host using the environment or request headers. Skip
              allowed hosts protection, so may return an insecure host.
              """
      Severity: Minor
      Found in django/http/request.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

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

          def get_signed_cookie(self, key, default=RAISE_ERROR, salt='', max_age=None):
              """
              Attempt to return a signed cookie. If the signature fails or the
              cookie has expired, raise an exception, unless the `default` argument
              is provided,  in which case return that value.
      Severity: Minor
      Found in django/http/request.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 scheme has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def scheme(self):
              if settings.SECURE_PROXY_SSL_HEADER:
                  try:
                      header, secure_value = settings.SECURE_PROXY_SSL_HEADER
                  except ValueError:
      Severity: Minor
      Found in django/http/request.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_host has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_host(self):
              """Return the HTTP host using the environment or request headers."""
              host = self._get_raw_host()
      
              # Allow variants of localhost if ALLOWED_HOSTS is empty and DEBUG=True.
      Severity: Minor
      Found in django/http/request.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