divio/django-cms

View on GitHub
cms/api.py

Summary

Maintainability
F
3 days
Test Coverage

File api.py has 430 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
Public Python API to create CMS contents.

WARNING: None of the functions defined in this module checks for permissions.
You must implement the necessary permission checks in your own code before
Severity: Minor
Found in cms/api.py - About 6 hrs to fix

    Function add_plugin has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

    def add_plugin(placeholder, plugin_type, language, position='last-child',
                   target=None, **data):
        """
        Add a plugin to a placeholder
    
    
    Severity: Minor
    Found in cms/api.py - About 4 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 create_page has 25 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def create_page(title, template, language, menu_title=None, slug=None,
    Severity: Major
    Found in cms/api.py - About 3 hrs to fix

      Function publish_pages has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

      def publish_pages(include_unpublished=False, language=None, site=None):
          """
          Create published public version of selected drafts.
          """
          warnings.warn('This API function will be removed in django CMS 4. For publishing functionality use a package '
      Severity: Minor
      Found in cms/api.py - About 2 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 create_page has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      def create_page(title, template, language, menu_title=None, slug=None,
                      apphook=None, apphook_namespace=None, redirect=None, meta_description=None,
                      created_by='python-api', parent=None,
                      publication_date=None, publication_end_date=None,
                      in_navigation=False, soft_root=False, reverse_id=None,
      Severity: Minor
      Found in cms/api.py - About 2 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 create_page_user has 14 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def create_page_user(created_by, user,
      Severity: Major
      Found in cms/api.py - About 1 hr to fix

        Function assign_user_to_page has 14 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def assign_user_to_page(page, user, grant_on=ACCESS_PAGE_AND_DESCENDANTS,
        Severity: Major
        Found in cms/api.py - About 1 hr to fix

          Function create_title has 11 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def create_title(language, title, page, menu_title=None, slug=None,
          Severity: Major
          Found in cms/api.py - About 1 hr to fix

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

            def _verify_apphook(apphook, namespace):
                """
                Verifies the apphook given is valid and returns the normalized form (name)
                """
                apphook_pool.discover_apps()
            Severity: Minor
            Found in cms/api.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 add_plugin has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def add_plugin(placeholder, plugin_type, language, position='last-child',
            Severity: Minor
            Found in cms/api.py - About 45 mins to fix

              There are no issues that match your filters.

              Category
              Status