django/django

View on GitHub
django/contrib/admin/sites.py

Summary

Maintainability
D
2 days
Test Coverage

File sites.py has 476 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from functools import update_wrapper
from weakref import WeakSet

from django.apps import apps
from django.conf import settings
Severity: Minor
Found in django/contrib/admin/sites.py - About 7 hrs to fix

    AdminSite has 28 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class AdminSite:
        """
        An AdminSite object encapsulates an instance of the Django admin application, ready
        to be hooked in to your URLconf. Models are registered with the AdminSite using the
        register() method, and the get_urls() method can then be used to access Django view
    Severity: Minor
    Found in django/contrib/admin/sites.py - About 3 hrs to fix

      Function _build_app_dict has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          def _build_app_dict(self, request, label=None):
              """
              Build the app dictionary. The optional `label` parameter filters models
              of a specific app.
              """
      Severity: Minor
      Found in django/contrib/admin/sites.py - About 2 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 register has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def register(self, model_or_iterable, admin_class=None, **options):
              """
              Register the given model(s) with the given admin class.
      
              The model(s) should be Model classes, not instances.
      Severity: Minor
      Found in django/contrib/admin/sites.py - About 2 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 admin_view has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def admin_view(self, view, cacheable=False):
              """
              Decorator to create an admin view attached to this ``AdminSite``. This
              wraps the view and provides permission checking by calling
              ``self.has_permission``.
      Severity: Minor
      Found in django/contrib/admin/sites.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

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

          def catch_all_view(self, request, url):
              if settings.APPEND_SLASH and not url.endswith("/"):
                  urlconf = getattr(request, "urlconf", None)
                  try:
                      match = resolve("%s/" % request.path_info, urlconf)
      Severity: Minor
      Found in django/contrib/admin/sites.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