File pagemodel.py
has 1273 lines of code (exceeds 250 allowed). Consider refactoring. Open
import copy
from collections import OrderedDict
from logging import getLogger
from os.path import join
Page
has 93 functions (exceeds 20 allowed). Consider refactoring. Open
class Page(models.Model):
"""
A simple hierarchical page model
"""
LIMIT_VISIBILITY_IN_MENU_CHOICES = (
Function copy
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def copy(self, site, parent_node=None, language=None,
translations=True, permissions=False, extensions=True):
from cms.utils.page import get_available_slug
if parent_node:
- 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_admin_tree_title
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def get_admin_tree_title(self):
from cms.models.titlemodels import EmptyTitle
language = get_language()
if not self.title_cache:
- 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 move_page
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def move_page(self, target_node, position='first-child'):
"""
Called from admin interface when page is moved. Should be used on
all the places which are changing page position. Used like an interface
to django-treebeard, but after move is done page_moved signal is fired.
- 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_title_cache
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def _get_title_cache(self, language, fallback, force_reload):
if not language:
language = get_language()
force_reload = (force_reload or language not in self.title_cache)
- 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 copy_with_descendants
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def copy_with_descendants(self, target_node=None, position=None,
copy_permissions=True, target_site=None):
"""
Copy a page [ and all its descendants to a new location ]
"""
- 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 copy
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def copy(self, site, parent_node=None, language=None,
Function publish
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def publish(self, language):
"""
:returns: True if page was successfully published.
"""
from cms.utils.permissions import get_current_user_name
- 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 is_new_dirty
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def is_new_dirty(self):
if self.pk:
fields = [
'publication_date', 'publication_end_date', 'in_navigation', 'soft_root', 'reverse_id',
'navigation_extenders', 'template', 'login_required', 'limit_visibility_in_menu'
- 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 copy_with_descendants
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def copy_with_descendants(self, target_node=None, position=None,
Function get_title_obj_attribute
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_title_obj_attribute(self, attrname, language=None, fallback=True, force_reload=False):
Function _update_title_path_recursive
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _update_title_path_recursive(self, language, slug=None):
assert self.publisher_is_draft
from cms.models import Title
if self.node.is_leaf() or language not in self.get_languages():
- 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
Avoid too many return
statements within this function. Open
return title.slug
Function clear_cache
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def clear_cache(self, language=None, menu=False, placeholder=False):
from cms.cache import invalidate_cms_page_cache
if get_cms_setting('PAGE_CACHE'):
# Clears all the page caches
- 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 update
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def update(self, refresh=False, draft_only=True, **data):
assert self.publisher_is_draft
cls = self.__class__
- 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
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def save(self, **kwargs):
# delete template cache
if hasattr(self, '_template_cache'):
delattr(self, '_template_cache')
- 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 rescan_placeholders
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def rescan_placeholders(self):
"""
Rescan and if necessary create placeholders in the current template.
"""
existing = OrderedDict()
- 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"