File cms_tags.py
has 851 lines of code (exceeds 250 allowed). Consider refactoring. Open
from collections import OrderedDict, namedtuple
from copy import copy
from datetime import datetime
from classytags.arguments import Argument, MultiKeywordArgument, MultiValueArgument
Function _get_editable_context
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
def _get_editable_context(self, context, instance, language, edit_fields,
view_method, view_url, querystring, editmode=True):
"""
Populate the context with the requested attributes to trigger the change form
"""
- 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_page_by_untyped_arg
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
def _get_page_by_untyped_arg(page_lookup, request, site_id):
"""
The `page_lookup` argument can be of any of the following types:
- Integer: interpreted as `pk` of the desired page
- String: interpreted as `reverse_id` of the desired page
- 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_data_context
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def _get_data_context(self, context, instance, attribute, edit_fields,
language, filters, view_url, view_method):
"""
Renders the requested attribute and attach changeform trigger to it
- 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 render_extra_menu_items
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def render_extra_menu_items(context, obj, template='cms/toolbar/dragitem_extra_menu.html'):
request = context['request']
toolbar = get_toolbar_from_request(request)
template = toolbar.templates.get_cached_template(template)
- 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_data_context
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def _get_data_context(self, context, instance, attribute, edit_fields,
Function _get_editable_context
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def _get_editable_context(self, context, instance, language, edit_fields,
Function render_tag
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def render_tag(self, context, code, extra_bits, nodelist=None):
request = context.get('request')
if not code or not request:
# an empty string was passed in or the variable is not available in the 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 _get_empty_context
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _get_empty_context(self, context, instance, edit_fields, language,
view_url, view_method, editmode=True):
"""
Inject in a copy of the context the data requested to trigger the edit.
- 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_empty_context
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def _get_empty_context(self, context, instance, edit_fields, language,
Function _show_placeholder_by_id
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _show_placeholder_by_id(context, placeholder_name, reverse_id,
Function get_context
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_context(self, context, instance, language, view_url, view_method,
Function _get_content
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _get_content(self, context, instance, attribute, language, filters):
Function _get_content
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _get_content(self, context, instance, attribute, language, filters):
"""
Renders the requested attribute
"""
extra_context = copy(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 _show_placeholder_by_id
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _show_placeholder_by_id(context, placeholder_name, reverse_id,
lang=None, site=None, use_cache=True):
validate_placeholder_name(placeholder_name)
request = context['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"
Further reading
Avoid too many return
statements within this function. Open
return pages.select_related('node').get(**page_lookup)
Avoid too many return
statements within this function. Open
return page.publisher_public
Avoid too many return
statements within this function. Open
return None
Avoid too many return
statements within this function. Open
return page
Avoid too many return
statements within this function. Open
return page.publisher_draft
Function get_value
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_value(self, context, page_lookup, lang, site):
site_id = get_site_id(site)
request = context.get('request', False)
- 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"