All branches in the conditional structure have same implementation
525 func(notification_recipient, view)
526 db.session.commit()
527 except TransportError:
528 if notification_recipient.notification.ignore_transport_errors:529 pass
530 else:
531 # TODO: Implement transport error handling code here
Description
For the highlighted if
statements, all the elif
/ else
branches have the same body as if
.
It is recommended to refactor this snippet.
If the if-chain is performing the same action in every case, it shouldn't be used there at all.
Not preferred:
if b == 0:
do_something()
elif b == 1:
do_something()
else:
do_something()
b = 4 if a > 12 else 4
Preferred:
# If this is was a copy-paste error, review and update the snippet
if b == 0:
do_something()
elif b == 1:
do_something_else()
else:
do_other_thing()
b = -4 if a > 12 else 4
# OR
# Refactor the code to not use the if-chain at all.
do_something()
b = 4