django/django

View on GitHub
django/contrib/admindocs/views.py

Summary

Maintainability
D
1 day
Test Coverage

Function get_context_data has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    def get_context_data(self, **kwargs):
        model_name = self.kwargs['model_name']
        # Get the model class.
        try:
            app_config = apps.get_app_config(self.kwargs['app_label'])
Severity: Minor
Found in django/contrib/admindocs/views.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

File views.py has 339 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import inspect
from importlib import import_module
from inspect import cleandoc
from pathlib import Path

Severity: Minor
Found in django/contrib/admindocs/views.py - About 4 hrs to fix

    Function extract_views_from_urlpatterns has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def extract_views_from_urlpatterns(urlpatterns, base='', namespace=None):
        """
        Return a list of views from a list of urlpatterns.
    
        Each object in the returned list is a two-tuple: (view_func, regex)
    Severity: Minor
    Found in django/contrib/admindocs/views.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 get_context_data has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_context_data(self, **kwargs):
            tags = []
            try:
                engine = Engine.get_default()
            except ImproperlyConfigured:
    Severity: Minor
    Found in django/contrib/admindocs/views.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_context_data has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_context_data(self, **kwargs):
            filters = []
            try:
                engine = Engine.get_default()
            except ImproperlyConfigured:
    Severity: Minor
    Found in django/contrib/admindocs/views.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

    Consider simplifying this complex logical expression.
    Open

                    if isinstance(func, property):
                        fields.append({
                            'name': func_name,
                            'data_type': get_return_data_type(func_name),
                            'verbose': verbose or ''
    Severity: Major
    Found in django/contrib/admindocs/views.py - About 40 mins to fix

      Function get_context_data has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_context_data(self, **kwargs):
              template = self.kwargs['template']
              templates = []
              try:
                  default_engine = Engine.get_default()
      Severity: Minor
      Found in django/contrib/admindocs/views.py - About 25 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