Complex boolean expressions in if statements hide intent.
# dirty — what does this check?
def solve(user):
if user['age'] >= 18 and user['is_active'] and not user['is_banned'] and user['email_verified']:
return 'eligible'
return 'not-eligible'Refactor by extracting the condition into a named predicate is_eligible(user).solve(user, 'is_eligible') → True/False · solve(user, 'get_status') → 'eligible'/'not-eligible'
Sample tests