snake-soft/django-oscar-pg-search

View on GitHub
src/oscar_pg_search/postgres_search_handler.py

Summary

Maintainability
B
4 hrs
Test Coverage
F
26%

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

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

There are no issues that match your filters.

Category
Status