Function change_present_location
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def change_present_location(parcel_id):
"""Change the present location of a parcel delivery order"""
current_user = get_jwt_identity()
user_input = request.get_json(force=True)
parcel = db.get_a_parcel(parcel_id)
- 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 change_parcel_destination
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def change_parcel_destination(parcel_id):
"""Change the destination of a parcel delivery order"""
current_user = get_jwt_identity()
user_input = request.get_json(force=True)
parcel = db.get_a_parcel(parcel_id)
- 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 change_parcel_status
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def change_parcel_status(parcel_id):
"""Change the status of a parcel delivery order"""
current_user = get_jwt_identity()
parcel = db.get_a_parcel(parcel_id)
if parcel:
- 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 get_parcels_by_user
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_parcels_by_user(user_id):
"""Retrieve all parcels by a specific user"""
parcel_list = []
current_user = get_jwt_identity()
if current_user.get('id') == user_id or current_user.get('role') == 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 too many return
statements within this function. Open
return jsonify({'message':f"There is no parcel with ID {parcel_id}"}), 404
Avoid too many return
statements within this function. Open
return jsonify({'message':f"There is no parcel with ID {parcel_id}"}), 404
Function get_delivered_parcels_by_user
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_delivered_parcels_by_user(user_id):
"""Retrieve all parcels by a specific user"""
parcel_list = []
current_user = get_jwt_identity()
if current_user.get('id') == user_id:
- 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 get_parcels
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_parcels():
"""Retrieve all parcels"""
parcel_list = []
current_user = get_jwt_identity()
if current_user.get('role') == 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"