diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-08-31 16:48:29 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-08-31 16:48:29 +0800 |
commit | d2cfcb3ec1327cd9dd901dcbe8c927e3c43cfb38 (patch) | |
tree | aaab3b7b0d7727292147755c881b4e815b5f9564 /lib | |
parent | 1e49a8bc6cd593910577a0f09ea13f0c933de1e9 (diff) | |
download | gitlab-ce-d2cfcb3ec1327cd9dd901dcbe8c927e3c43cfb38.tar.gz |
Use guard clause, feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6084#note_14754681
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/ci/pipeline_duration.rb | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/lib/gitlab/ci/pipeline_duration.rb b/lib/gitlab/ci/pipeline_duration.rb index f97727e8548..e37ba19bca9 100644 --- a/lib/gitlab/ci/pipeline_duration.rb +++ b/lib/gitlab/ci/pipeline_duration.rb @@ -132,18 +132,16 @@ module Gitlab end def process_periods(periods) - if periods.empty? - periods - else - periods.drop(1).inject([periods.first]) do |result, current| - merged = try_merge_period(result.last, current) + return periods if periods.empty? - if merged - result[-1] = merged - result - else - result << current - end + periods.drop(1).inject([periods.first]) do |result, current| + merged = try_merge_period(result.last, current) + + if merged + result[-1] = merged + result + else + result << current end end end |