cms/plugin_base.py
File plugin_base.py
has 388 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import json
import re
from django import forms
from django.contrib import admin, messages
CMSPluginBase
has 30 functions (exceeds 20 allowed). Consider refactoring. Open
Open
class CMSPluginBase(admin.ModelAdmin, metaclass=CMSPluginBaseMetaclass):
name = ""
module = _("Generic") # To be overridden in child classes
Function __new__
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
Open
def __new__(cls, name, bases, attrs):
super_new = super(CMSPluginBaseMetaclass, cls).__new__
parents = [base for base in bases if isinstance(base, CMSPluginBaseMetaclass)]
if not parents:
# If this is CMSPluginBase itself, and not a subclass, don't do anything
- 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_change_form
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def render_change_form(self, request, context, add=False, change=False, form_url='', obj=None):
Function __init__
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def __init__(self, name, url, data=None, question=None, action='ajax', attributes=None):
Function save_model
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def save_model(self, request, obj, form, change):
"""
Override original method, and add some attributes to obj
This have to be made, because if object is newly created, he must know
where he lives.
- 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"