divio/django-cms

View on GitHub
cms/appresolver.py

Summary

Maintainability
C
1 day
Test Coverage

Function resolve_page_id has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    def resolve_page_id(self, path):
        """Resolves requested path similar way how resolve does, but instead
        of return callback,.. returns page_id to which was application
        assigned.
        """
Severity: Minor
Found in cms/appresolver.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_app_patterns has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

def _get_app_patterns(site):
    """
    Get a list of patterns for all hooked apps.

    How this works:
Severity: Minor
Found in cms/appresolver.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 recurse_patterns has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

def recurse_patterns(path, pattern_list, page_id, default_args=None,
                     nested=False):
    """
    Recurse over a list of to-be-hooked patterns for a given path prefix
    """
Severity: Minor
Found in cms/appresolver.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 applications_page_check has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def applications_page_check(request, current_page=None, path=None):
    """Tries to find if given path was resolved over application.
    Applications have higher priority than other cms pages.
    """
    if current_page:
Severity: Minor
Found in cms/appresolver.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 _set_permissions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def _set_permissions(patterns, exclude_permissions):
    for pattern in patterns:
        if isinstance(pattern, URLResolver):
            if pattern.namespace in exclude_permissions:
                continue
Severity: Minor
Found in cms/appresolver.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_app_urls has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def get_app_urls(urls):
    for urlconf in urls:
        if isinstance(urlconf, six.string_types):
            mod = import_module(urlconf)
            if not hasattr(mod, 'urlpatterns'):
Severity: Minor
Found in cms/appresolver.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 recurse_patterns has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

def recurse_patterns(path, pattern_list, page_id, default_args=None,
Severity: Minor
Found in cms/appresolver.py - About 35 mins to fix

    There are no issues that match your filters.

    Category
    Status