Commit 2d796f02 authored by Douwe Maan's avatar Douwe Maan
Browse files

Enable Style/ConditionalAssignment

parent f0585e739211
......@@ -965,5 +965,8 @@
Style/CommentAnnotation:
Enabled: false
Style/ConditionalAssignment:
Enabled: true
Style/DoubleNegation:
Enabled: false
......@@ -38,13 +38,6 @@
Exclude:
- 'spec/requests/api/internal_spec.rb'
# Offense count: 32
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, SingleLineConditionsOnly.
# SupportedStyles: assign_to_condition, assign_inside_condition
Style/ConditionalAssignment:
Enabled: false
# Offense count: 6
# Cop supports --auto-correct.
Style/EachWithObject:
......
......@@ -101,5 +101,5 @@
# TODO: We should really clean this up
def set_commit_variables
if can?(current_user, :push_code, @project)
@mr_source_project = if can?(current_user, :push_code, @project)
# Edit file in this project
......@@ -105,4 +105,4 @@
# Edit file in this project
@mr_source_project = @project
@project
else
# Merge request from fork to this project
......@@ -107,6 +107,6 @@
else
# Merge request from fork to this project
@mr_source_project = current_user.fork_of(@project)
current_user.fork_of(@project)
end
# Merge request to this project
......
......@@ -76,6 +76,6 @@
return @project if defined?(@project)
project_id, _ = project_id_with_suffix
if project_id.blank?
@project = nil
@project = if project_id.blank?
nil
else
......@@ -81,5 +81,5 @@
else
@project = Project.find_by_full_path("#{params[:namespace_id]}/#{project_id}")
Project.find_by_full_path("#{params[:namespace_id]}/#{project_id}")
end
end
......
......@@ -381,9 +381,9 @@
end
def merge_widget_refresh
if merge_request.merge_when_build_succeeds
@status = :merge_when_build_succeeds
@status = if merge_request.merge_when_build_succeeds
:merge_when_build_succeeds
else
# Only MRs that can be merged end in this action
# MR can be already picked up for merge / merged already or can be waiting for worker to be picked up
# in last case it does not have any special status. Possible error is handled inside widget js function
......@@ -386,8 +386,8 @@
else
# Only MRs that can be merged end in this action
# MR can be already picked up for merge / merged already or can be waiting for worker to be picked up
# in last case it does not have any special status. Possible error is handled inside widget js function
@status = :success
:success
end
render 'merge'
......
......@@ -15,6 +15,6 @@
def new
set_minimum_password_length
if Gitlab.config.ldap.enabled
@ldap_servers = Gitlab::LDAP::Config.servers
@ldap_servers = if Gitlab.config.ldap.enabled
Gitlab::LDAP::Config.servers
else
......@@ -20,5 +20,5 @@
else
@ldap_servers = []
[]
end
super
......
......@@ -28,6 +28,6 @@
private
def init_collection
if @params[:target_id]
@notes = on_target(@params[:target_type], @params[:target_id])
@notes = if @params[:target_id]
on_target(@params[:target_type], @params[:target_id])
else
......@@ -33,5 +33,5 @@
else
@notes = notes_of_any_type
notes_of_any_type
end
end
......
......@@ -69,6 +69,6 @@
end
def avatar_icon(user_or_email = nil, size = nil, scale = 2)
if user_or_email.is_a?(User)
user = user_or_email
user = if user_or_email.is_a?(User)
user_or_email
else
......@@ -74,5 +74,5 @@
else
user = User.find_by_any_email(user_or_email.try(:downcase))
User.find_by_any_email(user_or_email.try(:downcase))
end
if user
......
......@@ -153,7 +153,7 @@
# Because we are opionated we set the cache headers ourselves.
response.cache_control[:public] = @project.public?
if @ref && @commit && @ref == @commit.id
response.cache_control[:max_age] = if @ref && @commit && @ref == @commit.id
# This is a link to a commit by its commit SHA. That means that the blob
# is immutable. The only reason to invalidate the cache is if the commit
# was deleted or if the user lost access to the repository.
......@@ -157,7 +157,7 @@
# This is a link to a commit by its commit SHA. That means that the blob
# is immutable. The only reason to invalidate the cache is if the commit
# was deleted or if the user lost access to the repository.
response.cache_control[:max_age] = Blob::CACHE_TIME_IMMUTABLE
Blob::CACHE_TIME_IMMUTABLE
else
# A branch or tag points at this blob. That means that the expected blob
# value may change over time.
......@@ -161,7 +161,7 @@
else
# A branch or tag points at this blob. That means that the expected blob
# value may change over time.
response.cache_control[:max_age] = Blob::CACHE_TIME
Blob::CACHE_TIME
end
response.etag = @blob.id
......
class RepositoryCheckMailer < BaseMailer
def notify(failed_count)
if failed_count == 1
@message = "One project failed its last repository check"
@message = if failed_count == 1
"One project failed its last repository check"
else
......@@ -5,5 +5,5 @@
else
@message = "#{failed_count} projects failed their last repository check"
"#{failed_count} projects failed their last repository check"
end
mail(
......
......@@ -122,6 +122,6 @@
def full_title
return @full_title if @full_title
if safe_message.blank?
@full_title = no_commit_message
@full_title = if safe_message.blank?
no_commit_message
else
......@@ -127,5 +127,5 @@
else
@full_title = safe_message.split("\n", 2).first
safe_message.split("\n", 2).first
end
end
......
......@@ -13,6 +13,6 @@
params.each do |key, value|
column = ActiveRecord::Base.connection.quote_table_name(key)
if cast_lower
condition = "LOWER(#{column}) = LOWER(:value)"
condition = if cast_lower
"LOWER(#{column}) = LOWER(:value)"
else
......@@ -18,5 +18,5 @@
else
condition = "#{column} = :value"
"#{column} = :value"
end
criteria = criteria.where(condition, value: value)
......
......@@ -46,6 +46,6 @@
where("label_links.target_id = #{target_column}").
reorder(nil)
if target_type_column
query = query.where("label_links.target_type = #{target_type_column}")
query = if target_type_column
query.where("label_links.target_type = #{target_type_column}")
else
......@@ -51,5 +51,5 @@
else
query = query.where(label_links: { target_type: target_type })
query.where(label_links: { target_type: target_type })
end
query = query.where.not(title: excluded_labels) if excluded_labels.present?
......
......@@ -188,6 +188,6 @@
end
# and mark it as reserved
if parent_time.nil?
min_time = leaves.first.time
min_time = if parent_time.nil?
leaves.first.time
else
......@@ -193,5 +193,5 @@
else
min_time = parent_time + 1
parent_time + 1
end
max_time = leaves.last.time
......
......@@ -453,8 +453,8 @@
end
def add_import_job
if forked?
job_id = RepositoryForkWorker.perform_async(id, forked_from_project.repository_storage_path,
job_id = if forked?
RepositoryForkWorker.perform_async(id, forked_from_project.repository_storage_path,
forked_from_project.path_with_namespace,
self.namespace.full_path)
else
......@@ -458,7 +458,7 @@
forked_from_project.path_with_namespace,
self.namespace.full_path)
else
job_id = RepositoryImportWorker.perform_async(self.id)
RepositoryImportWorker.perform_async(self.id)
end
if job_id
......
......@@ -72,6 +72,6 @@
before = data[:before]
after = data[:after]
if Gitlab::Git.blank_ref?(before)
message = "#{data[:user_name]} pushed new branch \"#{ref}\"."
message = if Gitlab::Git.blank_ref?(before)
"#{data[:user_name]} pushed new branch \"#{ref}\"."
elsif Gitlab::Git.blank_ref?(after)
......@@ -77,3 +77,3 @@
elsif Gitlab::Git.blank_ref?(after)
message = "#{data[:user_name]} deleted branch \"#{ref}\"."
"#{data[:user_name]} deleted branch \"#{ref}\"."
else
......@@ -79,5 +79,5 @@
else
message = "#{data[:user_name]} push to branch \"#{ref}\"."
"#{data[:user_name]} push to branch \"#{ref}\"."
end
if data[:total_commits_count] > 0
......
......@@ -408,5 +408,5 @@
# Initial scope should be system notes of this noteable type
notes = Note.system.where(noteable_type: noteable.class)
if noteable.is_a?(Commit)
notes = if noteable.is_a?(Commit)
# Commits have non-integer IDs, so they're stored in `commit_id`
......@@ -412,3 +412,3 @@
# Commits have non-integer IDs, so they're stored in `commit_id`
notes = notes.where(commit_id: noteable.id)
notes.where(commit_id: noteable.id)
else
......@@ -414,5 +414,5 @@
else
notes = notes.where(noteable_id: noteable.id)
notes.where(noteable_id: noteable.id)
end
notes_for_mentioner(mentioner, noteable, notes).exists?
......
......@@ -14,6 +14,6 @@
end
def build_gitlab_ci_url
if on_standard_port?(gitlab)
custom_port = nil
custom_port = if on_standard_port?(gitlab)
nil
else
......@@ -19,5 +19,5 @@
else
custom_port = ":#{gitlab.port}"
":#{gitlab.port}"
end
[gitlab.protocol,
"://",
......@@ -160,6 +160,6 @@
github_settings["args"] ||= Settingslogic.new({})
if github_settings["url"].include?(github_default_url)
github_settings["args"]["client_options"] = OmniAuth::Strategies::GitHub.default_options[:client_options]
github_settings["args"]["client_options"] = if github_settings["url"].include?(github_default_url)
OmniAuth::Strategies::GitHub.default_options[:client_options]
else
......@@ -165,5 +165,5 @@
else
github_settings["args"]["client_options"] = {
{
"site" => File.join(github_settings["url"], "api/v3"),
"authorize_url" => File.join(github_settings["url"], "login/oauth/authorize"),
"token_url" => File.join(github_settings["url"], "login/oauth/access_token")
......
......@@ -160,6 +160,6 @@
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
......@@ -165,5 +165,5 @@
else
url = url_for_object_cached(object, project)
url_for_object_cached(object, project)
end
content = link_content || object_link_text(object, matches)
......
......@@ -149,6 +149,6 @@
name, reference = *parts.compact.map(&:strip)
end
if url?(reference)
href = reference
href = if url?(reference)
reference
else
......@@ -154,5 +154,5 @@
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')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment