Skip to content
Snippets Groups Projects
Commit 0430b764 authored by Grzegorz Bizon's avatar Grzegorz Bizon Committed by Rémy Coutable
Browse files

Enable Style/DotPosition Rubocop :cop:

parent 78ee24ba
No related branches found
No related tags found
No related merge requests found
Showing
with 102 additions and 102 deletions
Loading
Loading
@@ -159,9 +159,9 @@ class RenameSystemNamespaces < ActiveRecord::Migration
end
 
def system_namespace
@system_namespace ||= Namespace.where(parent_id: nil).
where(arel_table[:path].matches(system_namespace_path)).
first
@system_namespace ||= Namespace.where(parent_id: nil)
.where(arel_table[:path].matches(system_namespace_path))
.first
end
 
def system_namespace_path
Loading
Loading
@@ -209,8 +209,8 @@ class RenameSystemNamespaces < ActiveRecord::Migration
end
 
def repo_paths_for_namespace(namespace)
projects_for_namespace(namespace).distinct.
select(:repository_storage).map(&:repository_storage_path)
projects_for_namespace(namespace).distinct
.select(:repository_storage).map(&:repository_storage_path)
end
 
def uploads_dir
Loading
Loading
Loading
Loading
@@ -87,8 +87,8 @@ class TurnNestedGroupsIntoRegularGroupsForMysql < ActiveRecord::Migration
while current&.parent_id
# We're using find_by(id: ...) here to deal with cases where the
# parent_id may point to a missing row.
current = Namespace.unscoped.select([:id, :parent_id]).
find_by(id: current.parent_id)
current = Namespace.unscoped.select([:id, :parent_id])
.find_by(id: current.parent_id)
 
ancestors << current.id if current
end
Loading
Loading
@@ -99,11 +99,11 @@ class TurnNestedGroupsIntoRegularGroupsForMysql < ActiveRecord::Migration
# Returns a relation containing all the members that have access to any of
# the current namespace's parent namespaces.
def all_members_for(namespace)
Member.
unscoped.
select(['user_id', 'MAX(access_level) AS access_level']).
where(source_type: 'Namespace', source_id: ancestors_for(namespace)).
group(:user_id)
Member
.unscoped
.select(['user_id', 'MAX(access_level) AS access_level'])
.where(source_type: 'Namespace', source_id: ancestors_for(namespace))
.group(:user_id)
end
 
def bulk_insert_members(rows)
Loading
Loading
Loading
Loading
@@ -13,13 +13,13 @@ class FixProjectRecordsWithInvalidVisibility < ActiveRecord::Migration
namespaces = Arel::Table.new(:namespaces)
 
finder_sql =
projects.
join(namespaces, Arel::Nodes::InnerJoin).
on(projects[:namespace_id].eq(namespaces[:id])).
where(projects[:visibility_level].gt(namespaces[:visibility_level])).
project(projects[:id], namespaces[:visibility_level]).
take(BATCH_SIZE).
to_sql
projects
.join(namespaces, Arel::Nodes::InnerJoin)
.on(projects[:namespace_id].eq(namespaces[:id]))
.where(projects[:visibility_level].gt(namespaces[:visibility_level]))
.project(projects[:id], namespaces[:visibility_level])
.take(BATCH_SIZE)
.to_sql
 
# Update matching rows in batches. Each batch can cause up to 3 UPDATE
# statements, in addition to the SELECT: one per visibility_level
Loading
Loading
@@ -33,10 +33,10 @@ class FixProjectRecordsWithInvalidVisibility < ActiveRecord::Migration
end
 
updates.each do |visibility_level, project_ids|
updater = Arel::UpdateManager.new(ActiveRecord::Base).
table(projects).
set(projects[:visibility_level] => visibility_level).
where(projects[:id].in(project_ids))
updater = Arel::UpdateManager.new(ActiveRecord::Base)
.table(projects)
.set(projects[:visibility_level] => visibility_level)
.where(projects[:id].in(project_ids))
 
ActiveRecord::Base.connection.exec_update(updater.to_sql, self.class.name, [])
end
Loading
Loading
Loading
Loading
@@ -79,17 +79,17 @@ class RenameReservedProjectNames < ActiveRecord::Migration
private
 
