Showing 77 of 118 total issues
Function make_form
has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring. Open
def make_form(model_, placeholders):
# a new form is needed every single time as some
# initial data are bound
class PageForm(forms.ModelForm):
- 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
File pages_tags.py
has 488 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""Page CMS page_tags template tags"""
from django import template
from django.utils.safestring import SafeText
from django.template import TemplateSyntaxError
from django.conf import settings
File models.py
has 470 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""Django page CMS ``models``."""
from pages.cache import cache
from pages.utils import get_placeholders, normalize_url, get_now
from pages.managers import PageManager, ContentManager
Function _placeholders_recursif
has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring. Open
def _placeholders_recursif(nodelist, plist, blist):
"""Recursively search into a template node list for PlaceholderNode
node."""
# I needed to do this lazy import to compile the documentation
from django.template.loader_tags import BlockNode
- 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 create_and_update_from_json_data
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
def create_and_update_from_json_data(d, user):
"""
Create or update page based on python dict d loaded from JSON data.
This applies all data except for redirect_to, which is done in a
second pass after all pages have been imported,
- 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
File placeholders.py
has 407 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""Placeholder module, that's where the smart things happen."""
from pages.widgets_registry import get_widget
from pages import settings
from pages.models import Content, Media
from pages.widgets import ImageInput, FileInput
Function validate_pages_json_data
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
def validate_pages_json_data(d, preferred_lang):
"""
Check if an import of d will succeed, and return errors.
errors is a list of strings. The import should proceed only if errors
- 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 export_po_files
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
def export_po_files(path='poexport', stdout=None):
"""
Export all the content from the published pages into
po files. The files will be automatically updated
with the new content if you run the command again.
- 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 cookie
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
pages.cookie = function(name, value, options) {
if (typeof value != 'undefined') { // name and value given, set cookie
options = options || {};
if (value === null) {
value = '';
- 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 parse_placeholder
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def parse_placeholder(parser, token):
"""Parse the `PlaceholderNode` parameters.
Return a tuple with the name and parameters."""
params = {}
- 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 bind_sortable
has 96 lines of code (exceeds 25 allowed). Consider refactoring. Open
function bind_sortable() {
// Initialise the table for drag and drop
var down = false;
var move_y = 0;
var start_y = 0;
Function import_po_files
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def import_po_files(path='poexport', stdout=None):
"""
Import all the content updates from the po files into
the pages.
"""
- 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
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
File utils.py
has 300 lines of code (exceeds 250 allowed). Consider refactoring. Open
from django.db.models import Max
from django.utils.translation import ugettext_lazy as _
from django.contrib.sites.models import Site
from django.conf import settings as global_settings
from django.contrib.auth import get_user_model
Page
has 26 functions (exceeds 20 allowed). Consider refactoring. Open
class Page(MPTTModel):
"""
This model contain the status, dates, author, template.
The real content of the page can be found in the
:class:`Content <pages.models.Content>` model.
File pages_list.js
has 284 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* Initialization of the change_list page - this script is run once everything is ready. */
$(function($) {
"use strict";
if(!$("body").hasClass("change-list-pages")) {
Function modify_placeholder
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def modify_placeholder(request, page_id):
"""Modify the content of a page."""
content_type = request.GET.get('content_type')
language_id = request.GET.get('language_id')
page = get_object_or_404(Page, pk=page_id)
- 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 __call__
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def __call__(
self, request, path=None, lang=None, delegation=True,
**kwargs):
current_page = 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 get_content
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def get_content(self, page, language, ctype, language_fallback=False):
"""Gets the latest content string for a particular page, language and
placeholder.
:param page: the concerned page object.
- 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
File managers.py
has 270 lines of code (exceeds 250 allowed). Consider refactoring. Open
# -*- coding: utf-8 -*-
"""Django page CMS ``managers``."""
from pages import settings
from pages.cache import cache
from pages.utils import normalize_url, get_now