aldryn/aldryn-faq

View on GitHub

Showing 14 of 39 total issues

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_category has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    def get_category(self, queryset=None):
        """
        Fetch the object using a translated slug. This is largely stolen from
        Parler, but modified to remove any assumptions that this is being used
        on a DetailView.
Severity: Minor
Found in aldryn_faq/views.py - About 3 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_nodes has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def get_nodes(self, request):
        nodes = []
        language = get_language_from_request(request, check_path=True)
        # don't bother with categories that don't have appconfig.
        categories = Category.objects.active_translations(
Severity: Minor
Found in aldryn_faq/cms_menus.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

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

# -*- coding: utf-8 -*-

from __future__ import unicode_literals
from functools import partial

Severity: Minor
Found in aldryn_faq/models.py - About 2 hrs to fix

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

        def get_absolute_url(self, language=None, slug=None):
            language = language or get_current_language()
    
            if not slug:
                slug = self.known_translation_getter(
    Severity: Minor
    Found in aldryn_faq/models.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_absolute_url has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_absolute_url(self, language=None):
            """
            Returns the absolute_url of this question object, respecting the
            configured fallback languages.
            """
    Severity: Minor
    Found in aldryn_faq/models.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_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

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

          def save(self, commit=True):
              question = super(CreateFaqQuestionForm, self).save(commit=False)
      
              # If 'content' field has value, create a TextPlugin with same and add
              # it to the PlaceholderField
      Severity: Minor
      Found in aldryn_faq/cms_wizards.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 rename_tables has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def rename_tables(db, table_mapping=None, reverse=False):
          """
          renames tables from source to destination name, if the source exists
          and the destination does not exist yet.
      
      
      Severity: Minor
      Found in aldryn_faq/utils.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 create_placeholders has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def create_placeholders(app_config, save=True):
          """
          Creates placeholder instances for each Placeholder field on provided
          app_config.
          """
      Severity: Minor
      Found in aldryn_faq/migrations/0011_create_default_faq_config.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

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

          def get_categories(self):
              """
              By default, if no categories were chosen return all categories.
              Otherwise, return the chosen categories.
              """
      Severity: Minor
      Found in aldryn_faq/models.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

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

          def get(self, request, *args, **kwargs):
              """
              On GET, if the URL used is not the correct one, handle according to
              preferences by either:
                  Allowing (200),
      Severity: Minor
      Found in aldryn_faq/views.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

      Severity
      Category
      Status
      Source
      Language