divio/django-cms

View on GitHub
cms/utils/page_permissions.py

Summary

Maintainability
F
3 days
Test Coverage

File page_permissions.py has 395 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from functools import wraps

from cms.api import get_page_draft
from cms.cache.permissions import get_permission_cache, set_permission_cache
from cms.constants import GRANT_ALL_PERMISSIONS
Severity: Minor
Found in cms/utils/page_permissions.py - About 5 hrs to fix

    Function auth_permission_required has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def auth_permission_required(action):
        def decorator(func):
            @wraps(func, assigned=available_attrs(func))
            def wrapper(user, *args, **kwargs):
                if not user.is_authenticated:
    Severity: Minor
    Found in cms/utils/page_permissions.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 user_can_view_page has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def user_can_view_page(user, page, site=None):
        if site is None:
            site = get_current_site()
    
        if user.is_superuser:
    Severity: Minor
    Found in cms/utils/page_permissions.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 _get_page_ids_for_action has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def _get_page_ids_for_action(user, site, action, check_global=True, use_cache=True):
    Severity: Minor
    Found in cms/utils/page_permissions.py - About 35 mins to fix

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

      def has_generic_permission(page, user, action, site=None, check_global=True):
      Severity: Minor
      Found in cms/utils/page_permissions.py - About 35 mins to fix

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

        def _get_page_ids_for_action(user, site, action, check_global=True, use_cache=True):
            if user.is_superuser or not get_cms_setting('PERMISSION'):
                # got superuser, or permissions aren't enabled?
                # just return grant all mark
                return GRANT_ALL_PERMISSIONS
        Severity: Minor
        Found in cms/utils/page_permissions.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 has_perm
        Severity: Major
        Found in cms/utils/page_permissions.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              return has_global_permission(user, site, action='view_page')
          Severity: Major
          Found in cms/utils/page_permissions.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return True
            Severity: Major
            Found in cms/utils/page_permissions.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return False
              Severity: Major
              Found in cms/utils/page_permissions.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return True
                Severity: Major
                Found in cms/utils/page_permissions.py - About 30 mins to fix

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

                  def user_can_view_all_pages(user, site):
                      if user.is_superuser:
                          return True
                  
                      if not get_cms_setting('PERMISSION'):
                  Severity: Minor
                  Found in cms/utils/page_permissions.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 8 locations. Consider refactoring.
                  Open

                  def get_add_id_list(user, site, check_global=True, use_cache=True):
                      """
                      Give a list of page where the user has add page rights or the string
                      "All" if the user has all rights.
                      """
                  Severity: Major
                  Found in cms/utils/page_permissions.py and 7 other locations - About 1 hr to fix
                  cms/utils/page_permissions.py on lines 387..399
                  cms/utils/page_permissions.py on lines 402..414
                  cms/utils/page_permissions.py on lines 417..427
                  cms/utils/page_permissions.py on lines 430..442
                  cms/utils/page_permissions.py on lines 445..455
                  cms/utils/page_permissions.py on lines 458..470
                  cms/utils/page_permissions.py on lines 473..483

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

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

                  def get_move_page_id_list(user, site, check_global=True, use_cache=True):
                      """Give a list of pages which user can move.
                      """
                      page_ids = _get_page_ids_for_action(
                          user=user,
                  Severity: Major
                  Found in cms/utils/page_permissions.py and 7 other locations - About 1 hr to fix
                  cms/utils/page_permissions.py on lines 372..384
                  cms/utils/page_permissions.py on lines 387..399
                  cms/utils/page_permissions.py on lines 402..414
                  cms/utils/page_permissions.py on lines 417..427
                  cms/utils/page_permissions.py on lines 430..442
                  cms/utils/page_permissions.py on lines 458..470
                  cms/utils/page_permissions.py on lines 473..483

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

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

                  def get_delete_id_list(user, site, check_global=True, use_cache=True):
                      """
                      Give a list of page where the user has delete rights or the string "All" if
                      the user has all rights.
                      """
                  Severity: Major
                  Found in cms/utils/page_permissions.py and 7 other locations - About 1 hr to fix
                  cms/utils/page_permissions.py on lines 372..384
                  cms/utils/page_permissions.py on lines 387..399
                  cms/utils/page_permissions.py on lines 402..414
                  cms/utils/page_permissions.py on lines 417..427
                  cms/utils/page_permissions.py on lines 445..455
                  cms/utils/page_permissions.py on lines 458..470
                  cms/utils/page_permissions.py on lines 473..483

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

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

                  def get_publish_id_list(user, site, check_global=True, use_cache=True):
                      """
                      Give a list of page where the user has publish rights or the string "All" if
                      the user has all rights.
                      """
                  Severity: Major
                  Found in cms/utils/page_permissions.py and 7 other locations - About 1 hr to fix
                  cms/utils/page_permissions.py on lines 372..384
                  cms/utils/page_permissions.py on lines 387..399
                  cms/utils/page_permissions.py on lines 402..414
                  cms/utils/page_permissions.py on lines 417..427
                  cms/utils/page_permissions.py on lines 430..442
                  cms/utils/page_permissions.py on lines 445..455
                  cms/utils/page_permissions.py on lines 473..483

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

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

                  def get_change_id_list(user, site, check_global=True, use_cache=True):
                      """
                      Give a list of page where the user has edit rights or the string "All" if
                      the user has all rights.
                      """
                  Severity: Major
                  Found in cms/utils/page_permissions.py and 7 other locations - About 1 hr to fix
                  cms/utils/page_permissions.py on lines 372..384
                  cms/utils/page_permissions.py on lines 402..414
                  cms/utils/page_permissions.py on lines 417..427
                  cms/utils/page_permissions.py on lines 430..442
                  cms/utils/page_permissions.py on lines 445..455
                  cms/utils/page_permissions.py on lines 458..470
                  cms/utils/page_permissions.py on lines 473..483

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

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

                  def get_view_id_list(user, site, check_global=True, use_cache=True):
                      """Give a list of pages which user can view.
                      """
                      page_ids = _get_page_ids_for_action(
                          user=user,
                  Severity: Major
                  Found in cms/utils/page_permissions.py and 7 other locations - About 1 hr to fix
                  cms/utils/page_permissions.py on lines 372..384
                  cms/utils/page_permissions.py on lines 387..399
                  cms/utils/page_permissions.py on lines 402..414
                  cms/utils/page_permissions.py on lines 417..427
                  cms/utils/page_permissions.py on lines 430..442
                  cms/utils/page_permissions.py on lines 445..455
                  cms/utils/page_permissions.py on lines 458..470

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

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

                  def get_change_advanced_settings_id_list(user, site, check_global=True, use_cache=True):
                      """
                      Give a list of page where the user can change advanced settings or the
                      string "All" if the user has all rights.
                      """
                  Severity: Major
                  Found in cms/utils/page_permissions.py and 7 other locations - About 1 hr to fix
                  cms/utils/page_permissions.py on lines 372..384
                  cms/utils/page_permissions.py on lines 387..399
                  cms/utils/page_permissions.py on lines 417..427
                  cms/utils/page_permissions.py on lines 430..442
                  cms/utils/page_permissions.py on lines 445..455
                  cms/utils/page_permissions.py on lines 458..470
                  cms/utils/page_permissions.py on lines 473..483

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

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

                  def get_change_permissions_id_list(user, site, check_global=True, use_cache=True):
                      """Give a list of page where the user can change permissions.
                      """
                      page_ids = _get_page_ids_for_action(
                          user=user,
                  Severity: Major
                  Found in cms/utils/page_permissions.py and 7 other locations - About 1 hr to fix
                  cms/utils/page_permissions.py on lines 372..384
                  cms/utils/page_permissions.py on lines 387..399
                  cms/utils/page_permissions.py on lines 402..414
                  cms/utils/page_permissions.py on lines 430..442
                  cms/utils/page_permissions.py on lines 445..455
                  cms/utils/page_permissions.py on lines 458..470
                  cms/utils/page_permissions.py on lines 473..483

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

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

                  @cached_func
                  @auth_permission_required('move_page')
                  def user_can_move_page(user, page, site=None):
                      has_perm = has_generic_permission(
                          page=page,
                  Severity: Major
                  Found in cms/utils/page_permissions.py and 5 other locations - About 1 hr to fix
                  cms/utils/page_permissions.py on lines 143..152
                  cms/utils/page_permissions.py on lines 224..233
                  cms/utils/page_permissions.py on lines 236..245
                  cms/utils/page_permissions.py on lines 248..257
                  cms/utils/page_permissions.py on lines 318..327

                  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

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

                  @cached_func
                  @auth_permission_required('change_page')
                  def user_can_change_page(user, page, site=None):
                      can_change = has_generic_permission(
                          page=page,
                  Severity: Major
                  Found in cms/utils/page_permissions.py and 5 other locations - About 1 hr to fix
                  cms/utils/page_permissions.py on lines 224..233
                  cms/utils/page_permissions.py on lines 236..245
                  cms/utils/page_permissions.py on lines 248..257
                  cms/utils/page_permissions.py on lines 260..269
                  cms/utils/page_permissions.py on lines 318..327

                  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

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

                  @cached_func
                  @auth_permission_required('change_page_permissions')
                  def user_can_change_page_permissions(user, page, site=None):
                      has_perm = has_generic_permission(
                          page=page,
                  Severity: Major
                  Found in cms/utils/page_permissions.py and 5 other locations - About 1 hr to fix
                  cms/utils/page_permissions.py on lines 143..152
                  cms/utils/page_permissions.py on lines 224..233
                  cms/utils/page_permissions.py on lines 236..245
                  cms/utils/page_permissions.py on lines 260..269
                  cms/utils/page_permissions.py on lines 318..327

                  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

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

                  @cached_func
                  @auth_permission_required('change_page')
                  def user_can_view_page_draft(user, page, site=None):
                      has_perm = has_generic_permission(
                          page=page,
                  Severity: Major
                  Found in cms/utils/page_permissions.py and 5 other locations - About 1 hr to fix
                  cms/utils/page_permissions.py on lines 143..152
                  cms/utils/page_permissions.py on lines 224..233
                  cms/utils/page_permissions.py on lines 236..245
                  cms/utils/page_permissions.py on lines 248..257
                  cms/utils/page_permissions.py on lines 260..269

                  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

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

                  @cached_func
                  @auth_permission_required('publish_page')
                  def user_can_publish_page(user, page, site=None):
                      has_perm = has_generic_permission(
                          page=page,
                  Severity: Major
                  Found in cms/utils/page_permissions.py and 5 other locations - About 1 hr to fix
                  cms/utils/page_permissions.py on lines 143..152
                  cms/utils/page_permissions.py on lines 236..245
                  cms/utils/page_permissions.py on lines 248..257
                  cms/utils/page_permissions.py on lines 260..269
                  cms/utils/page_permissions.py on lines 318..327

                  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

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

                  @cached_func
                  @auth_permission_required('change_page_advanced_settings')
                  def user_can_change_page_advanced_settings(user, page, site=None):
                      has_perm = has_generic_permission(
                          page=page,
                  Severity: Major
                  Found in cms/utils/page_permissions.py and 5 other locations - About 1 hr to fix
                  cms/utils/page_permissions.py on lines 143..152
                  cms/utils/page_permissions.py on lines 224..233
                  cms/utils/page_permissions.py on lines 248..257
                  cms/utils/page_permissions.py on lines 260..269
                  cms/utils/page_permissions.py on lines 318..327

                  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

                  There are no issues that match your filters.

                  Category
                  Status