if
statement have similar implementation PTC-W0051340
341 @staticmethod
342 def charge_payment(order_identifier, token):
343 if get_settings()['app_environment'] == Environment.PRODUCTION:344 omise.api_secret = get_settings()['omise_test_secret']
345 omise.api_public = get_settings()['omise_test_public']
346 else:
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.
if b == 0:
do_something()
elif b == 1:
do_something()
else:
do_something()
b = 4 if a > 12 else 4
# 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