nephila/djangocms-blog

View on GitHub

Showing 24 of 73 total issues

File models.py has 544 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import hashlib

from aldryn_apphooks_config.fields import AppHookConfigField
from aldryn_apphooks_config.managers.parler import AppHookConfigTranslatableManager
from cms.models import CMSPlugin, PlaceholderField
Severity: Major
Found in djangocms_blog/models.py - About 1 day to fix

    Function get_nodes has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_nodes(self, request):
            """
            Generates the nodelist
    
            :param request:
    Severity: Minor
    Found in djangocms_blog/cms_menus.py - About 1 day 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

    File admin.py has 490 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    from copy import deepcopy
    
    from aldryn_apphooks_config.admin import BaseAppHookConfig, ModelAppHookConfig
    from cms.admin.placeholderadmin import FrontendEditableAdminMixin, PlaceholderAdminMixin
    from cms.models import CMSPlugin, ValidationError
    Severity: Minor
    Found in djangocms_blog/admin.py - About 7 hrs to fix

      File settings.py has 454 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """
      List of settings that can be set in project django settings.
      """
      
      from django.utils.translation import gettext_lazy as _
      Severity: Minor
      Found in djangocms_blog/settings.py - About 6 hrs to fix

        Post has 21 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Post(KnockerModel, BlogMetaMixin, TranslatableModel):
            """
            Blog post
            """
        
        
        Severity: Minor
        Found in djangocms_blog/models.py - About 2 hrs to fix

          PostAdmin has 21 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class PostAdmin(PlaceholderAdminMixin, FrontendEditableAdminMixin, ModelAppHookConfig, TranslatableAdmin):
              form = PostAdminForm
              list_display = ["title", "author", "date_published", "app_config", "all_languages_column", "date_published_end"]
              search_fields = ("translations__title",)
              date_hierarchy = "date_published"
          Severity: Minor
          Found in djangocms_blog/admin.py - About 2 hrs to fix

            Function modify has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
                    """
                    Actual modifier function
                    :param request: request
                    :param nodes: complete list of nodes
            Severity: Minor
            Found in djangocms_blog/cms_menus.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 get_fieldsets has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_fieldsets(self, request, obj=None):
                    """
                    Customize the fieldsets according to the app settings
            
                    :param request: request
            Severity: Minor
            Found in djangocms_blog/admin.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 __init__ has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                def __init__(self, *args, **kwargs):
                    self.base_fields["meta_description"].validators = [MaxLengthValidator(get_setting("META_DESCRIPTION_LENGTH"))]
                    original_attrs = self.base_fields["meta_description"].widget.attrs
                    if "cols" in original_attrs:
                        del original_attrs["cols"]
            Severity: Minor
            Found in djangocms_blog/forms.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 towncrier_check has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

            def towncrier_check(c):  # NOQA
                """Check towncrier files."""
                output = io.StringIO()
                c.run("git branch -a --contains HEAD", out_stream=output)
                skipped_branch_prefix = ["pull/", "release/", "develop", "master", "HEAD"]
            Severity: Minor
            Found in tasks.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 __init__ has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def __init__(self, *args, **kwargs):
                    self.base_fields["meta_description"].validators = [MaxLengthValidator(get_setting("META_DESCRIPTION_LENGTH"))]
                    original_attrs = self.base_fields["meta_description"].widget.attrs
                    if "cols" in original_attrs:
                        del original_attrs["cols"]
            Severity: Minor
            Found in djangocms_blog/forms.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 media_images has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            def media_images(context, post, main=True):
                """
                Extract images of the given size from all the
                :py:class:`djangocms_blog.media.base.MediaAttachmentPluginMixin`
                plugins in the ``media`` placeholder of the provided post.
            Severity: Minor
            Found in djangocms_blog/templatetags/djangocms_blog.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 media_params has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def media_params(self):
                    """
                    Retrieves the media information.
            
                    Minimal keys returned:
            Severity: Minor
            Found in djangocms_blog/media/base.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 _get_language has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            def _get_language(instance, language):
                available_languages = instance.get_available_languages()
                if language and language in available_languages:
                    return language
                language = get_language()
            Severity: Minor
            Found in djangocms_blog/models.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 get_absolute_url has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_absolute_url(self, lang=None):
                    lang = _get_language(self, lang)
                    with switch_language(self, lang):
                        category = self.categories.first()
                        kwargs = {}
            Severity: Minor
            Found in djangocms_blog/models.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 modify has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
            Severity: Minor
            Found in djangocms_blog/cms_menus.py - About 45 mins to fix

              Avoid too many return statements within this function.
              Open

                  return language
              Severity: Major
              Found in djangocms_blog/models.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return nodes
                Severity: Major
                Found in djangocms_blog/cms_menus.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return nodes
                  Severity: Major
                  Found in djangocms_blog/cms_menus.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return nodes
                    Severity: Major
                    Found in djangocms_blog/cms_menus.py - About 30 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language