def reserved_projects
Project.unscoped.
includes(:namespace).
where('EXISTS (SELECT 1 FROM namespaces WHERE projects.namespace_id = namespaces.id)').
where('projects.path' => KNOWN_PATHS)
Project.unscoped
.includes(:namespace)
.where('EXISTS (SELECT 1 FROM namespaces WHERE projects.namespace_id = namespaces.id)')
.where('projects.path' => KNOWN_PATHS)
end
 
def route_exists?(full_path)
quoted_path = ActiveRecord::Base.connection.quote_string(full_path)
 
ActiveRecord::Base.connection.
select_all("SELECT id, path FROM routes WHERE path = '#{quoted_path}'").present?
ActiveRecord::Base.connection
.select_all("SELECT id, path FROM routes WHERE path = '#{quoted_path}'").present?
end
 
# Adds number to the end of the path that is not taken by other route
Loading
Loading
Loading
Loading
@@ -39,11 +39,11 @@ class RequeuePendingDeleteProjects < ActiveRecord::Migration
 
def find_batch
projects = Arel::Table.new(:projects)
projects.project(projects[:id]).
where(projects[:pending_delete].eq(true)).
where(projects[:namespace_id].not_eq(nil)).
skip(@offset * BATCH_SIZE).
take(BATCH_SIZE).
to_sql
projects.project(projects[:id])
.where(projects[:pending_delete].eq(true))
.where(projects[:namespace_id].not_eq(nil))
.skip(@offset * BATCH_SIZE)
.take(BATCH_SIZE)
.to_sql
end
end
Loading
Loading
@@ -15,8 +15,8 @@ class FillAuthorizedProjects < ActiveRecord::Migration
disable_ddl_transaction!
 
def up
relation = User.select(:id).
where('authorized_projects_populated IS NOT TRUE')
relation = User.select(:id)
.where('authorized_projects_populated IS NOT TRUE')
 
relation.find_in_batches(batch_size: 1_000) do |rows|
args = rows.map { |row| [row.id] }
Loading
Loading
Loading
Loading
@@ -21,17 +21,17 @@ class RenameMoreReservedProjectNames < ActiveRecord::Migration
private
 
def reserved_projects
Project.unscoped.
includes(:namespace).
where('EXISTS (SELECT 1 FROM namespaces WHERE projects.namespace_id = namespaces.id)').
where('projects.path' => KNOWN_PATHS)
Project.unscoped
.includes(:namespace)
.where('EXISTS (SELECT 1 FROM namespaces WHERE projects.namespace_id = namespaces.id)')
.where('projects.path' => KNOWN_PATHS)
end
 
def route_exists?(full_path)
quoted_path = ActiveRecord::Base.connection.quote_string(full_path)
 
ActiveRecord::Base.connection.
select_all("SELECT id, path FROM routes WHERE path = '#{quoted_path}'").present?
ActiveRecord::Base.connection
.select_all("SELECT id, path FROM routes WHERE path = '#{quoted_path}'").present?
end
 
# Adds number to the end of the path that is not taken by other route
Loading
Loading
Loading
Loading
@@ -38,11 +38,11 @@ class MigrateUserActivitiesToUsersLastActivityOn < ActiveRecord::Migration
activities = activities(day.at_beginning_of_day, day.at_end_of_day, page: page)
 
update_sql =
Arel::UpdateManager.new(ActiveRecord::Base).
table(users_table).
set(users_table[:last_activity_on] => day.to_date).
where(users_table[:username].in(activities.map(&:first))).
to_sql
Arel::UpdateManager.new(ActiveRecord::Base)
.table(users_table)
.set(users_table[:last_activity_on] => day.to_date)
.where(users_table[:username].in(activities.map(&:first)))
.to_sql
 
connection.exec_update(update_sql, self.class.name, [])
 
Loading
Loading
Loading
Loading
@@ -37,11 +37,11 @@ class CleanupNamespacelessPendingDeleteProjects < ActiveRecord::Migration
 
def find_batch
projects = Arel::Table.new(:projects)
projects.project(projects[:id]).
where(projects[:pending_delete].eq(true)).
where(projects[:namespace_id].eq(nil)).
skip(@offset * BATCH_SIZE).
take(BATCH_SIZE).
to_sql
projects.project(projects[:id])
.where(projects[:pending_delete].eq(true))
.where(projects[:namespace_id].eq(nil))
.skip(@offset * BATCH_SIZE)
.take(BATCH_SIZE)
.to_sql
end
end
Loading
Loading
@@ -9,11 +9,11 @@ class AddHeadPipelineForEachMergeRequest < ActiveRecord::Migration
pipelines = Arel::Table.new(:ci_pipelines)
merge_requests = Arel::Table.new(:merge_requests)
 
