Commit 7d5eb7d0 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Resolve offenses for EE

parent 932c1ae8
...@@ -1196,9 +1196,11 @@ Gitlab/ModuleWithInstanceVariables: ...@@ -1196,9 +1196,11 @@ Gitlab/ModuleWithInstanceVariables:
Enable: true Enable: true
Exclude: Exclude:
# We ignore Rails helpers right now because it's hard to workaround it # We ignore Rails helpers right now because it's hard to workaround it
- app/helpers/*_helper.rb - app/helpers/**/*_helper.rb
- ee/app/helpers/**/*_helper.rb
# We ignore Rails mailers right now because it's hard to workaround it # We ignore Rails mailers right now because it's hard to workaround it
- app/mailers/emails/*.rb - app/mailers/emails/**/*.rb
- ee/**/emails/**/*.rb
# We ignore spec helpers because it usually doesn't matter # We ignore spec helpers because it usually doesn't matter
- spec/support/**/*.rb - spec/support/**/*.rb
- features/steps/**/*.rb - features/steps/**/*.rb
......
...@@ -81,7 +81,7 @@ module IssuableActions ...@@ -81,7 +81,7 @@ module IssuableActions
private private
def recaptcha_check_if_spammable(should_redirect = true, &block) def recaptcha_check_if_spammable(should_redirect = true, &block)
return yield unless @issuable.is_a? Spammable return yield unless issuable.is_a? Spammable
recaptcha_check_with_fallback(should_redirect, &block) recaptcha_check_with_fallback(should_redirect, &block)
end end
......
class AuditEvent < ActiveRecord::Base class AuditEvent < ActiveRecord::Base
prepend EE::AuditEvent prepend EE::AuditEvent
include Gitlab::Utils::StrongMemoize
serialize :details, Hash # rubocop:disable Cop/ActiveRecordSerialize serialize :details, Hash # rubocop:disable Cop/ActiveRecordSerialize
......
...@@ -10,8 +10,8 @@ module Prependable ...@@ -10,8 +10,8 @@ module Prependable
super super
base.singleton_class.send(:prepend, const_get('ClassMethods')) if const_defined?(:ClassMethods) base.singleton_class.send(:prepend, const_get('ClassMethods')) if const_defined?(:ClassMethods)
@_dependencies.each { |dep| base.send(:prepend, dep) } @_dependencies.each { |dep| base.send(:prepend, dep) } # rubocop:disable Gitlab/ModuleWithInstanceVariables
base.class_eval(&@_included_block) if instance_variable_defined?(:@_included_block) base.class_eval(&@_included_block) if instance_variable_defined?(:@_included_block) # rubocop:disable Gitlab/ModuleWithInstanceVariables
end end
end end
end end
......
module EE module EE
module LfsRequest module LfsRequest
extend ActiveSupport::Concern extend ActiveSupport::Concern
include ::Gitlab::Utils::StrongMemoize
def lfs_forbidden! def lfs_forbidden!
if project.above_size_limit? || objects_exceed_repo_limit? if project.above_size_limit? || objects_exceed_repo_limit?
...@@ -13,7 +14,7 @@ module EE ...@@ -13,7 +14,7 @@ module EE
def render_size_error def render_size_error
render( render(
json: { json: {
message: ::Gitlab::RepositorySizeError.new(project).push_error(@exceeded_limit), message: ::Gitlab::RepositorySizeError.new(project).push_error(@exceeded_limit), # rubocop:disable Gitlab/ModuleWithInstanceVariables
documentation_url: help_url documentation_url: help_url
}, },
content_type: "application/vnd.git-lfs+json", content_type: "application/vnd.git-lfs+json",
...@@ -23,13 +24,14 @@ module EE ...@@ -23,13 +24,14 @@ module EE
def objects_exceed_repo_limit? def objects_exceed_repo_limit?
return false unless project.size_limit_enabled? return false unless project.size_limit_enabled?
return @limit_exceeded if defined?(@limit_exceeded)
lfs_push_size = objects.sum { |o| o[:size] } strong_memoize(:limit_exceeded) do
size_with_lfs_push = project.repository_and_lfs_size + lfs_push_size lfs_push_size = objects.sum { |o| o[:size] }
size_with_lfs_push = project.repository_and_lfs_size + lfs_push_size
@exceeded_limit = size_with_lfs_push - project.actual_size_limit @exceeded_limit = size_with_lfs_push - project.actual_size_limit # rubocop:disable Gitlab/ModuleWithInstanceVariables
@limit_exceeded = @exceeded_limit > 0 @exceeded_limit > 0 # rubocop:disable Gitlab/ModuleWithInstanceVariables
end
end end
end end
end end
...@@ -14,6 +14,6 @@ module SafeMirrorParams ...@@ -14,6 +14,6 @@ module SafeMirrorParams
end end
def default_mirror_users def default_mirror_users
[current_user, @project.mirror_user].compact.uniq [current_user, project.mirror_user].compact.uniq
end end
end end
module EE::Admin::LogsController module EE::Admin::LogsController
include ::Gitlab::Utils::StrongMemoize
def loggers def loggers
raise NotImplementedError unless defined?(super) raise NotImplementedError unless defined?(super)
@loggers ||= super + [ strong_memoize(:loggers) do
Gitlab::GeoLogger super + [
] Gitlab::GeoLogger
]
end
end end
end end
...@@ -24,6 +24,7 @@ module EE ...@@ -24,6 +24,7 @@ module EE
end end
end end
# rubocop:disable Gitlab/ModuleWithInstanceVariables
def update def update
service = ::Boards::UpdateService.new(parent, current_user, board_params) service = ::Boards::UpdateService.new(parent, current_user, board_params)
...@@ -40,10 +41,11 @@ module EE ...@@ -40,10 +41,11 @@ module EE
end end
end end
end end
# rubocop:enable Gitlab/ModuleWithInstanceVariables
def destroy def destroy
service = ::Boards::DestroyService.new(parent, current_user) service = ::Boards::DestroyService.new(parent, current_user)
service.execute(@board) service.execute(@board) # rubocop:disable Gitlab/ModuleWithInstanceVariables
respond_to do |format| respond_to do |format|
format.json { head :ok } format.json { head :ok }
...@@ -62,15 +64,15 @@ module EE ...@@ -62,15 +64,15 @@ module EE
end end
def find_board def find_board
@board = parent.boards.find(params[:id]) @board = parent.boards.find(params[:id]) # rubocop:disable Gitlab/ModuleWithInstanceVariables
end end
def parent def parent
@parent ||= @project || @group @parent ||= @project || @group # rubocop:disable Gitlab/ModuleWithInstanceVariables
end end
def boards_path def boards_path
if @group if @group # rubocop:disable Gitlab/ModuleWithInstanceVariables
group_boards_path(parent) group_boards_path(parent)
else else
project_boards_path(parent) project_boards_path(parent)
...@@ -78,7 +80,7 @@ module EE ...@@ -78,7 +80,7 @@ module EE
end end
def board_path(board) def board_path(board)
if @group if @group # rubocop:disable Gitlab/ModuleWithInstanceVariables
group_board_path(parent, board) group_board_path(parent, board)
else else
project_board_path(parent, board) project_board_path(parent, board)
......
module EE module EE
module Groups module Groups
module GroupMembersController module GroupMembersController
# rubocop:disable Gitlab/ModuleWithInstanceVariables
def override def override
@group_member = @group.group_members.find(params[:id]) @group_member = @group.group_members.find(params[:id])
...@@ -14,6 +15,7 @@ module EE ...@@ -14,6 +15,7 @@ module EE
end end
end end
end end
# rubocop:enable Gitlab/ModuleWithInstanceVariables
protected protected
......
...@@ -3,7 +3,7 @@ module EE ...@@ -3,7 +3,7 @@ module EE
protected protected
def fail_login def fail_login
log_failed_login(@user.username, oauth['provider']) log_failed_login(@user.username, oauth['provider']) # rubocop:disable Gitlab/ModuleWithInstanceVariables
super super
end end
......
...@@ -33,7 +33,7 @@ module EE ...@@ -33,7 +33,7 @@ module EE
payload = ::Gitlab::Geo::JwtRequestDecoder.new(request.headers['Authorization']).decode payload = ::Gitlab::Geo::JwtRequestDecoder.new(request.headers['Authorization']).decode
if payload if payload
@authentication_result = ::Gitlab::Auth::Result.new(nil, project, :geo, [:download_code]) @authentication_result = ::Gitlab::Auth::Result.new(nil, project, :geo, [:download_code]) # rubocop:disable Gitlab/ModuleWithInstanceVariables
return # grant access return # grant access
end end
......
...@@ -11,8 +11,8 @@ module EE ...@@ -11,8 +11,8 @@ module EE
end end
def service_desk def service_desk
@issues = @issuables @issues = @issuables # rubocop:disable Gitlab/ModuleWithInstanceVariables
@users.push(::User.support_bot) @users.push(::User.support_bot) # rubocop:disable Gitlab/ModuleWithInstanceVariables
end end
def export_csv def export_csv
......
...@@ -7,11 +7,11 @@ module EE ...@@ -7,11 +7,11 @@ module EE
private private
def set_suggested_approvers def set_suggested_approvers
if @merge_request.requires_approve? if merge_request.requires_approve?
@suggested_approvers = ::Gitlab::AuthorityAnalyzer.new( @suggested_approvers = ::Gitlab::AuthorityAnalyzer.new( # rubocop:disable Gitlab/ModuleWithInstanceVariables
@merge_request, merge_request,
@merge_request.author || current_user merge_request.author || current_user
).calculate(@merge_request.approvals_required) ).calculate(merge_request.approvals_required)
end end
end end
...@@ -38,12 +38,12 @@ module EE ...@@ -38,12 +38,12 @@ module EE
# Target the MR target project in priority, else it depends whether the project # Target the MR target project in priority, else it depends whether the project
# is forked. # is forked.
target_project = if @merge_request target_project = if merge_request
@merge_request.target_project merge_request.target_project
elsif @project.forked? && @project.id.to_s != mr_params[:target_project_id] elsif project.forked? && project.id.to_s != mr_params[:target_project_id]
@project.forked_from_project project.forked_from_project
else else
@project project
end end
if mr_params[:approvals_before_merge].to_i <= target_project.approvals_before_merge if mr_params[:approvals_before_merge].to_i <= target_project.approvals_before_merge
......
...@@ -9,19 +9,19 @@ module EE ...@@ -9,19 +9,19 @@ module EE
end end
def rebase def rebase
RebaseWorker.perform_async(@merge_request.id, current_user.id) RebaseWorker.perform_async(merge_request.id, current_user.id)
render nothing: true, status: 200 render nothing: true, status: 200
end end
def approve def approve
unless @merge_request.can_approve?(current_user) unless merge_request.can_approve?(current_user)
return render_404 return render_404
end end
::MergeRequests::ApprovalService ::MergeRequests::ApprovalService
.new(project, current_user) .new(project, current_user)
.execute(@merge_request) .execute(merge_request)
render_approvals_json render_approvals_json
end end
...@@ -31,10 +31,10 @@ module EE ...@@ -31,10 +31,10 @@ module EE
end end
def unapprove def unapprove
if @merge_request.has_approved?(current_user) if merge_request.has_approved?(current_user)
::MergeRequests::RemoveApprovalService ::MergeRequests::RemoveApprovalService
.new(project, current_user) .new(project, current_user)
.execute(@merge_request) .execute(merge_request)
end end
render_approvals_json render_approvals_json
...@@ -51,7 +51,7 @@ module EE ...@@ -51,7 +51,7 @@ module EE
def render_approvals_json def render_approvals_json
respond_to do |format| respond_to do |format|
format.json do format.json do
entity = ::API::Entities::MergeRequestApprovals.new(@merge_request, current_user: current_user) entity = ::API::Entities::MergeRequestApprovals.new(merge_request, current_user: current_user)
render json: entity render json: entity
end end
end end
...@@ -65,11 +65,11 @@ module EE ...@@ -65,11 +65,11 @@ module EE
end end
def check_user_can_push_to_source_branch! def check_user_can_push_to_source_branch!
return access_denied! unless @merge_request.source_branch_exists? return access_denied! unless merge_request.source_branch_exists?
access_check = ::Gitlab::UserAccess access_check = ::Gitlab::UserAccess
.new(current_user, project: @merge_request.source_project) .new(current_user, project: merge_request.source_project)
.can_push_to_branch?(@merge_request.source_branch) .can_push_to_branch?(merge_request.source_branch)
access_denied! unless access_check access_denied! unless access_check
end end
......
...@@ -15,15 +15,16 @@ module EE ...@@ -15,15 +15,16 @@ module EE
return unless project.feature_available?(:push_rules) return unless project.feature_available?(:push_rules)
project.create_push_rule unless project.push_rule project.create_push_rule unless project.push_rule
@push_rule = project.push_rule @push_rule = project.push_rule # rubocop:disable Gitlab/ModuleWithInstanceVariables
end end
def remote_mirror def remote_mirror
return unless project.feature_available?(:repository_mirrors) return unless project.feature_available?(:repository_mirrors)
@remote_mirror = @project.remote_mirrors.first_or_initialize @remote_mirror = project.remote_mirrors.first_or_initialize # rubocop:disable Gitlab/ModuleWithInstanceVariables
end end
# rubocop:disable Gitlab/ModuleWithInstanceVariables
def acces_levels_options def acces_levels_options
super.merge( super.merge(
selected_merge_access_levels: @protected_branch.merge_access_levels.map { |access_level| access_level.user_id || access_level.access_level }, selected_merge_access_levels: @protected_branch.merge_access_levels.map { |access_level| access_level.user_id || access_level.access_level },
...@@ -31,11 +32,12 @@ module EE ...@@ -31,11 +32,12 @@ module EE
selected_create_access_levels: @protected_tag.create_access_levels.map { |access_level| access_level.user_id || access_level.access_level } selected_create_access_levels: @protected_tag.create_access_levels.map { |access_level| access_level.user_id || access_level.access_level }
) )
end end
# rubocop:enable Gitlab/ModuleWithInstanceVariables
def load_gon_index def load_gon_index
super super
gon.push(current_project_id: @project.id) if @project gon.push(current_project_id: project.id) if project
end end
end end
end end
......
...@@ -26,7 +26,7 @@ module EE ...@@ -26,7 +26,7 @@ module EE
return unless ::Gitlab::Geo.secondary? return unless ::Gitlab::Geo.secondary?
oauth = ::Gitlab::Geo::OauthSession.new(access_token: session[:access_token]) oauth = ::Gitlab::Geo::OauthSession.new(access_token: session[:access_token])
@geo_logout_state = oauth.generate_logout_state @geo_logout_state = oauth.generate_logout_state # rubocop:disable Gitlab/ModuleWithInstanceVariables
end end
def log_failed_login def log_failed_login
......
...@@ -10,7 +10,7 @@ module EE ...@@ -10,7 +10,7 @@ module EE
return unless entity_type && entity_id return unless entity_type && entity_id
# Avoiding exception if the record doesn't exist # Avoiding exception if the record doesn't exist
@entity ||= entity_type.constantize.find_by_id(entity_id) @entity ||= entity_type.constantize.find_by_id(entity_id) # rubocop:disable Gitlab/ModuleWithInstanceVariables
end end
def present def present
......
...@@ -5,6 +5,7 @@ module EE ...@@ -5,6 +5,7 @@ module EE
# and be prepended in the `Namespace` model # and be prepended in the `Namespace` model
module Namespace module Namespace
extend ActiveSupport::Concern extend ActiveSupport::Concern
include ::Gitlab::Utils::StrongMemoize
FREE_PLAN = 'free'.freeze FREE_PLAN = 'free'.freeze
...@@ -67,19 +68,23 @@ module EE ...@@ -67,19 +68,23 @@ module EE
# for a given Namespace plan. This method should consider ancestor groups # for a given Namespace plan. This method should consider ancestor groups
# being licensed. # being licensed.
def feature_available?(feature) def feature_available?(feature)
@feature_available ||= Hash.new do |h, feature| available_features = strong_memoize(:feature_available) do
h[feature] = load_feature_available(feature) Hash.new do |h, feature|
h[feature] = load_feature_available(feature)
end
end end
@feature_available[feature] available_features[feature]
end end
def feature_available_in_plan?(feature) def feature_available_in_plan?(feature)
@features_available_in_plan ||= Hash.new do |h, feature| available_features = strong_memoize(:features_available_in_plan) do
h[feature] = (plans.map(&:name) & self.class.plans_with_feature(feature)).any? Hash.new do |h, feature|
h[feature] = (plans.map(&:name) & self.class.plans_with_feature(feature)).any?
end
end end
@features_available_in_plan[feature] available_features[feature]
end end
# The main difference between the "plan" column and this method is that "plan" # The main difference between the "plan" column and this method is that "plan"
...@@ -128,9 +133,9 @@ module EE ...@@ -128,9 +133,9 @@ module EE
# These helper methods are required to not break the Namespace API. # These helper methods are required to not break the Namespace API.
def plan=(plan_name) def plan=(plan_name)
if plan_name.is_a?(String) if plan_name.is_a?(String)
@plan_name = plan_name @plan_name = plan_name # rubocop:disable Gitlab/ModuleWithInstanceVariables
super(Plan.find_by(name: @plan_name)) super(Plan.find_by(name: @plan_name)) # rubocop:disable Gitlab/ModuleWithInstanceVariables
else else
super super
end end
...@@ -149,7 +154,7 @@ module EE ...@@ -149,7 +154,7 @@ module EE
private private
def validate_plan_name def validate_plan_name
if @plan_name.present? && PLANS.exclude?(@plan_name) if @plan_name.present? && PLANS.exclude?(@plan_name) # rubocop:disable Gitlab/ModuleWithInstanceVariables
errors.add(:plan, 'is not included in the list') errors.add(:plan, 'is not included in the list')
end end
end end
......
...@@ -5,6 +5,7 @@ module EE ...@@ -5,6 +5,7 @@ module EE
# and be prepended in the `Project` model # and be prepended in the `Project` model
module Project module Project
extend ActiveSupport::Concern extend ActiveSupport::Concern
include ::Gitlab::Utils::StrongMemoize
prepended do prepended do
include Elastic::ProjectsSearch include Elastic::ProjectsSearch
...@@ -258,8 +259,9 @@ module EE ...@@ -258,8 +259,9 @@ module EE
def deployment_platform(environment: nil) def deployment_platform(environment: nil)
return super unless environment && feature_available?(:multiple_clusters) return super unless environment && feature_available?(:multiple_clusters)
@deployment_platform ||= clusters.enabled.on_environment(environment.name) @deployment_platform ||= # rubocop:disable Gitlab/ModuleWithInstanceVariables
.last&.platform_kubernetes clusters.enabled.on_environment(environment.name)
.last&.platform_kubernetes
super # Wildcard or KubernetesService super # Wildcard or KubernetesService
end end
...@@ -323,8 +325,11 @@ module EE ...@@ -323,8 +325,11 @@ module EE
end end
def find_path_lock(path, exact_match: false, downstream: false) def find_path_lock(path, exact_match: false, downstream: false)
@path_lock_finder ||= ::Gitlab::PathLocksFinder.new(self) path_lock_finder = strong_memoize(:path_lock_finder) do
@path_lock_finder.find(path, exact_match: exact_match, downstream: downstream) ::Gitlab::PathLocksFinder.new(self)
end
path_lock_finder.find(path, exact_match: exact_match, downstream: downstream)
end end
def import_url_updated? def import_url_updated?
...@@ -450,15 +455,15 @@ module EE ...@@ -450,15 +455,15 @@ module EE
end end
def disabled_services def disabled_services
return @disabled_services if defined?(@disabled_services) strong_memoize(:disabled_services) do
disabled_services = []
@disabled_services = [] unless feature_available?(:jenkins_integration)
disabled_services.push('jenkins', 'jenkins_deprecated')
end
unless feature_available?(:jenkins_integration) disabled_services
@disabled_services.push('jenkins', 'jenkins_deprecated')
end end
@disabled_services
end end
def remote_mirror_available? def remote_mirror_available?
...@@ -479,11 +484,13 @@ module EE ...@@ -479,11 +484,13 @@ module EE
end end
def licensed_feature_available?(feature) def licensed_feature_available?(feature)
@licensed_feature_available ||= Hash.new do |h, feature| available_features = strong_memoize(:licensed_feature_available) do
h[feature] = load_licensed_feature_available(feature) Hash.new do |h, feature|
h[feature] = load_licensed_feature_available(feature)
end
end end
@licensed_feature_available[feature] available_features[feature]
end end
def load_licensed_feature_available(feature) def load_licensed_feature_available(feature)
......
module EE module EE
module Applications module Applications
# rubocop:disable Gitlab/ModuleWithInstanceVariables
module CreateService module CreateService
def execute(request) def execute(request)
super.tap do |application| super.tap do |application|
......
module EE module EE
module AuditEventService module AuditEventService
# rubocop:disable Gitlab/ModuleWithInstanceVariables
def for_member(member) def for_member(member)
action = @details[:action] action = @details[:action]
old_access_level = @details[:old_access_level] old_access_level = @details[:old_access_level]
...@@ -199,5 +200,6 @@ module EE ...@@ -199,5 +200,6 @@ module EE
} }
end end
end end
# rubocop:enable Gitlab/ModuleWithInstanceVariables
end end
end end
...@@ -3,8 +3,8 @@ module EE ...@@ -3,8 +3,8 @@ module EE
module Issues module Issues
module ListService module ListService
def set_parent def set_parent
if @parent.is_a?(Group) if parent.is_a?(Group)
params[:group_id] = @parent.id params[:group_id] = parent.id
else else
super super
end end
......
...@@ -12,11 +12,11 @@ module EE ...@@ -12,11 +12,11 @@ module EE
end end
def audit_event_service def audit_event_service
::AuditEventService.new(@user, ::AuditEventService.new(user,
@user, user,
action: :custom, action: :custom,
custom_message: 'Added SSH key', custom_message: 'Added SSH key',
ip_address: @ip_address) ip_address: @ip_address) # rubocop:disable Gitlab/ModuleWithInstanceVariables
end end
end end
end end
......
...@@ -25,8 +25,8 @@ module EE ...@@ -25,8 +25,8 @@ module EE
private private
def check_size_limit def check_size_limit
if @merge_request.target_project.above_size_limit? if merge_request.target_project.above_size_limit?
message = ::Gitlab::RepositorySizeError.new(@merge_request.target_project).merge_error message = ::Gitlab::RepositorySizeError.new(merge_request.target_project).merge_error
raise ::MergeRequests::MergeService::MergeError, message raise ::MergeRequests::MergeService::MergeError, message
end end
......
...@@ -41,7 +41,7 @@ module EE ...@@ -41,7 +41,7 @@ module EE
create_predefined_push_rule create_predefined_push_rule
@project.group&.refresh_members_authorized_projects project.group&.refresh_members_authorized_projects
end end
def create_predefined_push_rule def create_predefined_push_rule
......
...@@ -8,12 +8,12 @@ module EE ...@@ -8,12 +8,12 @@ module EE
super super
EE::Audit::ProjectChangesAuditor.new(@current_user, project).execute EE::Audit::ProjectChangesAuditor.new(current_user, project).execute
::Geo::RepositoryRenamedEventStore.new( ::Geo::RepositoryRenamedEventStore.new(
project, project,
old_path: project.path, old_path: project.path,
old_path_with_namespace: @old_path old_path_with_namespace: @old_path # rubocop:disable Gitlab/ModuleWithInstanceVariables
).create ).create
end end
end end
......
...@@ -26,15 +26,15 @@ module EE ...@@ -26,15 +26,15 @@ module EE
end end
def groups_accessible? def groups_accessible?
group_ids = @merge_params.group_ids + @push_params.group_ids group_ids = @merge_params.group_ids + @push_params.group_ids # rubocop:disable Gitlab/ModuleWithInstanceVariables
allowed_groups = @project.invited_groups.where(id: group_ids) allowed_groups = @project.invited_groups.where(id: group_ids) # rubocop:disable Gitlab/ModuleWithInstanceVariables
group_ids.count == allowed_groups.count group_ids.count == allowed_groups.count
end end
def users_accessible? def users_accessible?
user_ids = @merge_params.user_ids + @push_params.user_ids user_ids = @merge_params.user_ids + @push_params.user_ids # rubocop:disable Gitlab/ModuleWithInstanceVariables
allowed_users = @project.team.users.where(id: user_ids) allowed_users = @project.team.users.where(id: user_ids) # rubocop:disable Gitlab/ModuleWithInstanceVariables
user_ids.count == allowed_users.count user_ids.count == allowed_users.count
end end
......
...@@ -3,7 +3,7 @@ module EE ...@@ -3,7 +3,7 @@ module EE
def execute(blocking: true) def execute(blocking: true)
result = super result = super
@user_ids.each do |id| @user_ids.each do |id| # rubocop:disable Gitlab/ModuleWithInstanceVariables
::Gitlab::Database::LoadBalancing::Sticking.stick(:user, id) ::Gitlab::Database::LoadBalancing::Sticking.stick(:user, id)
end end
......
...@@ -6,7 +6,7 @@ module EE ...@@ -6,7 +6,7 @@ module EE
private private
def notify_success(user_exists) def notify_success(user_exists)
notify_new_user(@user, nil) unless user_exists notify_new_user(@user, nil) unless user_exists # rubocop:disable Gitlab/ModuleWithInstanceVariables
audit_changes(:email, as: 'email address') audit_changes(:email, as: 'email address')
audit_changes(:encrypted_password, as: 'password', skip_changes: true) audit_changes(:encrypted_password, as: 'password', skip_changes: true)
......
...@@ -2,14 +2,14 @@ module EE ...@@ -2,14 +2,14 @@ module EE
module API module API
module Helpers module Helpers
def current_user def current_user
return @current_user if defined?(@current_user) strong_memoize(:current_user) do
user = super
user = super ::Gitlab::Database::LoadBalancing::RackMiddleware
.stick_or_unstick(env, :user, user.id) if user
::Gitlab::Database::LoadBalancing::RackMiddleware user
.stick_or_unstick(env, :user, user.id) if user end
user
end end
def check_project_feature_available!(feature) def check_project_feature_available!(feature)
......
...@@ -6,7 +6,7 @@ module EE ...@@ -6,7 +6,7 @@ module EE
private private
def project_or_wiki def project_or_wiki
@project.wiki project.wiki
end end
end end
end end
......
...@@ -2,24 +2,26 @@ module EE ...@@ -2,24 +2,26 @@ module EE
module Gitlab module Gitlab
module OAuth module OAuth
module AuthHash module AuthHash
include ::Gitlab::Utils::StrongMemoize
def kerberos_default_realm def kerberos_default_realm
::Gitlab::Kerberos::Authentication.kerberos_default_realm ::Gitlab::Kerberos::Authentication.kerberos_default_realm
end end
def uid def uid
return @ee_uid if defined?(@ee_uid) strong_memoize(:ee_uid) do
ee_uid = super
ee_uid = super # For Kerberos, usernames `principal` and `principal@DEFAULT.REALM`
# are equivalent and may be used indifferently, but omniauth_kerberos
# does not normalize them as of version 0.3.0, so add the default
# realm ourselves if appropriate
if provider == 'kerberos' && ee_uid.present?
ee_uid += "@#{kerberos_default_realm}" unless ee_uid.include?('@')
end
# For Kerberos, usernames `principal` and `principal@DEFAULT.REALM` ee_uid
# are equivalent and may be used indifferently, but omniauth_kerberos
# does not normalize them as of version 0.3.0, so add the default
# realm ourselves if appropriate
if provider == 'kerberos' && ee_uid.present?
ee_uid += "@#{kerberos_default_realm}" unless ee_uid.include?('@')
end end
@ee_uid = ee_uid
end end
end end
end end
......
...@@ -44,9 +44,9 @@ module Gitlab ...@@ -44,9 +44,9 @@ module Gitlab
end end
def abort_if_no_geo_config! def abort_if_no_geo_config!
@geo_config_exists ||= File.exist?(Rails.root.join(GEO_DATABASE_CONFIG)) @geo_config_exists ||= File.exist?(Rails.root.join(GEO_DATABASE_CONFIG)) # rubocop:disable Gitlab/ModuleWithInstanceVariables
unless @geo_config_exists unless @geo_config_exists # rubocop:disable Gitlab/ModuleWithInstanceVariables
abort("Failed to open #{GEO_DATABASE_CONFIG}. Consult the documentation on how to set up GitLab Geo.") abort("Failed to open #{GEO_DATABASE_CONFIG}. Consult the documentation on how to set up GitLab Geo.")
end end
end end
......
...@@ -3,6 +3,7 @@ module API ...@@ -3,6 +3,7 @@ module API
prepend EE::API::Helpers prepend EE::API::Helpers
include Gitlab::Utils include Gitlab::Utils
include Gitlab::Utils::StrongMemoize
include Helpers::Pagination include Helpers::Pagination
SUDO_HEADER = "HTTP_SUDO".freeze SUDO_HEADER = "HTTP_SUDO".freeze
......
...@@ -3,7 +3,7 @@ module EE ...@@ -3,7 +3,7 @@ module EE
module Changes module Changes
def audit_changes(column, options = {}) def audit_changes(column, options = {})
column = options[:column] || column column = options[:column] || column
@model = options[:model] @model = options[:model] # rubocop:disable Gitlab/ModuleWithInstanceVariables
return unless changed?(column) return unless changed?(column)
...@@ -39,7 +39,7 @@ module EE ...@@ -39,7 +39,7 @@ module EE
end end
def audit_event(options) def audit_event(options)
::AuditEventService.new(@current_user, model, options) ::AuditEventService.new(@current_user, model, options) # rubocop:disable Gitlab/ModuleWithInstanceVariables
.for_changes.security_event .for_changes.security_event
end end
end end
......
...@@ -57,7 +57,7 @@ module Gitlab ...@@ -57,7 +57,7 @@ module Gitlab
job = ::Ci::Build.find_by(token: token) job = ::Ci::Build.find_by(token: token)
raise UnauthorizedError unless job raise UnauthorizedError unless job
@job_token_authentication = true @job_token_authentication = true # rubocop:disable Gitlab/ModuleWithInstanceVariables
job.user job.user
end end
......
...@@ -37,7 +37,7 @@ module Gitlab ...@@ -37,7 +37,7 @@ module Gitlab
}, },
{ {
title: "Weight", title: "Weight",
value: @resource.weight? ? @resource.weight : "_None_", value: resource.weight? ? resource.weight : "_None_",
short: true short: true
} }
] ]
......
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