Skip to content

Commit 8633092

Browse files
committed
combine early return condition into should return helper
1 parent c315710 commit 8633092

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/slack/web/faraday/response/raise_error.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,17 @@ def response_content_type_is_a_string?(env)
2020

2121
def should_return?(env)
2222
body = env.body
23-
(env.success? && body.is_a?(String) && response_content_type_is_a_string?(env)) || !body || body['ok']
23+
return true unless env.success?
24+
return true if env.success? && body.is_a?(String) && response_content_type_is_a_string?(env)
25+
return true if !body || body['ok']
26+
27+
false
2428
end
2529

2630
def on_complete(env)
2731
throw_if_too_many_requests(env)
2832
throw_if_response_is_invalid_json(env)
2933

30-
return unless env.success?
31-
3234
body = env.body
3335
return if should_return?(env)
3436

0 commit comments

Comments
 (0)