head_id = pipelines.
project(Arel::Nodes::NamedFunction.new('max', [pipelines[:id]])).
from(pipelines).
where(pipelines[:ref].eq(merge_requests[:source_branch])).
where(pipelines[:project_id].eq(merge_requests[:source_project_id]))
head_id = pipelines
.project(Arel::Nodes::NamedFunction.new('max', [pipelines[:id]]))
.from(pipelines)
.where(pipelines[:ref].eq(merge_requests[:source_branch]))
.where(pipelines[:project_id].eq(merge_requests[:source_project_id]))
 
sub_query = Arel::Nodes::SqlLiteral.new(Arel::Nodes::Grouping.new(head_id).to_sql)
 
Loading
Loading
Loading
Loading
@@ -68,8 +68,8 @@ module API
delete ":id/access_requests/:user_id" do
source = find_source(source_type, params[:id])
 
::Members::DestroyService.new(source, current_user, params).
execute(:requesters)
::Members::DestroyService.new(source, current_user, params)
.execute(:requesters)
end
end
end
Loading
Loading
Loading
Loading
@@ -102,8 +102,8 @@ module API
post ":id/repository/branches" do
authorize_push_project
 
result = CreateBranchService.new(user_project, current_user).
execute(params[:branch], params[:ref])
result = CreateBranchService.new(user_project, current_user)
.execute(params[:branch], params[:ref])
 
if result[:status] == :success
present result[:branch],
Loading
Loading
@@ -121,8 +121,8 @@ module API
delete ":id/repository/branches/:branch", requirements: { branch: /.+/ } do
authorize_push_project
 
result = DeleteBranchService.new(user_project, current_user).
execute(params[:branch])
result = DeleteBranchService.new(user_project, current_user)
.execute(params[:branch])
 
if result[:status] != :success
render_api_error!(result[:message], result[:return_code])
Loading
Loading
Loading
Loading
@@ -484,9 +484,9 @@ module API
expose :job_events
# Expose serialized properties
expose :properties do |service, options|
field_names = service.fields.
select { |field| options[:include_passwords] || field[:type] != 'password' }.
map { |field| field[:name] }
field_names = service.fields
.select { |field| options[:include_passwords] || field[:type] != 'password' }
.map { |field| field[:name] }
service.properties.slice(*field_names)
end
end
Loading
Loading
Loading
Loading
@@ -33,8 +33,8 @@ module API
# paginate() only works with a relation. This could lead to a
# mismatch between the pagination headers info and the actual notes
# array returned, but this is really a edge-case.
paginate(noteable.notes).
reject { |n| n.cross_reference_not_visible_for?(current_user) }
paginate(noteable.notes)
.reject { |n| n.cross_reference_not_visible_for?(current_user) }
present notes, with: Entities::Note
else
not_found!("Notes")
Loading
Loading
Loading
Loading
@@ -44,8 +44,8 @@ module API
post ':id/repository/tags' do
authorize_push_project
 
result = ::Tags::CreateService.new(user_project, current_user).
execute(params[:tag_name], params[:ref], params[:message], params[:release_description])
result = ::Tags::CreateService.new(user_project, current_user)
.execute(params[:tag_name], params[:ref], params[:message], params[:release_description])
 
if result[:status] == :success
present result[:tag],
Loading
Loading
@@ -63,8 +63,8 @@ module API
delete ":id/repository/tags/:tag_name", requirements: { tag_name: /.+/ } do
authorize_push_project
 
result = ::Tags::DestroyService.new(user_project, current_user).
execute(params[:tag_name])
result = ::Tags::DestroyService.new(user_project, current_user)
.execute(params[:tag_name])
 
if result[:status] != :success
render_api_error!(result[:message], result[:return_code])
Loading
Loading
@@ -81,8 +81,8 @@ module API
post ':id/repository/tags/:tag_name/release', requirements: { tag_name: /.+/ } do
authorize_push_project
 
result = CreateReleaseService.new(user_project, current_user).
execute(params[:tag_name], params[:description])
result = CreateReleaseService.new(user_project, current_user)
.execute(params[:tag_name], params[:description])
 
