Skip to content

Commit 19d502d

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

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,16 @@ 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 if !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+
return false
2427
end
2528

2629
def on_complete(env)
2730
throw_if_too_many_requests(env)
2831
throw_if_response_is_invalid_json(env)
2932

30-
return unless env.success?
31-
3233
body = env.body
3334
return if should_return?(env)
3435

0 commit comments

Comments
 (0)