Commit dc72c135 authored by Rémy Coutable's avatar Rémy Coutable

Fix EE-specific offenses to the LineBreakAfterGuardClauses cop

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 63a0f8e2
......@@ -9,6 +9,7 @@ module Oauth2
def execute
return error('access token not found') unless access_token
status = AccessTokenValidationService.new(access_token).validate
if status == AccessTokenValidationService::VALID
......
......@@ -69,6 +69,7 @@ module Projects
# Try for 30 seconds, polling every 10
3.times do
return true if reference_counter.value == 0
sleep 10
end
......
......@@ -7,6 +7,7 @@ module Prependable
return false
else
return false if base < self
super
base.singleton_class.send(:prepend, const_get('ClassMethods')) if const_defined?(:ClassMethods)
@_dependencies.each { |dep| base.send(:prepend, dep) }
......
......@@ -35,11 +35,13 @@ class AddIndexForPushrulesIsSample < ActiveRecord::Migration
def up
return if index_exists? :push_rules, :is_sample
add_concurrent_index(:push_rules, :is_sample, where: "is_sample")
end
def down
return unless index_exists? :push_rules, :is_sample
remove_concurrent_index(:push_rules, :is_sample, where: "is_sample")
end
end
......@@ -31,6 +31,7 @@ module EE
kubeclient.get_deployments(namespace: actual_namespace).as_json
rescue KubeException => err
raise err unless err.error_code == 404
[]
end
end
......
......@@ -366,6 +366,7 @@ module EE
def username_only_import_url
bare_url = read_attribute(:import_url)
return bare_url unless ::Gitlab::UrlSanitizer.valid?(bare_url)
::Gitlab::UrlSanitizer.new(bare_url, credentials: { user: import_data&.user }).full_url
end
......
......@@ -177,6 +177,7 @@ class License < ActiveRecord::Base
license = self.last
return unless license && license.valid?
license
end
end
......
......@@ -111,6 +111,7 @@ class RemoteMirror < ActiveRecord::Base
def url=(value)
return super(value) unless Gitlab::UrlSanitizer.valid?(value)
mirror_url = Gitlab::UrlSanitizer.new(value)
self.credentials = mirror_url.credentials
......
......@@ -8,6 +8,7 @@ class LdapGroupResetService
group.members.with_ldap_dn.map do |member|
# don't unauthorize the current user
next if current_user == member.user
member.update_attribute :access_level, Gitlab::Access::GUEST
end
......
......@@ -19,6 +19,7 @@ class RepositoryUpdateRemoteMirrorWorker
return if remote_mirror.updated_since?(scheduled_time)
raise UpdateAlreadyInProgressError if remote_mirror.update_in_progress?
remote_mirror.update_start
project = remote_mirror.project
......
......@@ -85,10 +85,12 @@ module Elasticsearch
bulk_operations = slice.map do |delta|
if delta.status == :deleted
next if delta.old_file[:mode].to_s(8) == "160000"
b = LiteBlob.new(repository_for_indexing, delta.old_file)
delete_blob(b)
else
next if delta.new_file[:mode].to_s(8) == "160000"
b = LiteBlob.new(repository_for_indexing, delta.new_file)
index_blob(b, to)
end
......@@ -112,6 +114,7 @@ module Elasticsearch
def delete_blob(blob)
return unless blob.text?
{
delete: {
_index: "#{self.class.index_name}",
......@@ -124,6 +127,7 @@ module Elasticsearch
def index_blob(blob, target_sha)
return unless can_index_blob?(blob)
{
index: {
_index: "#{self.class.index_name}",
......
......@@ -9,9 +9,11 @@ module Gitlab
def oauth_state_valid?
return false unless state
salt, hmac, return_to = state.split(':', 3)
return false unless return_to
hmac == generate_oauth_hmac(salt, return_to)
end
......
......@@ -94,6 +94,7 @@ module Gitlab
page, version = wiki_page_from_iterator(response) { |message| message.end_of_page }
break unless page && version
pages << [page, version]
end
......
......@@ -154,8 +154,10 @@ module Gitlab
# there can be only one Kerberos identity in GitLab; if the user has a Kerberos identity in AD,
# replace any existing Kerberos identity for the user
return unless ldap_user.kerberos_principal.present?
kerberos_identity = user.identities.where(provider: :kerberos).first
return if kerberos_identity && kerberos_identity.extern_uid == ldap_user.kerberos_principal
kerberos_identity ||= Identity.new(provider: :kerberos, user: user)
kerberos_identity.extern_uid = ldap_user.kerberos_principal
unless kerberos_identity.save
......
......@@ -426,6 +426,7 @@ module Gitlab
args = [gitlab_shell_projects_path, 'delete-remote-branches', storage, "#{project_name}.git", remote_name, *branch_names]
output, status = Popen.popen(args)
raise Error, output unless status.zero?
true
end
......
Markdown is supported
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