File placeholderadmin.py
has 933 lines of code (exceeds 250 allowed). Consider refactoring. Open
import uuid
import warnings
from urllib.parse import parse_qsl, urlparse
from django.contrib.admin.helpers import AdminForm
PlaceholderAdminMixin
has 29 functions (exceeds 20 allowed). Consider refactoring. Open
class PlaceholderAdminMixin:
def _get_attached_admin(self, placeholder):
return placeholder._get_attached_admin(admin_site=self.admin_site)
Function move_plugin
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def move_plugin(self, request):
"""
Performs a move or a "paste" operation (when «move_a_copy» is set)
POST request with following parameters:
- 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_plugin
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def _move_plugin(self, request, plugin, target_language,
target_placeholder, tree_order, target_parent=None):
if not self.has_move_plugin_permission(request, plugin, target_placeholder):
message = force_str(_("You have no permission to move this plugin"))
raise PermissionDenied(message)
- 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 edit_field
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def edit_field(self, request, object_id, language):
obj = self._get_object_for_single_field(object_id, language)
opts = obj.__class__._meta
saved_successfully = False
cancel_clicked = request.POST.get("_cancel", 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"
Further reading
Function _move_plugin
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _move_plugin(self, request, plugin, target_language,
Function _paste_plugin
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _paste_plugin(self, request, plugin, target_language,
Function _paste_placeholder
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _paste_placeholder(self, request, plugin, target_language,
Function clear_placeholder
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def clear_placeholder(self, request, placeholder_id):
placeholder = get_object_or_404(Placeholder, pk=placeholder_id)
language = request.GET.get('language')
if placeholder.pk == request.toolbar.clipboard.pk:
- 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 delete_plugin
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def delete_plugin(self, request, plugin_id):
plugin = self._get_plugin_from_id(plugin_id)
if not self.has_delete_plugin_permission(request, plugin):
return HttpResponseForbidden(force_str(
- 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 HttpResponse(data, content_type='application/json')
Avoid too many return
statements within this function. Open
return TemplateResponse(request, "admin/cms/page/plugin/delete_confirmation.html", context)
Avoid too many return
statements within this function. Open
return render(request, 'admin/cms/page/plugin/change_form.html', context)
Function copy_plugins
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def copy_plugins(self, request):
"""
POST request should have the following data:
- cms_path
- 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 add_plugin
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def add_plugin(self, request):
"""
Shows the add plugin form and saves it on POST.
Requires the following GET parameters:
- 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"