File __init__.py
has 301 lines of code (exceeds 250 allowed). Consider refactoring. Open
# -*- coding: utf-8 -*-
"""Page Admin module."""
from pages import settings
from pages.models import Page, Content, PageAlias, Media
from pages.phttp import get_language_from_request, get_template_from_request
Function change_view
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def change_view(self, request, object_id, form_url='', extra_context=None):
"""The ``change`` admin view for the
:class:`Page <pages.models.Page>`."""
language = get_language_from_request(request)
extra_context = {
- Read upRead up
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 save_model
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def save_model(self, request, page, form, change):
"""Move the page in the tree if necessary and save every
placeholder :class:`Content <pages.models.Content>`.
"""
language = form.cleaned_data['language']
- Read upRead up
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_fieldsets
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def get_fieldsets(self, request, obj=None):
"""
Add fieldsets of placeholders to the list of already
existing fieldsets.
"""
- Read upRead up
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 save_model
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def save_model(self, request, page, form, change):
Function change_view
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def change_view(self, request, object_id, form_url='', extra_context=None):
Function get_form
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_form(self, request, obj=None, **kwargs):
"""Get a :class:`Page <pages.admin.forms.PageForm>` for the
:class:`Page <pages.models.Page>` and modify its fields depending on
the request."""
- Read upRead up
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"