From f3feabb6e08a91ecd526f2d4e9c9ac873ee467b0 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Mon, 19 Nov 2018 23:46:14 -0700 Subject: [PATCH] Reduce nesting of conditionals --- src/spectator/example_group.cr | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/spectator/example_group.cr b/src/spectator/example_group.cr index d404510..1091ffa 100644 --- a/src/spectator/example_group.cr +++ b/src/spectator/example_group.cr @@ -127,10 +127,9 @@ module Spectator # The hooks will be run only once. # Subsequent calls to this method will do nothing. def run_before_all_hooks : Nil - unless @before_all_hooks_run - @hooks.run_before_all - @before_all_hooks_run = true - end + return if @before_all_hooks_run + @hooks.run_before_all + @before_all_hooks_run = true end # Runs all of the `before_each` hooks. @@ -145,12 +144,10 @@ module Spectator # and only after all examples in the group have finished. # Subsequent calls after the hooks have been run will do nothing. def run_after_all_hooks : Nil - unless @after_all_hooks_run - if finished? - @hooks.run_after_all - @after_all_hooks_run = true - end - end + return if @after_all_hooks_run + return unless finished? + @hooks.run_after_all + @after_all_hooks_run = true end # Runs all of the `after_each` hooks.