batiste/django-page-cms

View on GitHub
pages/admin/__init__.py

Summary

Maintainability
C
7 hrs
Test Coverage

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
Severity: Minor
Found in pages/admin/__init__.py - About 3 hrs to fix

    Function change_view has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def change_view(self, request, object_id, form_url='', extra_context=None):
            """The ``change`` admin view for the
            :class:`Page <pages.models.Page>`."""
            language = get_language_from_request(request)
            extra_context = {
    Severity: Minor
    Found in pages/admin/__init__.py - About 1 hr to fix

    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_model has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def save_model(self, request, page, form, change):
            """Move the page in the tree if necessary and save every
            placeholder :class:`Content <pages.models.Content>`.
            """
            language = form.cleaned_data['language']
    Severity: Minor
    Found in pages/admin/__init__.py - About 55 mins to fix

    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_fieldsets has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_fieldsets(self, request, obj=None):
            """
            Add fieldsets of placeholders to the list of already
            existing fieldsets.
            """
    Severity: Minor
    Found in pages/admin/__init__.py - About 45 mins to fix

    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_model has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def save_model(self, request, page, form, change):
    Severity: Minor
    Found in pages/admin/__init__.py - About 35 mins to fix

      Function change_view has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def change_view(self, request, object_id, form_url='', extra_context=None):
      Severity: Minor
      Found in pages/admin/__init__.py - About 35 mins to fix

        Function get_form has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_form(self, request, obj=None, **kwargs):
                """Get a :class:`Page <pages.admin.forms.PageForm>` for the
                :class:`Page <pages.models.Page>` and modify its fields depending on
                the request."""
        
        
        Severity: Minor
        Found in pages/admin/__init__.py - About 25 mins to fix

        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

        There are no issues that match your filters.

        Category
        Status