summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2016-07-20 16:26:04 +0000
committerRobert Speicher <robert@gitlab.com>2016-07-20 16:26:04 +0000
commit6f8156cea587f08e11ad578bec012af103cc82e4 (patch)
tree9676f19b4bd627ebf6e545d78deacbe972246dd3
parent639942ef01791ca37362bb2ba9716b6745f7025f (diff)
parent07be5943788fe0b672e8c6bea6859582cbdd3d11 (diff)
downloadgitlab-ce-6f8156cea587f08e11ad578bec012af103cc82e4.tar.gz
Merge branch 'rubocop/enable-multiline-ternary-operator-cop' into 'master'
Enable Style/MultilineTernaryOperator rubocop cop Avoid multi-line ?: (the ternary operator). Use if/unless instead. See #17478 See merge request !4356
-rw-r--r--.rubocop.yml4
-rw-r--r--.rubocop_todo.yml4
-rw-r--r--lib/banzai/filter/relative_link_filter.rb3
-rw-r--r--spec/support/api_helpers.rb14
4 files changed, 15 insertions, 10 deletions
diff --git a/.rubocop.yml b/.rubocop.yml
index db0bcfadcf4..6adbda53456 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -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
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 9310e711889..b622b9239d4 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -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:
diff --git a/lib/banzai/filter/relative_link_filter.rb b/lib/banzai/filter/relative_link_filter.rb
index c78da404607..21ed0410f7f 100644
--- a/lib/banzai/filter/relative_link_filter.rb
+++ b/lib/banzai/filter/relative_link_filter.rb
@@ -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
diff --git a/spec/support/api_helpers.rb b/spec/support/api_helpers.rb
index 1b3cafb497c..68b196d9033 100644
--- a/spec/support/api_helpers.rb
+++ b/spec/support/api_helpers.rb
@@ -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