Skip to content
Snippets Groups Projects
Commit e21257f7 authored by Rémy Coutable's avatar Rémy Coutable
Browse files

Merge branch 'zj-ruby-2-1-no-more' into 'master'

[EE] Update Rubocop to Ruby 2.3

See merge request !1195
parents 251d0116 6155d8e7
No related branches found
No related tags found
1 merge request!1195[EE] Update Rubocop to Ruby 2.3
Pipeline #
Showing
with 32 additions and 46 deletions
Loading
Loading
@@ -5,7 +5,7 @@ require:
inherit_from: .rubocop_todo.yml
 
AllCops:
TargetRubyVersion: 2.1
TargetRubyVersion: 2.3
# Cop names are not d§splayed in offense messages by default. Change behavior
# by overriding DisplayCopNames, or by giving the -D/--display-cop-names
# option.
Loading
Loading
Loading
Loading
@@ -46,7 +46,7 @@ def find_kerberos_user
return unless krb_principal
 
identity = ::Identity.find_by(provider: :kerberos, extern_uid: krb_principal)
identity.user if identity
identity&.user
end
 
# The Kerberos backend will translate spnego_token into a Kerberos
Loading
Loading
Loading
Loading
@@ -152,7 +152,7 @@ def mail_answer_thread(model, headers = {})
headers['In-Reply-To'] = message_id(model)
headers['References'] = message_id(model)
 
headers[:subject].prepend('Re: ') if headers[:subject]
headers[:subject]&.prepend('Re: ')
 
mail_thread(model, headers)
end
Loading
Loading
Loading
Loading
@@ -129,31 +129,25 @@ class ApplicationSetting < ActiveRecord::Base
numericality: { only_integer: true, greater_than_or_equal_to: 0 }
 
validates_each :restricted_visibility_levels do |record, attr, value|
unless value.nil?
value.each do |level|
unless Gitlab::VisibilityLevel.options.has_value?(level)
record.errors.add(attr, "'#{level}' is not a valid visibility level")
end
value&.each do |level|
unless Gitlab::VisibilityLevel.options.has_value?(level)
record.errors.add(attr, "'#{level}' is not a valid visibility level")
end
end
end
 
validates_each :import_sources do |record, attr, value|
unless value.nil?
value.each do |source|
unless Gitlab::ImportSources.options.has_value?(source)
record.errors.add(attr, "'#{source}' is not a import source")
end
value&.each do |source|
unless Gitlab::ImportSources.options.has_value?(source)
record.errors.add(attr, "'#{source}' is not a import source")
end
end
end
 
validates_each :disabled_oauth_sign_in_sources do |record, attr, value|
unless value.nil?
value.each do |source|
unless Devise.omniauth_providers.include?(source.to_sym)
record.errors.add(attr, "'#{source}' is not an OAuth sign-in source")
end
value&.each do |source|
unless Devise.omniauth_providers.include?(source.to_sym)
record.errors.add(attr, "'#{source}' is not an OAuth sign-in source")
end
end
end
Loading
Loading
@@ -255,11 +249,11 @@ def sidekiq_throttling_column_exists?
end
 
def domain_whitelist_raw
self.domain_whitelist.join("\n") unless self.domain_whitelist.nil?
self.domain_whitelist&.join("\n")
end
 
def domain_blacklist_raw
self.domain_blacklist.join("\n") unless self.domain_blacklist.nil?
self.domain_blacklist&.join("\n")
end
 
def domain_whitelist_raw=(values)
Loading
Loading
Loading
Loading
@@ -98,8 +98,8 @@ def award_emojis_loaded?
def update_assignee_cache_counts
# make sure we flush the cache for both the old *and* new assignees(if they exist)
previous_assignee = User.find_by_id(assignee_id_was) if assignee_id_was
previous_assignee.update_cache_counts if previous_assignee
assignee.update_cache_counts if assignee
previous_assignee&.update_cache_counts
assignee&.update_cache_counts
end
 
# We want to use optimistic lock for cases when only title or description are involved
Loading
Loading
Loading
Loading
@@ -73,7 +73,7 @@ def count_issues_by_state(user)
def memoize_per_user(user, method_name)
@memoized ||= {}
@memoized[method_name] ||= {}
@memoized[method_name][user.try!(:id)] ||= yield
@memoized[method_name][user&.id] ||= yield
end
 
# override in a class that includes this module to get a faster query
Loading
Loading
Loading
Loading
@@ -126,7 +126,7 @@ def stop_with_action!(current_user)
return unless available?
 
stop!
stop_action.play(current_user) if stop_action
stop_action&.play(current_user)
end
 
