aldryn/aldryn-faq

View on GitHub
aldryn_faq/cms_toolbars.py

Summary

Maintainability
D
2 days
Test Coverage

Function populate has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

    def populate(self):
        self.config = self.__get_faq_config()
        user = getattr(self.request, 'user', None)
        try:
            view_name = self.request.resolver_match.view_name
Severity: Minor
Found in aldryn_faq/cms_toolbars.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 get_on_delete_redirect_url has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def get_on_delete_redirect_url(self, obj, lang=None):
        if not self.config:
            self.config = self.__get_faq_config()

        if isinstance(obj, Category):
Severity: Minor
Found in aldryn_faq/cms_toolbars.py - About 45 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

def get_obj_from_request(model, request,
Severity: Minor
Found in aldryn_faq/cms_toolbars.py - About 35 mins to fix

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

    def get_obj_from_request(model, request,
                             pk_url_kwarg='pk',
                             slug_url_kwarg='slug',
                             slug_field='slug'):
        """
    Severity: Minor
    Found in aldryn_faq/cms_toolbars.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

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

                if change_question_perm and question:
                    url_args = {}
                    if language:
                        url_args = {'language': language, }
                    url = get_admin_url('aldryn_faq_question_change',
    Severity: Major
    Found in aldryn_faq/cms_toolbars.py and 1 other location - About 3 hrs to fix
    aldryn_faq/cms_toolbars.py on lines 181..187

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

    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 change_category_perm and category:
                    url_args = {}
                    if language:
                        url_args = {'language': language, }
                    url = get_admin_url('aldryn_faq_category_change',
    Severity: Major
    Found in aldryn_faq/cms_toolbars.py and 1 other location - About 3 hrs to fix
    aldryn_faq/cms_toolbars.py on lines 212..218

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

    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 delete_category_perm and category:
                    redirect_url = self.get_on_delete_redirect_url(
                        category, language)
                    url = get_admin_url('aldryn_faq_category_delete',
                                        [category.pk, ])
    Severity: Major
    Found in aldryn_faq/cms_toolbars.py and 1 other location - About 2 hrs to fix
    aldryn_faq/cms_toolbars.py on lines 221..226

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

    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 delete_question_perm and question:
                    redirect_url = self.get_on_delete_redirect_url(
                        question, language)
                    url = get_admin_url('aldryn_faq_question_delete',
                                        [question.pk, ])
    Severity: Major
    Found in aldryn_faq/cms_toolbars.py and 1 other location - About 2 hrs to fix
    aldryn_faq/cms_toolbars.py on lines 190..195

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

    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