Also known as the "Arrow Anti-Pattern".
if logged_in?
tokens.each do |token|
if token != current_session.token
token.expire!
end
end
end
Code in loops and conditionals tends to conflate data
transformation with side effects. This is because there's no
way for a loop or an if
to affect the rest of the
system unless it has a side effect. As a result, it's hard
to see at a glance what the code is doing, and where it
might be unsafe to insert new code or reorder statements.
Use Replace Loop with Pipeline to separate data transformation from side effects. Additionally, Replace Inline Code with Function Call and Extract Method can help abstract away complex boolean logic in conditionals.