if result[:status] == :success
present result[:release], with: Entities::Release
Loading
Loading
@@ -101,8 +101,8 @@ module API
put ':id/repository/tags/:tag_name/release', requirements: { tag_name: /.+/ } do
authorize_push_project
 
result = UpdateReleaseService.new(user_project, current_user).
execute(params[:tag_name], params[:description])
result = UpdateReleaseService.new(user_project, current_user)
.execute(params[:tag_name], params[:description])
 
if result[:status] == :success
present result[:release], with: Entities::Release
Loading
Loading
Loading
Loading
@@ -103,13 +103,13 @@ module API
if user.persisted?
present user, with: Entities::UserPublic
else
conflict!('Email has already been taken') if User.
where(email: user.email).
count > 0
conflict!('Email has already been taken') if User
.where(email: user.email)
.count > 0
 
conflict!('Username has already been taken') if User.
where(username: user.username).
count > 0
conflict!('Username has already been taken') if User
.where(username: user.username)
.count > 0
 
render_validation_error!(user)
end
Loading
Loading
@@ -133,12 +133,12 @@ module API
not_found!('User') unless user
 
conflict!('Email has already been taken') if params[:email] &&
User.where(email: params[:email]).
where.not(id: user.id).count > 0
User.where(email: params[:email])
.where.not(id: user.id).count > 0
 
conflict!('Username has already been taken') if params[:username] &&
User.where(username: params[:username]).
where.not(id: user.id).count > 0
User.where(username: params[:username])
.where.not(id: user.id).count > 0
 
user_params = declared_params(include_missing: false)
identity_attrs = user_params.slice(:provider, :extern_uid)
Loading
Loading
@@ -517,9 +517,9 @@ module API
get "activities" do
authenticated_as_admin!
 
activities = User.
where(User.arel_table[:last_activity_on].gteq(params[:from])).
reorder(last_activity_on: :asc)
activities = User
.where(User.arel_table[:last_activity_on].gteq(params[:from]))
.reorder(last_activity_on: :asc)
 
present paginate(activities), with: Entities::UserActivity
end
Loading
Loading
Loading
Loading
@@ -26,8 +26,8 @@ module API
delete ":id/repository/branches/:branch", requirements: { branch: /.+/ } do
authorize_push_project
 
result = DeleteBranchService.new(user_project, current_user).
execute(params[:branch])
result = DeleteBranchService.new(user_project, current_user)
.execute(params[:branch])
 
if result[:status] == :success
status(200)
Loading
Loading
@@ -55,8 +55,8 @@ module API
end
post ":id/repository/branches" do
authorize_push_project
result = CreateBranchService.new(user_project, current_user).
execute(params[:branch_name], params[:ref])
result = CreateBranchService.new(user_project, current_user)
.execute(params[:branch_name], params[:ref])
 
if result[:status] == :success
present result[:branch],
Loading
Loading
Loading
Loading
@@ -245,9 +245,9 @@ module API
expose :job_events, as: :build_events
# Expose serialized properties
expose :properties do |service, options|
field_names = service.fields.
select { |field| options[:include_passwords] || field[:type] != 'password' }.
map { |field| field[:name] }
field_names = service.fields
.select { |field| options[:include_passwords] || field[:type] != 'password' }
.map { |field| field[:name] }
service.properties.slice(*field_names)
end
end
Loading
Loading
Loading
Loading
@@ -34,8 +34,8 @@ module API
# paginate() only works with a relation. This could lead to a
# mismatch between the pagination headers info and the actual notes
# array returned, but this is really a edge-case.
paginate(noteable.notes).
reject { |n| n.cross_reference_not_visible_for?(current_user) }
paginate(noteable.notes)
.reject { |n| n.cross_reference_not_visible_for?(current_user) }
present notes, with: ::API::V3::Entities::Note
else
not_found!("Notes")
Loading
Loading
Loading
Loading
@@ -22,8 +22,8 @@ module API
delete ":id/repository/tags/:tag_name", requirements: { tag_name: /.+/ } do
authorize_push_project
 
result = ::Tags::DestroyService.new(user_project, current_user).
execute(params[:tag_name])
result = ::Tags::DestroyService.new(user_project, current_user)
.execute(params[:tag_name])
 
if result[:status] == :success
status(200)
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