Function remove_bucketlist_item
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
def remove_bucketlist_item(bucketlist_name, item_name):
''' Remove item_name from bucketlist_name '''
if get_session_user is not None:
session_user = get_session_user()
for bucketlist in session_user.available_bucketlists:
Function update_bucketlist_item
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
def update_bucketlist_item(bucketlist_name, item_name):
''' Update item_name in bucketlist_name with item_details '''
name = request.form.get('item_name')
description = request.form.get('item_desc')
category = str(request.form.get('item_category'))
Similar blocks of code found in 2 locations. Consider refactoring.
for bucketlist_item in target_bucketlist.items:
if str(bucketlist_item) == item_name:
delete_item = target_bucketlist.remove_item(bucketlist_item)
flash(delete_item)
return redirect("/dashboard/")
Similar blocks of code found in 2 locations. Consider refactoring.
for bucketlist in session_user.available_bucketlists:
if str(bucketlist) == bucketlist_name:
delete_bucketlist = session_user.delete_bucketlist(bucketlist)
flash(delete_bucketlist)
return redirect("/dashboard/")
Function display_bucketlist_items
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
def display_bucketlist_items(bucketlist_name):
''' Read bucketlist items and display them '''
if session['logged_in']:
if get_session_user() is not None:
session_user = get_session_user()
Similar blocks of code found in 2 locations. Consider refactoring.
for bucketlist in session_user.available_bucketlists:
if str(bucketlist) == bucketlist_name:
update_bucketlist = session_user.change_bucketlist_details(bucketlist, bucketlist_details)
flash(update_bucketlist)
return redirect("dashboard/")
Similar blocks of code found in 2 locations. Consider refactoring.
if str(bucketlist_item) == item_name:
update_item = target_bucketlist.update_item(bucketlist_item, new_details)
flash(update_item)
return redirect("/dashboard/")
Avoid deeply nested control flow statements.
if str(bucketlist_item) == item_name:
update_item = target_bucketlist.update_item(bucketlist_item, new_details)
flash(update_item)
return redirect("/dashboard/")
flash("The bucketlist item you are trying to delete is not available")
Avoid deeply nested control flow statements.
if str(bucketlist_item) == item_name:
delete_item = target_bucketlist.remove_item(bucketlist_item)
flash(delete_item)
return redirect("/dashboard/")
flash("The bucketlist item you are trying to delete is not available")
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring.
def __init__(self, name, category, description=None, status=None, bucketlist=None):
Function login
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def login():
''' Validate user details from existing non-persistent data '''
email = request.form.get('email')
password = request.form.get('password')
for user in registered_users:
Function delete_bucketlist
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def delete_bucketlist(bucketlist_name):
''' Deletes the bucketlist with the name name '''
if get_session_user is not None:
session_user = get_session_user()
for bucketlist in session_user.available_bucketlists:
Function update_bucketlist_details
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def update_bucketlist_details(bucketlist_name):
''' Updates the bucketlist details from a form '''
name = request.form.get('bucketlist_name')
description = request.form.get('bucketlist_desc')
bucketlist_details = (name, description)
Function add_bucketlist_item
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def add_bucketlist_item(bucketlist_name):
''' Add item details to bucketlist_name from a form '''
name = request.form.get('item_name')
description = request.form.get('item_desc')
category = str(request.form.get('item_category'))