Enable Style/MultilineTernaryOperator rubocop cop

Avoid multi-line ?: (the ternary operator). Use if/unless instead.

See #17478
This commit is contained in:
Grzegorz Bizon 2016-05-30 14:06:06 +02:00
parent 79b02e40e5
commit 07be594378
4 changed files with 15 additions and 10 deletions

View File

@ -291,6 +291,10 @@ Style/MultilineMethodDefinitionBraceLayout:
Style/MultilineOperationIndentation:
Enabled: false
# Avoid multi-line `? :` (the ternary operator), use if/unless instead.
Style/MultilineTernaryOperator:
Enabled: true
# Favor unless over if for negative conditions (or control flow or).
Style/NegatedIf:
Enabled: true

View File

@ -226,10 +226,6 @@ Style/LineEndConcatenation:
Style/MethodCallParentheses:
Enabled: false
# Offense count: 3
Style/MultilineTernaryOperator:
Enabled: false
# Offense count: 62
# Cop supports --auto-correct.
Style/MutableConstant:

View File

@ -112,8 +112,7 @@ module Banzai
end
def current_commit
@current_commit ||= context[:commit] ||
ref ? repository.commit(ref) : repository.head_commit
@current_commit ||= context[:commit] || ref ? repository.commit(ref) : repository.head_commit
end
def relative_url_root

View File

@ -24,8 +24,11 @@ module ApiHelpers
(path.index('?') ? '' : '?') +
# Append private_token if given a User object
(user.respond_to?(:private_token) ?
"&private_token=#{user.private_token}" : "")
if user.respond_to?(:private_token)
"&private_token=#{user.private_token}"
else
''
end
end
def ci_api(path, user = nil)
@ -35,8 +38,11 @@ module ApiHelpers
(path.index('?') ? '' : '?') +
# Append private_token if given a User object
(user.respond_to?(:private_token) ?
"&private_token=#{user.private_token}" : "")
if user.respond_to?(:private_token)
"&private_token=#{user.private_token}"
else
''
end
end
def json_response