Last active
October 26, 2018 23:56
-
-
Save beatmadsen/ae9e7b366fa4e9b4129f8d40990c8473 to your computer and use it in GitHub Desktop.
Bad reuse with boolean parameter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# calling code: | |
age = find_age(name: user.name, divert: !user.belongs_to_system_a?) | |
# methods | |
def find_age(name:, divert:) | |
payload = { name: name, size: 42 } | |
response = divert ? call_system_b(payload) : call_system_a(payload) | |
if response.use_dog_years? | |
response.age * 7 | |
else | |
response.age | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment