File models.py
has 454 lines of code (exceeds 250 allowed). Consider refactoring. Open
import bleach
import csv
from datetime import datetime
from decimal import Decimal
Function multi_phrase_search
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def multi_phrase_search(self, query, query_by=None, *args, **kwargs):
"""
Given a query as string, runs it through clean_search to get a list of search terms,
then returns a matching queryset of Contract objects for each of those terms.
- Read upRead up
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 update_price_fields
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def update_price_fields(self):
'''
Set current, next, and second year price fields based on this
contract's contract_year.
'''
- Read upRead up
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 order_by
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def order_by(self, *args, **kwargs):
edu_sort_sql = """
case
when education_level = 'HS' then 1
when education_level = 'AA' then 2
- Read upRead up
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 bulk_update_normalized_labor_categories
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def bulk_update_normalized_labor_categories(self):
'''
Iterate through all Contract models and update their
normalized labor categories if necessary.
- Read upRead up
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"