nephila/djangocms-blog

View on GitHub

Showing 73 of 73 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

@plugin_pool.register_plugin
class BlogTagsPlugin(BlogPlugin):
    """Render the list of post tags."""

    module = get_setting("PLUGIN_MODULE_NAME")
Severity: Major
Found in djangocms_blog/cms_plugins.py and 1 other location - About 1 day to fix
djangocms_blog/cms_plugins.py on lines 225..243

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 149.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

@plugin_pool.register_plugin
class BlogArchivePlugin(BlogPlugin):
    """Render the list of months with available posts."""

    module = get_setting("PLUGIN_MODULE_NAME")
Severity: Major
Found in djangocms_blog/cms_plugins.py and 1 other location - About 1 day to fix
djangocms_blog/cms_plugins.py on lines 175..193

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 149.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

            @admin.action(description=_("Disable comments for selection "))
            def disable_comments(self, request, queryset):
                """
                Bulk action to disable comments for selected posts.
                queryset must not be empty (ensured by django CMS).
        Severity: Major
        Found in djangocms_blog/admin.py and 3 other locations - About 4 hrs to fix
        djangocms_blog/admin.py on lines 194..204
        djangocms_blog/admin.py on lines 207..218
        djangocms_blog/admin.py on lines 235..246

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 75.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

            @admin.action(description=_("Enable liveblog for selection"))
            def enable_liveblog(self, request, queryset):
                """
                Bulk action to enable comments for selected posts.
                queryset must not be empty (ensured by django CMS).
        Severity: Major
        Found in djangocms_blog/admin.py and 3 other locations - About 4 hrs to fix
        djangocms_blog/admin.py on lines 194..204
        djangocms_blog/admin.py on lines 207..218
        djangocms_blog/admin.py on lines 221..232

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 75.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

            @admin.action(description=_("Unpublish selection"))
            def make_unpublished(self, request, queryset):
                """
                Bulk action to mark selected posts as unpublished.
                queryset must not be empty (ensured by django CMS).
        Severity: Major
        Found in djangocms_blog/admin.py and 3 other locations - About 4 hrs to fix
        djangocms_blog/admin.py on lines 207..218
        djangocms_blog/admin.py on lines 221..232
        djangocms_blog/admin.py on lines 235..246

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 75.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

            @admin.action(description=_("Enable comments for selection"))
            def enable_comments(self, request, queryset):
                """
                Bulk action to enable comments for selected posts.
                queryset must not be empty (ensured by django CMS).
        Severity: Major
        Found in djangocms_blog/admin.py and 3 other locations - About 4 hrs to fix
        djangocms_blog/admin.py on lines 194..204
        djangocms_blog/admin.py on lines 221..232
        djangocms_blog/admin.py on lines 235..246

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 75.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            def get_fields(self, request, obj=None):
                """
                Return the fields available when editing the plugin.
        
                'template_folder' field is added if ``BLOG_PLUGIN_TEMPLATE_FOLDERS`` contains multiple folders.
        Severity: Major
        Found in djangocms_blog/cms_plugins.py and 1 other location - About 2 hrs to fix
        djangocms_blog/cms_plugins.py on lines 162..172

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 53.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            def get_fields(self, request, obj=None):
                """
                Return the fields available when editing the plugin.
        
                'template_folder' field is added if ``BLOG_PLUGIN_TEMPLATE_FOLDERS`` contains multiple folders.
        Severity: Major
        Found in djangocms_blog/cms_plugins.py and 1 other location - About 2 hrs to fix
        djangocms_blog/cms_plugins.py on lines 48..58

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 53.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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

          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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                def get_image_width(self):
                    if self.main_image:
                        thumbnail_options = get_setting("META_IMAGE_SIZE")
                        if thumbnail_options:
                            return get_thumbnailer(self.main_image).get_thumbnail(thumbnail_options).width
            Severity: Major
            Found in djangocms_blog/models.py and 1 other location - About 1 hr to fix
            djangocms_blog/models.py on lines 419..424

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 49.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                def get_image_height(self):
                    if self.main_image:
                        thumbnail_options = get_setting("META_IMAGE_SIZE")
                        if thumbnail_options:
                            return get_thumbnailer(self.main_image).get_thumbnail(thumbnail_options).height
            Severity: Major
            Found in djangocms_blog/models.py and 1 other location - About 1 hr to fix
            djangocms_blog/models.py on lines 412..417

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 49.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            @receiver(post_save, sender=Post)
            def post_save_post(sender, instance, **kwargs):
                for language in instance.get_available_languages():
                    key = instance.get_cache_key(language, "feed")
                    cache.delete(key)
            Severity: Major
            Found in djangocms_blog/models.py and 1 other location - About 1 hr to fix
            djangocms_blog/models.py on lines 626..630

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 48.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            @receiver(pre_delete, sender=Post)
            def pre_delete_post(sender, instance, **kwargs):
                for language in instance.get_available_languages():
                    key = instance.get_cache_key(language, "feed")
                    cache.delete(key)
            Severity: Major
            Found in djangocms_blog/models.py and 1 other location - About 1 hr to fix
            djangocms_blog/models.py on lines 633..637

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 48.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                        try:  # pragma: no cover
                            import djangocms_page_tags  # NOQA
            
                            menu = self.request.toolbar.get_or_create_menu("page")
                            pagetags = menu.get_or_create_menu("pagetags", "tags")
            Severity: Major
            Found in djangocms_blog/cms_toolbars.py and 1 other location - About 1 hr to fix
            djangocms_blog/cms_toolbars.py on lines 63..69

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 47.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Severity
            Category
            Status
            Source
            Language