def actions_for(environment)
Loading
Loading
Loading
Loading
@@ -95,7 +95,7 @@ def build_dependents
end
 
def update_dependents_attributes
self.geo_node_key.title = "Geo node: #{self.url}" if self.geo_node_key
self.geo_node_key&.title = "Geo node: #{self.url}"
 
if self.primary?
self.oauth_application = nil
Loading
Loading
Loading
Loading
@@ -9,7 +9,7 @@ def self.build_collection(group, projects, params)
 
def self.build(group, projects, title)
super(projects, title).tap do |milestone|
milestone.group = group if milestone
milestone&.group = group
end
end
 
Loading
Loading
Loading
Loading
@@ -945,9 +945,7 @@ def ff_merge(user, source, target_branch, merge_request: nil)
 
GitOperationService.new(user, self).with_branch(
target_branch) do |start_commit|
if merge_request
merge_request.update(in_progress_merge_commit_sha: their_commit.oid)
end
merge_request&.update(in_progress_merge_commit_sha: their_commit.oid)
 
their_commit.oid
end
Loading
Loading
Loading
Loading
@@ -334,7 +334,7 @@ def find_by_username!(username)
 
def find_by_personal_access_token(token_string)
personal_access_token = PersonalAccessToken.active.find_by_token(token_string) if token_string
personal_access_token.user if personal_access_token
personal_access_token&.user
end
 
# Returns a user for the given SSH key.
Loading
Loading
Loading
Loading
@@ -69,16 +69,12 @@ def title=(new_title)
 
# The raw content of this page.
def content
@attributes[:content] ||= if @page
@page.text_data
end
@attributes[:content] ||= @page&.text_data
end
 
# The processed/formatted content of this page.
def formatted_content
@attributes[:formatted_content] ||= if @page
@page.formatted_data
end
@attributes[:formatted_content] ||= @page&.formatted_data
end
 
# The markup format for the page.
Loading
Loading
Loading
Loading
@@ -4,7 +4,7 @@ def execute(tag_name, target, message, release_description = nil)
return error('Tag name invalid') unless valid_tag
 
repository = project.repository
message.strip! if message
message&.strip!
 
new_tag = nil
 
Loading
Loading
Loading
Loading
@@ -9,7 +9,7 @@ def execute(tag_name)
 
if repository.rm_tag(current_user, tag_name)
release = project.releases.find_by(tag: tag_name)
release.destroy if release
release&.destroy
 
push_data = build_push_data(tag)
EventCreateService.new.push(project, current_user, push_data)
Loading
Loading
Loading
Loading
@@ -15,7 +15,7 @@ def execute
def before_create(issuable)
if @recaptcha_verified
spam_log = current_user.spam_logs.find_by(id: @spam_log_id, title: issuable.title)
spam_log.update!(recaptcha_verified: true) if spam_log
spam_log&.update!(recaptcha_verified: true)
else
issuable.spam = spam_service.check(@api)
issuable.spam_log = spam_service.spam_log
Loading
Loading
Loading
Loading
@@ -107,7 +107,7 @@ def after_create_actions
project.push_rule = push_rule
end
 
@project.group.refresh_members_authorized_projects if @project.group
@project.group&.refresh_members_authorized_projects
end
 
def skip_wiki?
Loading
Loading
Loading
Loading
@@ -16,6 +16,6 @@ def self.bulk_perform_async(args_list)
def perform(user_id)
user = User.find_by(id: user_id)
 
user.refresh_authorized_projects if user
user&.refresh_authorized_projects
end
end
Loading
Loading
@@ -84,7 +84,7 @@ class Branches < Grape::API
branch = user_project.repository.find_branch(params[:branch])
not_found!("Branch") unless branch
protected_branch = user_project.protected_branches.find_by(name: branch.name)
protected_branch.destroy if protected_branch
protected_branch&.destroy
 
present branch, with: Entities::RepoBranch, project: user_project
end
Loading
Loading
Loading
Loading
@@ -429,9 +429,7 @@ class Event < Grape::Entity
expose :author, using: Entities::UserBasic, if: ->(event, options) { event.author }
 
expose :author_username do |event, options|
if event.author
event.author.username
end
event.author&.username
end
end
 
Loading
Loading
Loading
Loading
@@ -58,7 +58,7 @@ def entry(key, entry, metadata)
def helpers(*nodes)
nodes.each do |symbol|
define_method("#{symbol}_defined?") do
@entries[symbol].specified? if @entries[symbol]
@entries[symbol]&.specified?
end
 
define_method("#{symbol}_value") do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment