django/django

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

Summary

Maintainability
D
1 day
Test Coverage

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

import re
from functools import update_wrapper
from weakref import WeakSet

from django.apps import apps
Severity: Minor
Found in django/contrib/admin/sites.py - About 6 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

    AdminSite has 25 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 2 hrs to fix

      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

      There are no issues that match your filters.

      Category
      Status