nephila/djangocms-helper

View on GitHub
app_helper/base_test.py

Summary

Maintainability
D
2 days
Test Coverage

File base_test.py has 566 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import os.path
import warnings
from collections import OrderedDict
from contextlib import contextmanager
from copy import deepcopy
Severity: Major
Found in app_helper/base_test.py - About 1 day to fix

    Function create_pages has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        def create_pages(source, languages):
            """
            Build pages according to the pages data provided by :py:meth:`get_pages_data`
            and returns the list of the draft version of each
            """
    Severity: Minor
    Found in app_helper/base_test.py - About 3 hrs 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 _prepare_request has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def _prepare_request(self, request, page, user, lang, use_middlewares, use_toolbar=False, secure=False):
            from importlib import import_module
    
            from django.contrib.auth.models import AnonymousUser
    
    
    Severity: Minor
    Found in app_helper/base_test.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 request has 9 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def request(
    Severity: Major
    Found in app_helper/base_test.py - About 1 hr to fix

      Function post_request has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def post_request(
      Severity: Major
      Found in app_helper/base_test.py - About 1 hr to fix

        Function create_user has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def create_user(
        Severity: Major
        Found in app_helper/base_test.py - About 50 mins to fix

          Function get_toolbar_request has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def get_toolbar_request(self, page, user, path=None, edit=False, lang="en", use_middlewares=False, secure=False):
          Severity: Major
          Found in app_helper/base_test.py - About 50 mins to fix

            Function get_request has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def get_request(self, page, lang, user=None, path=None, use_middlewares=False, secure=False, use_toolbar=False):
            Severity: Major
            Found in app_helper/base_test.py - About 50 mins to fix

              Function _prepare_request has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def _prepare_request(self, request, page, user, lang, use_middlewares, use_toolbar=False, secure=False):
              Severity: Major
              Found in app_helper/base_test.py - About 50 mins to fix

                Function get_page_request has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def get_page_request(self, page, user, path=None, edit=False, lang="en", use_middlewares=False, secure=False):
                Severity: Major
                Found in app_helper/base_test.py - About 50 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status