Function edit_user
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
def edit_user(user_name):
"""Modify a particular users details"""
current_user = get_jwt_identity()
user_input = request.get_json(force=True)
usermail = user_input.get("user_email")
- 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 sign_up
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def sign_up():
"""Register a user"""
# db = DatabaseConnection()
user_input = request.get_json(force=True)
user_name = user_input.get("user_name")
- 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 usermail == a_user[2]:
return jsonify({'message':"Email belongs to another account"}), 400
db.edit_user(usermail, usermobile, defaultpickup, user_name)
Function switch_user_role
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def switch_user_role(user_id):
current_user = get_jwt_identity()
print(current_user)
if current_user.get('username') == 'admin':
user = db.get_user_by_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 login
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def login():
db = DatabaseConnection()
user_input = request.get_json(force=True)
username = user_input.get("user_name")
password = user_input.get("user_password")
- 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':'You do not have access to this'}), 401
Avoid too many return
statements within this function. Open
return jsonify({'message':"Something went wrong"}), 400
Avoid too many return
statements within this function. Open
return jsonify({'message': f"{user_name} does not exist"}), 404
Avoid too many return
statements within this function. Open
return jsonify({"message":"Your details have successfully been updated"}), 200
Avoid too many return
statements within this function. Open
return jsonify({'message':'Please enter a valid email'}), 400
Avoid too many return
statements within this function. Open
return jsonify({"message":f"User {user_name} successfully created"}), 201