divio/django-cms

View on GitHub
cms/admin/pageadmin.py

Summary

Maintainability
F
1 wk
Test Coverage

File pageadmin.py has 1432 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
from collections import namedtuple
import copy
import json
import sys
Severity: Major
Found in cms/admin/pageadmin.py - About 3 days to fix

    BasePageAdmin has 60 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class BasePageAdmin(PlaceholderAdminMixin, admin.ModelAdmin):
        form = AddPageForm
        ordering = ('node__path',)
        search_fields = ('=id', 'title_set__slug', 'title_set__title', 'reverse_id')
        add_general_fields = ['title', 'slug', 'language', 'template']
    Severity: Major
    Found in cms/admin/pageadmin.py - About 1 day to fix

      Function publish_page has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
      Open

          def publish_page(self, request, page_id, language):
              page = self.get_object(request, object_id=page_id)
      
              if page and not self.has_publish_permission(request, obj=page):
                  return HttpResponseForbidden(force_text(_("You do not have permission to publish this page")))
      Severity: Minor
      Found in cms/admin/pageadmin.py - About 7 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 resolve has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
      Open

          def resolve(self, request):
              if not request.user.is_staff:
                  return HttpResponse('/', content_type='text/plain')
              obj = False
              url = False
      Severity: Minor
      Found in cms/admin/pageadmin.py - About 6 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 delete_translation has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          def delete_translation(self, request, object_id, extra_context=None):
              if 'language' in request.GET:
                  language = request.GET['language']
              else:
                  language = get_language_from_request(request)
      Severity: Minor
      Found in cms/admin/pageadmin.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 get_tree_rows has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_tree_rows(self, request, pages, language, depth=1,
                            follow_descendants=True):
              """
              Used for rendering the page tree, inserts into context everything what
              we need for single item
      Severity: Minor
      Found in cms/admin/pageadmin.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 changelist_view has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def changelist_view(self, request, extra_context=None):
              from django.contrib.admin.views.main import ERROR_FLAG
      
              if not self.has_change_permission(request, obj=None):
                  raise PermissionDenied
      Severity: Minor
      Found in cms/admin/pageadmin.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_copy_dialog has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_copy_dialog(self, request, page_id):
              if not get_cms_setting('PERMISSION'):
                  return HttpResponse('')
      
              page = self.get_page_from_id(page_id)
      Severity: Minor
      Found in cms/admin/pageadmin.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 delete_view has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def delete_view(self, request, object_id, extra_context=None):
              # This is an unfortunate copy/paste from django's delete view.
              # The reason is to add the descendant pages to the deleted objects list.
              opts = self.model._meta
              app_label = opts.app_label
      Severity: Minor
      Found in cms/admin/pageadmin.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 edit_title_fields has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def edit_title_fields(self, request, page_id, language):
              page, translation = self.get_object_with_translation(
                  request=request,
                  object_id=page_id,
                  language=language,
      Severity: Minor
      Found in cms/admin/pageadmin.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 preview_page has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def preview_page(self, request, object_id, language):
              """
              Redirecting preview function based on draft_id
              """
              page = self.get_object(request, object_id=object_id)
      Severity: Minor
      Found in cms/admin/pageadmin.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 render_change_form has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def render_change_form(self, request, context, add=False, change=False, form_url='', obj=None):
      Severity: Minor
      Found in cms/admin/pageadmin.py - About 45 mins to fix

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

            def get_tree_rows(self, request, pages, language, depth=1,
        Severity: Minor
        Found in cms/admin/pageadmin.py - About 35 mins to fix

          Function copy_page has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def copy_page(self, request, page_id):
                  """
                  Copy the page and all its plugins and descendants to the requested
                  target, at the given position
                  """
          Severity: Minor
          Found in cms/admin/pageadmin.py - About 35 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 set_home has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def set_home(self, request, object_id):
                  page = self.get_object(request, object_id=object_id)
          
                  if not self.has_change_permission(request, page):
                      raise PermissionDenied("You do not have permission to set 'home'.")
          Severity: Minor
          Found in cms/admin/pageadmin.py - About 35 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_form_class has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_form_class(self, request, obj=None, **kwargs):
                  if 'advanced' in request.path_info:
                      return self.advanced_form
                  elif 'permission' in request.path_info:
                      return PagePermissionForm
          Severity: Minor
          Found in cms/admin/pageadmin.py - About 35 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_permissions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_permissions(self, request, page_id):
                  rows = []
                  user = request.user
                  page = self.get_object(request, object_id=page_id)
          
          
          Severity: Minor
          Found in cms/admin/pageadmin.py - About 35 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 copy_language has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def copy_language(self, request, page_id):
                  page = self.get_object(request, object_id=page_id)
                  source_language = request.POST.get('source_language')
                  target_language = request.POST.get('target_language')
          
          
          Severity: Minor
          Found in cms/admin/pageadmin.py - About 35 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 change_view has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def change_view(self, request, object_id, form_url='', extra_context=None):
                  """
                  The 'change' admin view for the Page model.
                  """
                  if extra_context is None:
          Severity: Minor
          Found in cms/admin/pageadmin.py - About 35 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 unpublish has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def unpublish(self, request, page_id, language):
                  """
                  Publish or unpublish a language of a page
                  """
                  page = self.get_object(request, object_id=page_id)
          Severity: Minor
          Found in cms/admin/pageadmin.py - About 35 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

          Avoid too many return statements within this function.
          Open

                  return HttpResponse(json.dumps({"id": new_page.pk}), content_type='application/json')
          Severity: Major
          Found in cms/admin/pageadmin.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return self.add_form
            Severity: Major
            Found in cms/admin/pageadmin.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return self.duplicate_form
              Severity: Major
              Found in cms/admin/pageadmin.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return render(request, self.delete_confirmation_template or [
                Severity: Major
                Found in cms/admin/pageadmin.py - About 30 mins to fix

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

                      def _has_add_permission_from_request(self, request):
                          site = self.get_site(request)
                          parent_node_id = request.GET.get('parent_node', None)
                  
                          if parent_node_id:
                  Severity: Minor
                  Found in cms/admin/pageadmin.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

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

                          if not cancel_clicked and request.method == 'POST':
                              form = PageTitleForm(instance=translation, data=request.POST)
                              if form.is_valid():
                                  form.save()
                                  saved_successfully = True
                  Severity: Major
                  Found in cms/admin/pageadmin.py and 1 other location - About 3 hrs to fix
                  cms/admin/placeholderadmin.py on lines 119..125

                  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 69.

                  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 3 locations. Consider refactoring.
                  Open

                      def has_change_advanced_settings_permission(self, request, obj=None):
                          if not obj:
                              return False
                          site = self.get_site(request)
                          return page_permissions.user_can_change_page_advanced_settings(request.user, page=obj, site=site)
                  Severity: Major
                  Found in cms/admin/pageadmin.py and 2 other locations - About 2 hrs to fix
                  cms/admin/pageadmin.py on lines 687..691
                  cms/admin/pageadmin.py on lines 721..725

                  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 50.

                  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 3 locations. Consider refactoring.
                  Open

                      def has_publish_permission(self, request, obj=None):
                          if not obj:
                              return False
                          site = self.get_site(request)
                          return page_permissions.user_can_publish_page(request.user, page=obj, site=site)
                  Severity: Major
                  Found in cms/admin/pageadmin.py and 2 other locations - About 2 hrs to fix
                  cms/admin/pageadmin.py on lines 681..685
                  cms/admin/pageadmin.py on lines 687..691

                  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 50.

                  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 3 locations. Consider refactoring.
                  Open

                      def has_change_permissions_permission(self, request, obj=None):
                          if not obj:
                              return False
                          site = self.get_site(request)
                          return page_permissions.user_can_change_page_permissions(request.user, page=obj, site=site)
                  Severity: Major
                  Found in cms/admin/pageadmin.py and 2 other locations - About 2 hrs to fix
                  cms/admin/pageadmin.py on lines 681..685
                  cms/admin/pageadmin.py on lines 721..725

                  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 50.

                  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

                                  if page.get_publisher_state(language) == PUBLISHER_STATE_PENDING:
                                      messages.warning(request, _("Page not published! A parent page is not published yet."))
                                  else:
                                      messages.info(request, _('The content was successfully published.'))
                  Severity: Major
                  Found in cms/admin/pageadmin.py and 1 other location - About 1 hr to fix
                  cms/admin/pageadmin.py on lines 1163..1182

                  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 45.

                  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

                              if all_published:
                                  if reload_urls:
                                      set_restart_trigger()
                  
                                  if page.get_publisher_state(language) == PUBLISHER_STATE_PENDING:
                  Severity: Major
                  Found in cms/admin/pageadmin.py and 1 other location - About 1 hr to fix
                  cms/admin/pageadmin.py on lines 1167..1170

                  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 45.

                  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

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

                          if request.GET.get('redirect_language'):
                              path = "%s?language=%s&page_id=%s" % (path, request.GET.get('redirect_language'), request.GET.get('redirect_page_id'))
                  Severity: Major
                  Found in cms/admin/pageadmin.py and 1 other location - About 1 hr to fix
                  cms/admin/pageadmin.py on lines 1194..1195

                  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 43.

                  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

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

                          if request.GET.get('redirect_language'):
                              path = "%s?language=%s&page_id=%s" % (path, request.GET.get('redirect_language'), request.GET.get('redirect_page_id'))
                  Severity: Major
                  Found in cms/admin/pageadmin.py and 1 other location - About 1 hr to fix
                  cms/admin/pageadmin.py on lines 1255..1256

                  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 43.

                  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

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

                          pat = lambda regex, fn: url(regex, self.admin_site.admin_view(fn), name='%s_%s' % (info, fn.__name__))
                  Severity: Major
                  Found in cms/admin/pageadmin.py and 3 other locations - About 1 hr to fix
                  cms/admin/pageadmin.py on lines 178..178
                  cms/admin/placeholderadmin.py on lines 82..82
                  cms/admin/placeholderadmin.py on lines 228..228

                  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 40.

                  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

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

                          pat = lambda regex, fn: url(regex, self.admin_site.admin_view(fn), name='%s_%s' % (info, fn.__name__))
                  Severity: Major
                  Found in cms/admin/pageadmin.py and 3 other locations - About 1 hr to fix
                  cms/admin/pageadmin.py on lines 1696..1696
                  cms/admin/placeholderadmin.py on lines 82..82
                  cms/admin/placeholderadmin.py on lines 228..228

                  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 40.

                  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

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

                              pages = pages.prefetch_related(
                                  Prefetch(
                                      'title_set',
                                      to_attr='filtered_translations',
                                      queryset=Title.objects.filter(language__in=get_language_list(site.pk))
                  Severity: Major
                  Found in cms/admin/pageadmin.py and 1 other location - About 1 hr to fix
                  cms/admin/pageadmin.py on lines 1452..1456

                  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 38.

                  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 3 locations. Consider refactoring.
                  Open

                          if perms_needed or protected:
                              title = _("Cannot delete %(name)s") % {"name": object_name}
                          else:
                              title = _("Are you sure?")
                  Severity: Major
                  Found in cms/admin/pageadmin.py and 2 other locations - About 1 hr to fix
                  cms/admin/placeholderadmin.py on lines 1093..1096
                  cms/admin/placeholderadmin.py on lines 1175..1178

                  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 38.

                  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

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

                          pages = pages.prefetch_related(
                              Prefetch(
                                  'title_set',
                                  to_attr='filtered_translations',
                                  queryset=Title.objects.filter(language__in=get_language_list(site.pk))
                  Severity: Major
                  Found in cms/admin/pageadmin.py and 1 other location - About 1 hr to fix
                  cms/admin/pageadmin.py on lines 799..803

                  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 38.

                  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

                          if DJANGO_2_0:
                              kwargs.update({'using': using, 'opts': pluginopts, 'user': request.user})
                          else:
                              kwargs.update({'request': request})
                  Severity: Minor
                  Found in cms/admin/pageadmin.py and 1 other location - About 55 mins to fix
                  cms/admin/pageadmin.py on lines 1291..1294

                  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 37.

                  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

                          if DJANGO_2_0:
                              kwargs.update({'using': using, 'opts': titleopts, 'user': request.user})
                          else:
                              kwargs.update({'request': request})
                  Severity: Minor
                  Found in cms/admin/pageadmin.py and 1 other location - About 55 mins to fix
                  cms/admin/pageadmin.py on lines 1300..1303

                  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 37.

                  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_queryset(self, request):
                          queryset  = super(PageAdmin, self).get_queryset(request)
                          return queryset.exclude(is_page_type=True)
                  Severity: Minor
                  Found in cms/admin/pageadmin.py and 1 other location - About 40 mins to fix
                  cms/admin/pageadmin.py on lines 1775..1777

                  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 34.

                  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_queryset(self, request):
                          queryset  = super(PageTypeAdmin, self).get_queryset(request)
                          return queryset.exclude(is_page_type=False)
                  Severity: Minor
                  Found in cms/admin/pageadmin.py and 1 other location - About 40 mins to fix
                  cms/admin/pageadmin.py on lines 1688..1690

                  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 34.

                  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

                              pages = page.get_descendant_pages().filter(Q(node__in=open_nodes)|Q(node__parent__in=open_nodes))
                  Severity: Minor
                  Found in cms/admin/pageadmin.py and 1 other location - About 35 mins to fix
                  cms/utils/page.py on lines 177..182

                  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 33.

                  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

                          if not self.has_publish_permission(request, obj=page):
                              return HttpResponseForbidden(force_text(_("You do not have permission to unpublish this page")))
                  Severity: Minor
                  Found in cms/admin/pageadmin.py and 1 other location - About 35 mins to fix
                  cms/admin/pageadmin.py on lines 1604..1605

                  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 33.

                  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

                          if not self.has_change_permission(request, obj=page):
                              return HttpResponseForbidden(force_text(_("You do not have permission to edit this page")))
                  Severity: Minor
                  Found in cms/admin/pageadmin.py and 1 other location - About 35 mins to fix
                  cms/admin/pageadmin.py on lines 1219..1220

                  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 33.

                  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

                  There are no issues that match your filters.

                  Category
                  Status