Created
February 19, 2016 14:01
-
-
Save filipechagas/38a1d50039ac8ba03c57 to your computer and use it in GitHub Desktop.
Cyclomatic Complexity - Guard clause overused
This file contains hidden or 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
| def compute_thing(thing) | |
| if thing[:foo] | |
| update_with_bar(thing) | |
| if thing[:foo][:bar] | |
| partial_compute(thing) | |
| else | |
| re_compute(thing) | |
| end | |
| end | |
| end |
This file contains hidden or 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
| def compute_thing(thing) | |
| return unless thing[:foo] | |
| update_with_bar(thing[:foo]) | |
| if thing[:foo][:bar] | |
| partial_compute(thing) | |
| else | |
| re_compute(thing) unless thing[:foo][:bar] | |
| end | |
| end |
This file contains hidden or 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
| def compute_thing(thing) | |
| return unless thing[:foo] | |
| update_with_bar(thing[:foo]) | |
| return re_compute(thing) unless thing[:foo][:bar] | |
| partial_compute(thing) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment