summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-02-21 19:02:23 -0600
committerDouwe Maan <douwe@selenight.nl>2017-02-23 09:31:57 -0600
commit8a4d68c53e9c58ad7f8dce1494f7976292b2f929 (patch)
tree773814f7079c626cafabc229f929cafbe4d4b2e7 /lib
parent7ea641b6d0882fc782a7eb493daf8b66d076924b (diff)
downloadgitlab-ce-8a4d68c53e9c58ad7f8dce1494f7976292b2f929.tar.gz
Enable Style/ConditionalAssignment
Diffstat (limited to 'lib')
-rw-r--r--lib/banzai/filter/abstract_reference_filter.rb6
-rw-r--r--lib/banzai/filter/gollum_tags_filter.rb6
-rw-r--r--lib/banzai/filter/issue_reference_filter.rb6
-rw-r--r--lib/gitlab/award_emoji.rb6
-rw-r--r--lib/gitlab/conflict/file.rb6
-rw-r--r--lib/gitlab/diff/position.rb6
-rw-r--r--lib/gitlab/email/reply_parser.rb6
-rw-r--r--lib/gitlab/metrics/instrumentation.rb6
-rw-r--r--lib/gitlab/saml/user.rb6
-rw-r--r--lib/gitlab/search_results.rb12
-rw-r--r--lib/gitlab/sherlock/query.rb6
11 files changed, 36 insertions, 36 deletions
diff --git a/lib/banzai/filter/abstract_reference_filter.rb b/lib/banzai/filter/abstract_reference_filter.rb
index 3b15ff6566f..1c42ae3363d 100644
--- a/lib/banzai/filter/abstract_reference_filter.rb
+++ b/lib/banzai/filter/abstract_reference_filter.rb
@@ -160,10 +160,10 @@ module Banzai
data = data_attributes_for(link_content || match, project, object, link: !!link_content)
- if matches.names.include?("url") && matches[:url]
- url = matches[:url]
+ url = if matches.names.include?("url") && matches[:url]
+ matches[:url]
else
- url = url_for_object_cached(object, project)
+ url_for_object_cached(object, project)
end
content = link_content || object_link_text(object, matches)
diff --git a/lib/banzai/filter/gollum_tags_filter.rb b/lib/banzai/filter/gollum_tags_filter.rb
index d08267a9d6c..35d21733967 100644
--- a/lib/banzai/filter/gollum_tags_filter.rb
+++ b/lib/banzai/filter/gollum_tags_filter.rb
@@ -149,10 +149,10 @@ module Banzai
name, reference = *parts.compact.map(&:strip)
end
- if url?(reference)
- href = reference
+ href = if url?(reference)
+ reference
else
- href = ::File.join(project_wiki_base_path, reference)
+ ::File.join(project_wiki_base_path, reference)
end
content_tag(:a, name || reference, href: href, class: 'gfm')
diff --git a/lib/banzai/filter/issue_reference_filter.rb b/lib/banzai/filter/issue_reference_filter.rb
index fd6b9704132..e5082895e82 100644
--- a/lib/banzai/filter/issue_reference_filter.rb
+++ b/lib/banzai/filter/issue_reference_filter.rb
@@ -39,10 +39,10 @@ module Banzai
projects_per_reference.each do |path, project|
issue_ids = references_per_project[path]
- if project.default_issues_tracker?
- issues = project.issues.where(iid: issue_ids.to_a)
+ issues = if project.default_issues_tracker?
+ project.issues.where(iid: issue_ids.to_a)
else
- issues = issue_ids.map { |id| ExternalIssue.new(id, project) }
+ issue_ids.map { |id| ExternalIssue.new(id, project) }
end
issues.each do |issue|
diff --git a/lib/gitlab/award_emoji.rb b/lib/gitlab/award_emoji.rb
index 39b43ab5489..fcb3542d181 100644
--- a/lib/gitlab/award_emoji.rb
+++ b/lib/gitlab/award_emoji.rb
@@ -69,10 +69,10 @@ module Gitlab
end
JSON.parse(File.read(path)).map do |hash|
- if digest
- fname = "#{hash['unicode']}-#{hash['digest']}"
+ fname = if digest
+ "#{hash['unicode']}-#{hash['digest']}"
else
- fname = hash['unicode']
+ hash['unicode']
end
{ name: hash['name'], path: File.join(base, prefix, "#{fname}.png") }
diff --git a/lib/gitlab/conflict/file.rb b/lib/gitlab/conflict/file.rb
index c843315782d..fd43a224b3d 100644
--- a/lib/gitlab/conflict/file.rb
+++ b/lib/gitlab/conflict/file.rb
@@ -91,10 +91,10 @@ module Gitlab
our_highlight = Gitlab::Highlight.highlight(our_path, our_file, repository: repository).lines
lines.each do |line|
- if line.type == 'old'
- line.rich_text = their_highlight[line.old_line - 1].try(:html_safe)
+ line.rich_text = if line.type == 'old'
+ their_highlight[line.old_line - 1].try(:html_safe)
else
- line.rich_text = our_highlight[line.new_line - 1].try(:html_safe)
+ our_highlight[line.new_line - 1].try(:html_safe)
end
end
end
diff --git a/lib/gitlab/diff/position.rb b/lib/gitlab/diff/position.rb
index ecf62dead35..81c93f1aab5 100644
--- a/lib/gitlab/diff/position.rb
+++ b/lib/gitlab/diff/position.rb
@@ -140,10 +140,10 @@ module Gitlab
def find_diff_file(repository)
# We're at the initial commit, so just get that as we can't compare to anything.
- if Gitlab::Git.blank_ref?(start_sha)
- compare = Gitlab::Git::Commit.find(repository.raw_repository, head_sha)
+ compare = if Gitlab::Git.blank_ref?(start_sha)
+ Gitlab::Git::Commit.find(repository.raw_repository, head_sha)
else
- compare = Gitlab::Git::Compare.new(
+ Gitlab::Git::Compare.new(
repository.raw_repository,
start_sha,
head_sha
diff --git a/lib/gitlab/email/reply_parser.rb b/lib/gitlab/email/reply_parser.rb
index 8c8dd1b9cef..4ddfd78130e 100644
--- a/lib/gitlab/email/reply_parser.rb
+++ b/lib/gitlab/email/reply_parser.rb
@@ -31,10 +31,10 @@ module Gitlab
private
def select_body(message)
- if message.multipart?
- part = message.text_part || message.html_part || message
+ part = if message.multipart?
+ message.text_part || message.html_part || message
else
- part = message
+ message
end
decoded = fix_charset(part)
diff --git a/lib/gitlab/metrics/instrumentation.rb b/lib/gitlab/metrics/instrumentation.rb
index 4b7a791e497..9a07abfed06 100644
--- a/lib/gitlab/metrics/instrumentation.rb
+++ b/lib/gitlab/metrics/instrumentation.rb
@@ -143,10 +143,10 @@ module Gitlab
# signature this would break things. As a result we'll make sure the
# generated method _only_ accepts regular arguments if the underlying
# method also accepts them.
- if method.arity == 0
- args_signature = ''
+ args_signature = if method.arity == 0
+ ''
else
- args_signature = '*args'
+ '*args'
end
proxy_module.class_eval <<-EOF, __FILE__, __LINE__ + 1
diff --git a/lib/gitlab/saml/user.rb b/lib/gitlab/saml/user.rb
index f253dc7477e..abde05d9b68 100644
--- a/lib/gitlab/saml/user.rb
+++ b/lib/gitlab/saml/user.rb
@@ -28,10 +28,10 @@ module Gitlab
if external_users_enabled? && @user
# Check if there is overlap between the user's groups and the external groups
# setting then set user as external or internal.
- if (auth_hash.groups & Gitlab::Saml::Config.external_groups).empty?
- @user.external = false
+ @user.external = if (auth_hash.groups & Gitlab::Saml::Config.external_groups).empty?
+ false
else
- @user.external = true
+ true
end
end
diff --git a/lib/gitlab/search_results.rb b/lib/gitlab/search_results.rb
index c9c65f76f4b..a1a6929103b 100644
--- a/lib/gitlab/search_results.rb
+++ b/lib/gitlab/search_results.rb
@@ -56,10 +56,10 @@ module Gitlab
def issues
issues = IssuesFinder.new(current_user).execute.where(project_id: project_ids_relation)
- if query =~ /#(\d+)\z/
- issues = issues.where(iid: $1)
+ issues = if query =~ /#(\d+)\z/
+ issues.where(iid: $1)
else
- issues = issues.full_search(query)
+ issues.full_search(query)
end
issues.order('updated_at DESC')
@@ -73,10 +73,10 @@ module Gitlab
def merge_requests
merge_requests = MergeRequestsFinder.new(current_user).execute.in_projects(project_ids_relation)
- if query =~ /[#!](\d+)\z/
- merge_requests = merge_requests.where(iid: $1)
+ merge_requests = if query =~ /[#!](\d+)\z/
+ merge_requests.where(iid: $1)
else
- merge_requests = merge_requests.full_search(query)
+ merge_requests.full_search(query)
end
merge_requests.order('updated_at DESC')
end
diff --git a/lib/gitlab/sherlock/query.rb b/lib/gitlab/sherlock/query.rb
index 4917c4ae2ac..086fcddf721 100644
--- a/lib/gitlab/sherlock/query.rb
+++ b/lib/gitlab/sherlock/query.rb
@@ -94,10 +94,10 @@ module Gitlab
private
def raw_explain(query)
- if Gitlab::Database.postgresql?
- explain = "EXPLAIN ANALYZE #{query};"
+ explain = if Gitlab::Database.postgresql?
+ "EXPLAIN ANALYZE #{query};"
else
- explain = "EXPLAIN #{query};"
+ "EXPLAIN #{query};"
end
ActiveRecord::Base.connection.execute(explain)