snake-soft/django-oscar-pg-search

View on GitHub

Showing 14 of 14 total issues

Function str_to_query has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def str_to_query(cls, search_str, search_fields):
        query = None # Query to search for every search term        
        terms = cls.normalize_query(search_str)
        for term in terms:
            or_query = None # Query to search for a given term in each field
Severity: Minor
Found in src/oscar_pg_search/postgres_search_handler.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 search_products has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def search_products(self, qs, query_string):
        if connection.vendor != 'postgresql':
            ''' fallback '''
            if settings.DEBUG:
                return qs
Severity: Minor
Found in src/oscar_pg_search/postgres_search_handler.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_queryset has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def get_queryset(self):
        if self.request and hasattr(self.request, 'products'):
            qs = self.request.products
        elif self.request and hasattr(Product, 'for_user'):
            qs = Product.for_user(self.request.user)
Severity: Minor
Found in src/oscar_pg_search/postgres_search_handler.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_choices has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def get_choices(self):
        """
        :returns: Choices drilled down by result query of all other fields.
        """
        result_for_other = self.manager.get_result(exclude=self)
Severity: Minor
Found in src/oscar_pg_search/filter_options/product_fields.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_attribute_fields has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def get_attribute_fields(self):
        """
        :returns: MultipleChoiceAttributeField for dynamic attribute values
        """
        fields = {}
Severity: Minor
Found in src/oscar_pg_search/filter_options/filter_forms.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 __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(self, request_data, code, name, sort_by=None, request=None):
Severity: Minor
Found in src/oscar_pg_search/order_by_options.py - About 35 mins to fix

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

        def __init__(self, request_data, form, *args, request=None, **kwargs):
    Severity: Minor
    Found in src/oscar_pg_search/filter_options/base_fields.py - About 35 mins to fix

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

          def __init__(self, request_data, form, *args, request=None, **kwargs):
      Severity: Minor
      Found in src/oscar_pg_search/filter_options/offer_fields.py - About 35 mins to fix

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

            def initialize(self):
                """
                Initializes all fields after the first result was calculated.
                It is executed by the FilterManager from outside
                """
        Severity: Minor
        Found in src/oscar_pg_search/filter_options/filter_forms.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_queries has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_queries(self, exclude=None):
                """
                :returns: List of all queries from the filters to be combined
                """
                queries = []
        Severity: Minor
        Found in src/oscar_pg_search/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 search_categories has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def search_categories(self, query_string):
                """ Return categories that contain query_string """
                qs = Category.objects.browsable()
                if connection.vendor != 'postgresql':
                    ''' fallback '''
        Severity: Minor
        Found in src/oscar_pg_search/postgres_search_handler.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_static has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def get_static(file_type):
            static_names = []
            for filelist in STATICFILES.values():
                for filename in filelist:
                    if filename.endswith(file_type):
        Severity: Minor
        Found in src/oscar_pg_search/templatetags/oscar_pg_search.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_sort_by has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_sort_by(self):
                if self.is_valid():
                    sort_by = self.cleaned_data.get('sort_by')
                    for choice in self.choice_objects + self.choice_objects_with_price:
                        if choice.code == sort_by:
        Severity: Minor
        Found in src/oscar_pg_search/forms.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 union has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def union(self, *args):
                query_string = self.query_string
                qs_arr = []
                for qs in args:
                    if self.order_by_option:
        Severity: Minor
        Found in src/oscar_pg_search/postgres_search_handler.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