Function check_user_can_set_status
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def check_user_can_set_status(request, application, data):
"""
Checks whether an user (internal/exporter) can set the requested status
Returns error response if user cannot set the status, None otherwise
"""
- 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 can_status_be_set_by_gov_user
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def can_status_be_set_by_gov_user(user: GovUser, original_status: str, new_status: str, is_mod: bool) -> bool:
"""
Check that a status can be set by a gov user. Gov users can not set a case's status to
`Applicant editing`. They also cannot set a case's status to `Finalised` or open a closed case
without additional permissions.
- 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 can_status_be_set_by_exporter_user
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def can_status_be_set_by_exporter_user(original_status: str, new_status: str) -> bool:
"""Check that a status can be set by an exporter user. Exporter users cannot withdraw an application
that is already in a terminal state and they cannot set an application to `Applicant editing` if the
application is read only.
"""
- 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 too many return
statements within this function. Open
return JsonResponse(
Avoid too many return
statements within this function. Open
return JsonResponse(data={"errors": ["Invalid user type"]}, status=status.HTTP_401_UNAUTHORIZED)
Avoid too many return
statements within this function. Open
return True
Avoid too many return
statements within this function. Open
return None