Function _validate_ultimate_end_users
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def _validate_ultimate_end_users(draft, errors, is_mandatory):
"""
Checks all ultimate end users have documents if is_mandatory is True.
Also checks that at least one ultimate_end_user is present if there is an incorporated good
"""
- 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 _validate_end_use_details
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def _validate_end_use_details(draft, errors, application_type):
if application_type in [CaseTypeSubTypeEnum.STANDARD, CaseTypeSubTypeEnum.OPEN]:
if (
draft.is_military_end_use_controls is None
or draft.is_informed_wmd is None
- 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 check_party_document
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def check_party_document(party, is_mandatory):
"""
Checks for existence of and status of document (if it is mandatory) and return any errors
"""
documents_qs = PartyDocument.objects.filter(party=party).values_list("safe", flat=True)
- 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
Avoid deeply nested control flow statements. Open
if "end_user" not in errors and str(ultimate_end_user) == str(draft.end_user.party.id):
errors["ultimate_end_users"] = [
"To submit the application, an ultimate end-user cannot be the same as the end user"
]
Avoid too many return
statements within this function. Open
return None
Avoid too many return
statements within this function. Open
return getattr(strings.Applications.Standard, f"{party.type.upper()}_DOCUMENT_INFECTED")
Function _validate_goods
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _validate_goods(draft, errors, is_mandatory):
"""Checks Goods"""
goods_on_application = GoodOnApplication.objects.filter(application=draft)
- 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"