diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-02-22 16:50:15 -0600 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-02-23 09:33:05 -0600 |
commit | 1fe7501b49f896b74102c4b970310aa9ae34da85 (patch) | |
tree | ce271afb0fbaaa14291c1dc9009cd7815ee25463 /app | |
parent | bdbc7d967a0c3d95d5e4ea19a2a5be41268d3540 (diff) | |
download | gitlab-ce-1fe7501b49f896b74102c4b970310aa9ae34da85.tar.gz |
Revert "Prefer leading style for Style/DotPosition"
This reverts commit cb10b725c8929b8b4460f89c9d96c773af39ba6b.
Diffstat (limited to 'app')
117 files changed, 524 insertions, 524 deletions
diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb index b0f5d4a9933..f801fac1839 100644 --- a/app/controllers/admin/application_settings_controller.rb +++ b/app/controllers/admin/application_settings_controller.rb @@ -5,9 +5,9 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController end def update - successful = ApplicationSettings::UpdateService - .new(@application_setting, current_user, application_setting_params) - .execute + successful = ApplicationSettings::UpdateService. + new(@application_setting, current_user, application_setting_params). + execute if successful redirect_to admin_application_settings_path, diff --git a/app/controllers/concerns/creates_commit.rb b/app/controllers/concerns/creates_commit.rb index 41c660be378..2fe03020d2d 100644 --- a/app/controllers/concerns/creates_commit.rb +++ b/app/controllers/concerns/creates_commit.rb @@ -83,8 +83,8 @@ module CreatesCommit def merge_request_exists? return @merge_request if defined?(@merge_request) - @merge_request = MergeRequestsFinder.new(current_user, project_id: @mr_target_project.id).execute.opened - .find_by(source_branch: @mr_source_branch, target_branch: @mr_target_branch, source_project_id: @mr_source_project) + @merge_request = MergeRequestsFinder.new(current_user, project_id: @mr_target_project.id).execute.opened. + find_by(source_branch: @mr_source_branch, target_branch: @mr_target_branch, source_project_id: @mr_source_project) end def different_project? diff --git a/app/controllers/concerns/issues_action.rb b/app/controllers/concerns/issues_action.rb index b17c138d5c7..8b985b6d003 100644 --- a/app/controllers/concerns/issues_action.rb +++ b/app/controllers/concerns/issues_action.rb @@ -5,9 +5,9 @@ module IssuesAction def issues @label = issues_finder.labels.first - @issues = issues_collection - .non_archived - .page(params[:page]) + @issues = issues_collection. + non_archived. + page(params[:page]) @collection_type = "Issue" @issuable_meta_data = issuable_meta_data(@issues, @collection_type) diff --git a/app/controllers/concerns/membership_actions.rb b/app/controllers/concerns/membership_actions.rb index 43ca4b6ac02..c13333641d3 100644 --- a/app/controllers/concerns/membership_actions.rb +++ b/app/controllers/concerns/membership_actions.rb @@ -15,8 +15,8 @@ module MembershipActions end def leave - member = Members::DestroyService.new(membershipable, current_user, user_id: current_user.id) - .execute(:all) + member = Members::DestroyService.new(membershipable, current_user, user_id: current_user.id). + execute(:all) source_type = membershipable.class.to_s.humanize(capitalize: false) notice = diff --git a/app/controllers/concerns/merge_requests_action.rb b/app/controllers/concerns/merge_requests_action.rb index d3c8e4888bc..28e34cffc24 100644 --- a/app/controllers/concerns/merge_requests_action.rb +++ b/app/controllers/concerns/merge_requests_action.rb @@ -5,8 +5,8 @@ module MergeRequestsAction def merge_requests @label = merge_requests_finder.labels.first - @merge_requests = merge_requests_collection - .page(params[:page]) + @merge_requests = merge_requests_collection. + page(params[:page]) @collection_type = "MergeRequest" @issuable_meta_data = issuable_meta_data(@merge_requests, @collection_type) diff --git a/app/controllers/import/bitbucket_controller.rb b/app/controllers/import/bitbucket_controller.rb index 8e42cdf415f..cd5cef2c20f 100644 --- a/app/controllers/import/bitbucket_controller.rb +++ b/app/controllers/import/bitbucket_controller.rb @@ -29,9 +29,9 @@ class Import::BitbucketController < Import::BaseController end def jobs - render json: current_user.created_projects - .where(import_type: 'bitbucket') - .to_json(only: [:id, :import_status]) + render json: current_user.created_projects. + where(import_type: 'bitbucket'). + to_json(only: [:id, :import_status]) end def create diff --git a/app/controllers/jwt_controller.rb b/app/controllers/jwt_controller.rb index 1b40645f2c9..3109439b2ff 100644 --- a/app/controllers/jwt_controller.rb +++ b/app/controllers/jwt_controller.rb @@ -11,8 +11,8 @@ class JwtController < ApplicationController service = SERVICES[params[:service]] return head :not_found unless service - result = service.new(@authentication_result.project, @authentication_result.actor, auth_params) - .execute(authentication_abilities: @authentication_result.authentication_abilities) + result = service.new(@authentication_result.project, @authentication_result.actor, auth_params). + execute(authentication_abilities: @authentication_result.authentication_abilities) render json: result, status: result[:http_status] end diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb index 0faa446aff9..58d50ad647b 100644 --- a/app/controllers/omniauth_callbacks_controller.rb +++ b/app/controllers/omniauth_callbacks_controller.rb @@ -144,7 +144,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController end def log_audit_event(user, options = {}) - AuditEventService.new(user, user, options) - .for_authentication.security_event + AuditEventService.new(user, user, options). + for_authentication.security_event end end diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index cc500af81db..f0c71725ea8 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -41,9 +41,9 @@ class ProfilesController < Profiles::ApplicationController end def audit_log - @events = AuditEvent.where(entity_type: "User", entity_id: current_user.id) - .order("created_at DESC") - .page(params[:page]) + @events = AuditEvent.where(entity_type: "User", entity_id: current_user.id). + order("created_at DESC"). + page(params[:page]) end def update_username diff --git a/app/controllers/projects/badges_controller.rb b/app/controllers/projects/badges_controller.rb index 6c25cd83a24..c1727d9fa28 100644 --- a/app/controllers/projects/badges_controller.rb +++ b/app/controllers/projects/badges_controller.rb @@ -4,15 +4,15 @@ class Projects::BadgesController < Projects::ApplicationController before_action :no_cache_headers, except: [:index] def build - build_status = Gitlab::Badge::Build::Status - .new(project, params[:ref]) + build_status = Gitlab::Badge::Build::Status. + new(project, params[:ref]) render_badge build_status end def coverage - coverage_report = Gitlab::Badge::Coverage::Report - .new(project, params[:ref], params[:job]) + coverage_report = Gitlab::Badge::Coverage::Report. + new(project, params[:ref], params[:job]) render_badge coverage_report end diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb index 647faca40a0..39ba815cfca 100644 --- a/app/controllers/projects/blob_controller.rb +++ b/app/controllers/projects/blob_controller.rb @@ -164,7 +164,7 @@ class Projects::BlobController < Projects::ApplicationController end def set_last_commit_sha - @last_commit_sha = Gitlab::Git::Commit - .last_for_path(@repository, @ref, @path).sha + @last_commit_sha = Gitlab::Git::Commit. + last_for_path(@repository, @ref, @path).sha end end diff --git a/app/controllers/projects/boards/issues_controller.rb b/app/controllers/projects/boards/issues_controller.rb index 61fef4dc133..8bcf18642cf 100644 --- a/app/controllers/projects/boards/issues_controller.rb +++ b/app/controllers/projects/boards/issues_controller.rb @@ -40,10 +40,10 @@ module Projects def issue @issue ||= - IssuesFinder.new(current_user, project_id: project.id) - .execute - .where(iid: params[:id]) - .first! + IssuesFinder.new(current_user, project_id: project.id). + execute. + where(iid: params[:id]). + first! end def authorize_read_issue! diff --git a/app/controllers/projects/branches_controller.rb b/app/controllers/projects/branches_controller.rb index c37a0653ff9..89d84809e3a 100644 --- a/app/controllers/projects/branches_controller.rb +++ b/app/controllers/projects/branches_controller.rb @@ -32,8 +32,8 @@ class Projects::BranchesController < Projects::ApplicationController branch_name = sanitize(strip_tags(params[:branch_name])) branch_name = Addressable::URI.unescape(branch_name) - result = CreateBranchService.new(project, current_user) - .execute(branch_name, ref) + result = CreateBranchService.new(project, current_user). + execute(branch_name, ref) if params[:issue_iid] issue = IssuesFinder.new(current_user, project_id: @project.id).find_by(iid: params[:issue_iid]) diff --git a/app/controllers/projects/builds_controller.rb b/app/controllers/projects/builds_controller.rb index 0db18d444f7..886934a3f67 100644 --- a/app/controllers/projects/builds_controller.rb +++ b/app/controllers/projects/builds_controller.rb @@ -48,8 +48,8 @@ class Projects::BuildsController < Projects::ApplicationController respond_to do |format| format.json do state = params[:state].presence - render json: @build.trace_with_state(state: state) - .merge!(id: @build.id, status: @build.status) + render json: @build.trace_with_state(state: state). + merge!(id: @build.id, status: @build.status) end end end diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb index e10d7992db7..23466dda981 100644 --- a/app/controllers/projects/commit_controller.rb +++ b/app/controllers/projects/commit_controller.rb @@ -35,9 +35,9 @@ class Projects::CommitController < Projects::ApplicationController respond_to do |format| format.html format.json do - render json: PipelineSerializer - .new(project: @project, user: @current_user) - .represent(@pipelines) + render json: PipelineSerializer. + new(project: @project, user: @current_user). + represent(@pipelines) end end end diff --git a/app/controllers/projects/commits_controller.rb b/app/controllers/projects/commits_controller.rb index 855147c8984..ad92f05a42d 100644 --- a/app/controllers/projects/commits_controller.rb +++ b/app/controllers/projects/commits_controller.rb @@ -18,11 +18,11 @@ class Projects::CommitsController < Projects::ApplicationController @repository.commits(@ref, path: @path, limit: @limit, offset: @offset) end - @note_counts = project.notes.where(commit_id: @commits.map(&:id)) - .group(:commit_id).count + @note_counts = project.notes.where(commit_id: @commits.map(&:id)). + group(:commit_id).count - @merge_request = MergeRequestsFinder.new(current_user, project_id: @project.id).execute.opened - .find_by(source_project: @project, source_branch: @ref, target_branch: @repository.root_ref) + @merge_request = MergeRequestsFinder.new(current_user, project_id: @project.id).execute.opened. + find_by(source_project: @project, source_branch: @ref, target_branch: @repository.root_ref) respond_to do |format| format.html diff --git a/app/controllers/projects/compare_controller.rb b/app/controllers/projects/compare_controller.rb index 7ef2f90ef01..99204c82784 100644 --- a/app/controllers/projects/compare_controller.rb +++ b/app/controllers/projects/compare_controller.rb @@ -46,8 +46,8 @@ class Projects::CompareController < Projects::ApplicationController end def define_diff_vars - @compare = CompareService.new(@project, @head_ref) - .execute(@project, @start_ref) + @compare = CompareService.new(@project, @head_ref). + execute(@project, @start_ref) if @compare @commits = @compare.commits @@ -66,7 +66,7 @@ class Projects::CompareController < Projects::ApplicationController end def merge_request - @merge_request ||= MergeRequestsFinder.new(current_user, project_id: @project.id).execute.opened - .find_by(source_project: @project, source_branch: @head_ref, target_branch: @start_ref) + @merge_request ||= MergeRequestsFinder.new(current_user, project_id: @project.id).execute.opened. + find_by(source_project: @project, source_branch: @head_ref, target_branch: @start_ref) end end diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb index fed75396d6e..2bbd8c6d046 100644 --- a/app/controllers/projects/environments_controller.rb +++ b/app/controllers/projects/environments_controller.rb @@ -9,18 +9,18 @@ class Projects::EnvironmentsController < Projects::ApplicationController before_action :verify_api_request!, only: :terminal_websocket_authorize def index - @environments = project.environments - .with_state(params[:scope] || :available) + @environments = project.environments. + with_state(params[:scope] || :available) respond_to do |format| format.html format.json do render json: { - environments: EnvironmentSerializer - .new(project: @project, user: @current_user) - .with_pagination(request, response) - .within_folders - .represent(@environments), + environments: EnvironmentSerializer. + new(project: @project, user: @current_user). + with_pagination(request, response). + within_folders. + represent(@environments), available_count: project.environments.available.count, stopped_count: project.environments.stopped.count } @@ -36,10 +36,10 @@ class Projects::EnvironmentsController < Projects::ApplicationController format.html format.json do render json: { - environments: EnvironmentSerializer - .new(project: @project, user: @current_user) - .with_pagination(request, response) - .represent(@environments), + environments: EnvironmentSerializer. + new(project: @project, user: @current_user). + with_pagination(request, response). + represent(@environments), available_count: folder_environments.available.count, stopped_count: folder_environments.stopped.count } diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index 4c009dd238c..ca5e81100da 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -77,8 +77,8 @@ class Projects::IssuesController < Projects::ApplicationController def show raw_notes = @issue.notes.inc_relations_for_view.fresh - @notes = Banzai::NoteRenderer - .render(raw_notes, @project, current_user, @path, @project_wiki, @ref) + @notes = Banzai::NoteRenderer. + render(raw_notes, @project, current_user, @path, @project_wiki, @ref) @note = @project.notes.new(noteable: @issue) @noteable = @issue @@ -189,9 +189,9 @@ class Projects::IssuesController < Projects::ApplicationController def merge_request_for_resolving_discussions return unless merge_request_iid = params[:merge_request_for_resolving_discussions] - @merge_request_for_resolving_discussions ||= MergeRequestsFinder.new(current_user, project_id: project.id) - .execute - .find_by(iid: merge_request_iid) + @merge_request_for_resolving_discussions ||= MergeRequestsFinder.new(current_user, project_id: project.id). + execute. + find_by(iid: merge_request_iid) end def authorize_read_issue! diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index 1f228d28f80..5ee7972e29e 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -162,8 +162,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController # Get commits from repository # or from cache if already merged @commits = @merge_request.commits - @note_counts = Note.where(commit_id: @commits.map(&:id)) - .group(:commit_id).count + @note_counts = Note.where(commit_id: @commits.map(&:id)). + group(:commit_id).count render json: { html: view_to_html_string('projects/merge_requests/show/_commits') } end @@ -232,9 +232,9 @@ class Projects::MergeRequestsController < Projects::ApplicationController end format.json do - render json: PipelineSerializer - .new(project: @project, user: @current_user) - .represent(@pipelines) + render json: PipelineSerializer. + new(project: @project, user: @current_user). + represent(@pipelines) end end end @@ -245,9 +245,9 @@ class Projects::MergeRequestsController < Projects::ApplicationController format.json do define_pipelines_vars - render json: PipelineSerializer - .new(project: @project, user: @current_user) - .represent(@pipelines) + render json: PipelineSerializer. + new(project: @project, user: @current_user). + represent(@pipelines) end end end @@ -332,9 +332,9 @@ class Projects::MergeRequestsController < Projects::ApplicationController return access_denied! end - MergeRequests::MergeWhenPipelineSucceedsService - .new(@project, current_user) - .cancel(@merge_request) + MergeRequests::MergeWhenPipelineSucceedsService. + new(@project, current_user). + cancel(@merge_request) end def merge @@ -361,9 +361,9 @@ class Projects::MergeRequestsController < Projects::ApplicationController end if @merge_request.head_pipeline.active? - MergeRequests::MergeWhenPipelineSucceedsService - .new(@project, current_user, merge_params) - .execute(@merge_request) + MergeRequests::MergeWhenPipelineSucceedsService. + new(@project, current_user, merge_params). + execute(@merge_request) @status = :merge_when_build_succeeds elsif @merge_request.head_pipeline.success? @@ -624,8 +624,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController @commit = @merge_request.diff_head_commit @base_commit = @merge_request.diff_base_commit - @note_counts = Note.where(commit_id: @commits.map(&:id)) - .group(:commit_id).count + @note_counts = Note.where(commit_id: @commits.map(&:id)). + group(:commit_id).count @labels = LabelsFinder.new(current_user, project_id: @project.id).execute @@ -640,8 +640,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController end def merge_request_params - params.require(:merge_request) - .permit(merge_request_params_ce) + params.require(:merge_request). + permit(merge_request_params_ce) end def merge_request_params_ce diff --git a/app/controllers/projects/pipelines_controller.rb b/app/controllers/projects/pipelines_controller.rb index e436c6666c3..0f2b7b2a4c8 100644 --- a/app/controllers/projects/pipelines_controller.rb +++ b/app/controllers/projects/pipelines_controller.rb @@ -7,11 +7,11 @@ class Projects::PipelinesController < Projects::ApplicationController def index @scope = params[:scope] - @pipelines = PipelinesFinder - .new(project) - .execute(scope: @scope) - .page(params[:page]) - .per(30) + @pipelines = PipelinesFinder. + new(project). + execute(scope: @scope). + page(params[:page]). + per(30) @running_count = PipelinesFinder. .new(project).execute(scope: 'running').count @@ -29,10 +29,10 @@ class Projects::PipelinesController < Projects::ApplicationController format.html format.json do render json: { - pipelines: PipelineSerializer - .new(project: @project, user: @current_user) - .with_pagination(request, response) - .represent(@pipelines), + pipelines: PipelineSerializer. + new(project: @project, user: @current_user). + with_pagination(request, response). + represent(@pipelines), count: { all: @pipelines_count, running: @running_count, @@ -49,9 +49,9 @@ class Projects::PipelinesController < Projects::ApplicationController end def create - @pipeline = Ci::CreatePipelineService - .new(project, current_user, create_params) - .execute(ignore_skip_ci: true, save_on_errors: false) + @pipeline = Ci::CreatePipelineService. + new(project, current_user, create_params). + execute(ignore_skip_ci: true, save_on_errors: false) unless @pipeline.persisted? render 'new' return diff --git a/app/controllers/projects/project_members_controller.rb b/app/controllers/projects/project_members_controller.rb index 3c582d15a4c..6e158e685e9 100644 --- a/app/controllers/projects/project_members_controller.rb +++ b/app/controllers/projects/project_members_controller.rb @@ -31,8 +31,8 @@ class Projects::ProjectMembersController < Projects::ApplicationController end def destroy - Members::DestroyService.new(@project, current_user, params) - .execute(:all) + Members::DestroyService.new(@project, current_user, params). + execute(:all) respond_to do |format| format.html do diff --git a/app/controllers/projects/settings/ci_cd_controller.rb b/app/controllers/projects/settings/ci_cd_controller.rb index 24fe78bc1bd..6f009d61950 100644 --- a/app/controllers/projects/settings/ci_cd_controller.rb +++ b/app/controllers/projects/settings/ci_cd_controller.rb @@ -14,8 +14,8 @@ module Projects def define_runners_variables @project_runners = @project.runners.ordered - @assignable_runners = current_user.ci_authorized_runners - .assignable_for(project).ordered.page(params[:page]).per(20) + @assignable_runners = current_user.ci_authorized_runners. + assignable_for(project).ordered.page(params[:page]).per(20) @shared_runners = Ci::Runner.shared.active @shared_runners_count = @shared_runners.count(:all) end diff --git a/app/controllers/projects/settings/members_controller.rb b/app/controllers/projects/settings/members_controller.rb index f4c79b796fd..5735e281f66 100644 --- a/app/controllers/projects/settings/members_controller.rb +++ b/app/controllers/projects/settings/members_controller.rb @@ -41,10 +41,10 @@ module Projects wheres = ["members.id IN (#{@project_members.select(:id).to_sql})"] wheres << "members.id IN (#{group_members.select(:id).to_sql})" if group_members - @project_members = Member - .where(wheres.join(' OR ')) - .sort(@sort) - .page(params[:page]) + @project_members = Member. + where(wheres.join(' OR ')). + sort(@sort). + page(params[:page]) @requesters = AccessRequestsFinder.new(@project).execute(current_user) diff --git a/app/controllers/projects/tags_controller.rb b/app/controllers/projects/tags_controller.rb index 5aaec97a082..33379659d73 100644 --- a/app/controllers/projects/tags_controller.rb +++ b/app/controllers/projects/tags_controller.rb @@ -27,8 +27,8 @@ class Projects::TagsController < Projects::ApplicationController end def create - result = Tags::CreateService.new(@project, current_user) - .execute(params[:tag_name], params[:ref], params[:message], params[:release_description]) + result = Tags::CreateService.new(@project, current_user). + execute(params[:tag_name], params[:ref], params[:message], params[:release_description]) if result[:status] == :success @tag = result[:tag] diff --git a/app/controllers/projects/uploads_controller.rb b/app/controllers/projects/uploads_controller.rb index 1e7d72f5faa..61686499bd3 100644 --- a/app/controllers/projects/uploads_controller.rb +++ b/app/controllers/projects/uploads_controller.rb @@ -5,8 +5,8 @@ class Projects::UploadsController < Projects::ApplicationController before_action :authorize_upload_file!, only: [:create] def create - link_to_file = ::Projects::UploadService.new(project, params[:file]) - .execute + link_to_file = ::Projects::UploadService.new(project, params[:file]). + execute respond_to do |format| if link_to_file diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index acca821782c..9ffb8152e32 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -293,8 +293,8 @@ class ProjectsController < Projects::ApplicationController end def project_params - params.require(:project) - .permit(project_params_ce) + params.require(:project). + permit(project_params_ce) end def project_params_ce diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index b632bbaaf78..7d81c96262f 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -119,8 +119,8 @@ class SessionsController < Devise::SessionsController end def log_audit_event(user, options = {}) - AuditEventService.new(user, user, options) - .for_authentication.security_event + AuditEventService.new(user, user, options). + for_authentication.security_event end def load_recaptcha diff --git a/app/controllers/sherlock/application_controller.rb b/app/controllers/sherlock/application_controller.rb index 6bdd3568a78..682ca5e3821 100644 --- a/app/controllers/sherlock/application_controller.rb +++ b/app/controllers/sherlock/application_controller.rb @@ -4,8 +4,8 @@ module Sherlock def find_transaction if params[:transaction_id] - @transaction = Gitlab::Sherlock.collection - .find_transaction(params[:transaction_id]) + @transaction = Gitlab::Sherlock.collection. + find_transaction(params[:transaction_id]) end end end diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb index 2e0f26ade91..f3fd3da8b20 100644 --- a/app/controllers/snippets_controller.rb +++ b/app/controllers/snippets_controller.rb @@ -83,8 +83,8 @@ class SnippetsController < ApplicationController @snippet ||= if current_user PersonalSnippet.where("author_id = ? OR visibility_level IN (?)", current_user.id, - [Snippet::PUBLIC, Snippet::INTERNAL]) - .find(params[:id]) + [Snippet::PUBLIC, Snippet::INTERNAL]). + find(params[:id]) else PersonalSnippet.find(params[:id]) end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 73056df5bef..c92594d4097 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -109,17 +109,17 @@ class UsersController < ApplicationController def load_events # Get user activity feed for projects common for both users - @events = user.recent_events - .merge(projects_for_current_user) - .references(:project) - .with_associations - .limit_recent(20, params[:offset]) + @events = user.recent_events. + merge(projects_for_current_user). + references(:project). + with_associations. + limit_recent(20, params[:offset]) end def load_projects @projects = - PersonalProjectsFinder.new(user).execute(current_user) - .page(params[:page]) + PersonalProjectsFinder.new(user).execute(current_user). + page(params[:page]) end def load_contributed_projects diff --git a/app/finders/environments_finder.rb b/app/finders/environments_finder.rb index a59f8c1efa3..52c73abc31d 100644 --- a/app/finders/environments_finder.rb +++ b/app/finders/environments_finder.rb @@ -17,12 +17,12 @@ class EnvironmentsFinder deployments.none end - environment_ids = deployments - .group(:environment_id) - .select(:environment_id) + environment_ids = deployments. + group(:environment_id). + select(:environment_id) - environments = project.environments.available - .where(id: environment_ids).order_by_last_deployed_at.to_a + environments = project.environments.available. + where(id: environment_ids).order_by_last_deployed_at.to_a environments.select! do |environment| Ability.allowed?(current_user, :read_environment, environment) diff --git a/app/finders/group_members_finder.rb b/app/finders/group_members_finder.rb index 873a253e2b5..9f2206346ce 100644 --- a/app/finders/group_members_finder.rb +++ b/app/finders/group_members_finder.rb @@ -8,9 +8,9 @@ class GroupMembersFinder < Projects::ApplicationController return group_members unless @group.parent - parents_members = GroupMember.non_request - .where(source_id: @group.ancestors.select(:id)) - .where.not(user_id: @group.users.select(:id)) + parents_members = GroupMember.non_request. + where(source_id: @group.ancestors.select(:id)). + where.not(user_id: @group.users.select(:id)) wheres = ["members.id IN (#{group_members.select(:id).to_sql})"] wheres << "members.id IN (#{parents_members.select(:id).to_sql})" diff --git a/app/helpers/form_helper.rb b/app/helpers/form_helper.rb index 913db3a3e26..1182939f656 100644 --- a/app/helpers/form_helper.rb +++ b/app/helpers/form_helper.rb @@ -8,10 +8,10 @@ module FormHelper content_tag(:div, class: 'alert alert-danger', id: 'error_explanation') do content_tag(:h4, headline) << content_tag(:ul) do - model.errors.full_messages - .map { |msg| content_tag(:li, msg) } - .join - .html_safe + model.errors.full_messages. + map { |msg| content_tag(:li, msg) }. + join. + html_safe end end end diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index 7a164cfd26d..8ff8db16514 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -97,8 +97,8 @@ module SearchHelper # Autocomplete results for the current user's projects def projects_autocomplete(term, limit = 5) - current_user.authorized_projects.search_by_title(term) - .sorted_by_stars.non_archived.limit(limit).map do |p| + current_user.authorized_projects.search_by_title(term). + sorted_by_stars.non_archived.limit(limit).map do |p| { category: "Projects", id: p.id, diff --git a/app/helpers/wiki_helper.rb b/app/helpers/wiki_helper.rb index 99212a3438f..3e3f6246fc5 100644 --- a/app/helpers/wiki_helper.rb +++ b/app/helpers/wiki_helper.rb @@ -6,8 +6,8 @@ module WikiHelper # Returns a String composed of the capitalized name of each directory and the # capitalized name of the page itself. def breadcrumb(page_slug) - page_slug.split('/') - .map { |dir_or_page| WikiPage.unhyphenize(dir_or_page).capitalize } - .join(' / ') + page_slug.split('/'). + map { |dir_or_page| WikiPage.unhyphenize(dir_or_page).capitalize }. + join(' / ') end end diff --git a/app/models/award_emoji.rb b/app/models/award_emoji.rb index 2eedbf3ffde..6937ad3bdd9 100644 --- a/app/models/award_emoji.rb +++ b/app/models/award_emoji.rb @@ -18,9 +18,9 @@ class AwardEmoji < ActiveRecord::Base class << self def votes_for_collection(ids, type) - select('name', 'awardable_id', 'COUNT(*) as count') - .where('name IN (?) AND awardable_type = ? AND awardable_id IN (?)', [DOWNVOTE_NAME, UPVOTE_NAME], type, ids) - .group('name', 'awardable_id') + select('name', 'awardable_id', 'COUNT(*) as count'). + where('name IN (?) AND awardable_type = ? AND awardable_id IN (?)', [DOWNVOTE_NAME, UPVOTE_NAME], type, ids). + group('name', 'awardable_id') end end diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 3a17d5c8dbe..2689078c771 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -65,9 +65,9 @@ module Ci end def retry(build, current_user) - Ci::RetryBuildService - .new(build.project, current_user) - .execute(build) + Ci::RetryBuildService. + new(build.project, current_user). + execute(build) end end @@ -98,9 +98,9 @@ module Ci end def detailed_status(current_user) - Gitlab::Ci::Status::Build::Factory - .new(self, current_user) - .fabricate! + Gitlab::Ci::Status::Build::Factory. + new(self, current_user). + fabricate! end def manual? @@ -222,9 +222,9 @@ module Ci end def merge_request - merge_requests = MergeRequest.includes(:merge_request_diff) - .where(source_branch: ref, source_project_id: pipeline.gl_project_id) - .reorder(iid: :asc) + merge_requests = MergeRequest.includes(:merge_request_diff). + where(source_branch: ref, source_project_id: pipeline.gl_project_id). + reorder(iid: :asc) merge_requests.find do |merge_request| merge_request.commits_sha.include?(pipeline.sha) @@ -276,8 +276,8 @@ module Ci def raw_trace(last_lines: nil) if File.exist?(trace_file_path) - Gitlab::Ci::TraceReader.new(trace_file_path) - .read(last_lines: last_lines) + Gitlab::Ci::TraceReader.new(trace_file_path). + read(last_lines: last_lines) else # backward compatibility read_attribute :trace diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 632178de887..04d43ca3c5c 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -91,9 +91,9 @@ module Ci # ref can't be HEAD or SHA, can only be branch/tag name scope :latest, ->(ref = nil) do - max_id = unscope(:select) - .select("max(#{quoted_table_name}.id)") - .group(:ref, :sha) + max_id = unscope(:select). + select("max(#{quoted_table_name}.id)"). + group(:ref, :sha) if ref where(ref: ref, id: max_id.where(ref: ref)) @@ -128,23 +128,23 @@ module Ci end def stages_name - statuses.order(:stage_idx).distinct - .pluck(:stage, :stage_idx).map(&:first) + statuses.order(:stage_idx).distinct. + pluck(:stage, :stage_idx).map(&:first) end def stages # TODO, this needs refactoring, see gitlab-ce#26481. - stages_query = statuses - .group('stage').select(:stage).order('max(stage_idx)') + stages_query = statuses. + group('stage').select(:stage).order('max(stage_idx)') status_sql = statuses.latest.where('stage=sg.stage').status_sql - warnings_sql = statuses.latest.select('COUNT(*) > 0') - .where('stage=sg.stage').failed_but_allowed.to_sql + warnings_sql = statuses.latest.select('COUNT(*) > 0'). + where('stage=sg.stage').failed_but_allowed.to_sql - stages_with_statuses = CommitStatus.from(stages_query, :sg) - .pluck('sg.stage', status_sql, "(#{warnings_sql})") + stages_with_statuses = CommitStatus.from(stages_query, :sg). + pluck('sg.stage', status_sql, "(#{warnings_sql})") stages_with_statuses.map do |stage| Ci::Stage.new(self, Hash[%i[name status warnings].zip(stage)]) @@ -220,8 +220,8 @@ module Ci end def retry_failed(current_user) - Ci::RetryPipelineService.new(project, current_user) - .execute(self) + Ci::RetryPipelineService.new(project, current_user). + execute(self) end def mark_as_processable_after_stage(stage_idx) @@ -253,9 +253,9 @@ module Ci def config_builds_attributes return [] unless config_processor - config_processor - .builds_for_ref(ref, tag?, trigger_requests.first) - .sort_by { |build| build[:stage_idx] } + config_processor. + builds_for_ref(ref, tag?, trigger_requests.first). + sort_by { |build| build[:stage_idx] } end def has_warnings? @@ -353,15 +353,15 @@ module Ci # Merge requests for which the current pipeline is running against # the merge request's latest commit. def merge_requests - @merge_requests ||= project.merge_requests - .where(source_branch: self.ref) - .select { |merge_request| merge_request.head_pipeline.try(:id) == self.id } + @merge_requests ||= project.merge_requests. + where(source_branch: self.ref). + select { |merge_request| merge_request.head_pipeline.try(:id) == self.id } end def detailed_status(current_user) - Gitlab::Ci::Status::Pipeline::Factory - .new(self, current_user) - .fabricate! + Gitlab::Ci::Status::Pipeline::Factory. + new(self, current_user). + fabricate! end private diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb index 9cf6164e8dd..a120112e882 100644 --- a/app/models/ci/runner.rb +++ b/app/models/ci/runner.rb @@ -23,15 +23,15 @@ module Ci scope :ordered, ->() { order(id: :desc) } scope :owned_or_shared, ->(project_id) do - joins('LEFT JOIN ci_runner_projects ON ci_runner_projects.runner_id = ci_runners.id') - .where("ci_runner_projects.gl_project_id = :project_id OR ci_runners.is_shared = true", project_id: project_id) + joins('LEFT JOIN ci_runner_projects ON ci_runner_projects.runner_id = ci_runners.id'). + where("ci_runner_projects.gl_project_id = :project_id OR ci_runners.is_shared = true", project_id: project_id) end scope :assignable_for, ->(project) do # FIXME: That `to_sql` is needed to workaround a weird Rails bug. # Without that, placeholders would miss one and couldn't match. - where(locked: false) - .where.not("id IN (#{project.runners.select(:id).to_sql})").specific + where(locked: false). + where.not("id IN (#{project.runners.select(:id).to_sql})").specific end validate :tag_constraints diff --git a/app/models/ci/stage.rb b/app/models/ci/stage.rb index ca74c91b062..0751ab1b7d8 100644 --- a/app/models/ci/stage.rb +++ b/app/models/ci/stage.rb @@ -28,9 +28,9 @@ module Ci end def detailed_status(current_user) - Gitlab::Ci::Status::Stage::Factory - .new(self, current_user) - .fabricate! + Gitlab::Ci::Status::Stage::Factory. + new(self, current_user). + fabricate! end def statuses diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb index fc750a3e5e9..1349beafb76 100644 --- a/app/models/commit_status.rb +++ b/app/models/commit_status.rb @@ -97,8 +97,8 @@ class CommitStatus < ActiveRecord::Base after_transition any => :failed do |commit_status| commit_status.run_after_commit do - MergeRequests::AddTodoWhenBuildFailsService - .new(pipeline.project, nil).execute(self) + MergeRequests::AddTodoWhenBuildFailsService. + new(pipeline.project, nil).execute(self) end end end @@ -132,9 +132,9 @@ class CommitStatus < ActiveRecord::Base end def detailed_status(current_user) - Gitlab::Ci::Status::Factory - .new(self, current_user) - .fabricate! + Gitlab::Ci::Status::Factory. + new(self, current_user). + fabricate! end def sortable_name diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb index fcb335e48d1..37c727b5d9f 100644 --- a/app/models/concerns/issuable.rb +++ b/app/models/concerns/issuable.rb @@ -162,9 +162,9 @@ module Issuable highest_priority = highest_label_priority(params).to_sql - select("#{table_name}.*, (#{highest_priority}) AS highest_priority") - .group(arel_table[:id]) - .reorder(Gitlab::Database.nulls_last_order('highest_priority', 'ASC')) + select("#{table_name}.*, (#{highest_priority}) AS highest_priority"). + group(arel_table[:id]). + reorder(Gitlab::Database.nulls_last_order('highest_priority', 'ASC')) end def with_label(title, sort = nil) diff --git a/app/models/concerns/mentionable.rb b/app/models/concerns/mentionable.rb index a8ce36e51fc..7e56e371b27 100644 --- a/app/models/concerns/mentionable.rb +++ b/app/models/concerns/mentionable.rb @@ -48,8 +48,8 @@ module Mentionable if extractor @extractor = extractor else - @extractor ||= Gitlab::ReferenceExtractor - .new(project, current_user) + @extractor ||= Gitlab::ReferenceExtractor. + new(project, current_user) @extractor.reset_memoized_values end diff --git a/app/models/concerns/milestoneish.rb b/app/models/concerns/milestoneish.rb index f449229864d..870a6fbaa90 100644 --- a/app/models/concerns/milestoneish.rb +++ b/app/models/concerns/milestoneish.rb @@ -39,8 +39,8 @@ module Milestoneish def issues_visible_to_user(user) memoize_per_user(user, :issues_visible_to_user) do - IssuesFinder.new(user, issues_finder_params) - .execute.where(milestone_id: milestoneish_ids) + IssuesFinder.new(user, issues_finder_params). + execute.where(milestone_id: milestoneish_ids) end end diff --git a/app/models/concerns/presentable.rb b/app/models/concerns/presentable.rb index 7b33b837004..d0f84831d71 100644 --- a/app/models/concerns/presentable.rb +++ b/app/models/concerns/presentable.rb @@ -1,7 +1,7 @@ module Presentable def present(**attributes) - Gitlab::View::Presenter::Factory - .new(self, attributes) - .fabricate! + Gitlab::View::Presenter::Factory. + new(self, attributes). + fabricate! end end diff --git a/app/models/concerns/routable.rb b/app/models/concerns/routable.rb index c2373de32c5..9f6d215ceb3 100644 --- a/app/models/concerns/routable.rb +++ b/app/models/concerns/routable.rb @@ -75,11 +75,11 @@ module Routable # # Returns an ActiveRecord::Relation. def member_descendants(user_id) - joins(:route) - .joins("INNER JOIN routes r2 ON routes.path LIKE CONCAT(r2.path, '/%') + joins(:route). + joins("INNER JOIN routes r2 ON routes.path LIKE CONCAT(r2.path, '/%') INNER JOIN members ON members.source_id = r2.source_id - AND members.source_type = r2.source_type") - .where('members.user_id = ?', user_id) + AND members.source_type = r2.source_type"). + where('members.user_id = ?', user_id) end end diff --git a/app/models/concerns/sortable.rb b/app/models/concerns/sortable.rb index a155a064032..b9a2d812edd 100644 --- a/app/models/concerns/sortable.rb +++ b/app/models/concerns/sortable.rb @@ -39,12 +39,12 @@ module Sortable private def highest_label_priority(target_type_column: nil, target_type: nil, target_column:, project_column:, excluded_labels: []) - query = Label.select(LabelPriority.arel_table[:priority].minimum) - .left_join_priorities - .joins(:label_links) - .where("label_priorities.project_id = #{project_column}") - .where("label_links.target_id = #{target_column}") - .reorder(nil) + query = Label.select(LabelPriority.arel_table[:priority].minimum). + left_join_priorities. + joins(:label_links). + where("label_priorities.project_id = #{project_column}"). + where("label_links.target_id = #{target_column}"). + reorder(nil) query = if target_type_column diff --git a/app/models/concerns/subscribable.rb b/app/models/concerns/subscribable.rb index f60a0f8f438..e4f5818d0e3 100644 --- a/app/models/concerns/subscribable.rb +++ b/app/models/concerns/subscribable.rb @@ -27,30 +27,30 @@ module Subscribable end def subscribers(project) - subscriptions_available(project) - .where(subscribed: true) - .map(&:user) + subscriptions_available(project). + where(subscribed: true). + map(&:user) end def toggle_subscription(user, project = nil) unsubscribe_from_other_levels(user, project) - find_or_initialize_subscription(user, project) - .update(subscribed: !subscribed?(user, project)) + find_or_initialize_subscription(user, project). + update(subscribed: !subscribed?(user, project)) end def subscribe(user, project = nil) unsubscribe_from_other_levels(user, project) - find_or_initialize_subscription(user, project) - .update(subscribed: true) + find_or_initialize_subscription(user, project). + update(subscribed: true) end def unsubscribe(user, project = nil) unsubscribe_from_other_levels(user, project) - find_or_initialize_subscription(user, project) - .update(subscribed: false) + find_or_initialize_subscription(user, project). + update(subscribed: false) end private @@ -69,14 +69,14 @@ module Subscribable end def find_or_initialize_subscription(user, project) - subscriptions - .find_or_initialize_by(user_id: user.id, project_id: project.try(:id)) + subscriptions. + find_or_initialize_by(user_id: user.id, project_id: project.try(:id)) end def subscriptions_available(project) t = Subscription.arel_table - subscriptions - .where(t[:project_id].eq(nil).or(t[:project_id].eq(project.try(:id)))) + subscriptions. + where(t[:project_id].eq(nil).or(t[:project_id].eq(project.try(:id)))) end end diff --git a/app/models/deployment.rb b/app/models/deployment.rb index 43f7460bd5d..afad001d50f 100644 --- a/app/models/deployment.rb +++ b/app/models/deployment.rb @@ -53,10 +53,10 @@ class Deployment < ActiveRecord::Base def update_merge_request_metrics! return unless environment.update_merge_request_metrics? - merge_requests = project.merge_requests - .joins(:metrics) - .where(target_branch: self.ref, merge_request_metrics: { first_deployed_to_production_at: nil }) - .where("merge_request_metrics.merged_at <= ?", self.created_at) + merge_requests = project.merge_requests. + joins(:metrics). + where(target_branch: self.ref, merge_request_metrics: { first_deployed_to_production_at: nil }). + where("merge_request_metrics.merged_at <= ?", self.created_at) if previous_deployment merge_requests = merge_requests.where("merge_request_metrics.merged_at >= ?", previous_deployment.created_at) @@ -71,17 +71,17 @@ class Deployment < ActiveRecord::Base merge_requests.map(&:id) end - MergeRequest::Metrics - .where(merge_request_id: merge_request_ids, first_deployed_to_production_at: nil) - .update_all(first_deployed_to_production_at: self.created_at) + MergeRequest::Metrics. + where(merge_request_id: merge_request_ids, first_deployed_to_production_at: nil). + update_all(first_deployed_to_production_at: self.created_at) end def previous_deployment @previous_deployment ||= - project.deployments.joins(:environment) - .where(environments: { name: self.environment.name }, ref: self.ref) - .where.not(id: self.id) - .take + project.deployments.joins(:environment). + where(environments: { name: self.environment.name }, ref: self.ref). + where.not(id: self.id). + take end def stop_action diff --git a/app/models/environment.rb b/app/models/environment.rb index f917f52f832..1a21b5e52b5 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -40,9 +40,9 @@ class Environment < ActiveRecord::Base scope :stopped, -> { with_state(:stopped) } scope :order_by_last_deployed_at, -> do max_deployment_id_sql = - Deployment.select(Deployment.arel_table[:id].maximum) - .where(Deployment.arel_table[:environment_id].eq(arel_table[:id])) - .to_sql + Deployment.select(Deployment.arel_table[:id].maximum). + where(Deployment.arel_table[:environment_id].eq(arel_table[:id])). + to_sql order(Gitlab::Database.nulls_first_order("(#{max_deployment_id_sql})", 'ASC')) end diff --git a/app/models/event.rb b/app/models/event.rb index b8918fcda21..4b8eac9accf 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -343,9 +343,9 @@ class Event < ActiveRecord::Base # At this point it's possible for multiple threads/processes to try to # update the project. Only one query should actually perform the update, # hence we add the extra WHERE clause for last_activity_at. - Project.unscoped.where(id: project_id) - .where('last_activity_at <= ?', RESET_PROJECT_ACTIVITY_INTERVAL.ago) - .update_all(last_activity_at: created_at) + Project.unscoped.where(id: project_id). + where('last_activity_at <= ?', RESET_PROJECT_ACTIVITY_INTERVAL.ago). + update_all(last_activity_at: created_at) end def authored_by?(user) diff --git a/app/models/generic_commit_status.rb b/app/models/generic_commit_status.rb index 8867ba0d2ff..36b8568871b 100644 --- a/app/models/generic_commit_status.rb +++ b/app/models/generic_commit_status.rb @@ -18,8 +18,8 @@ class GenericCommitStatus < CommitStatus end def detailed_status(current_user) - Gitlab::Ci::Status::External::Factory - .new(self, current_user) - .fabricate! + Gitlab::Ci::Status::External::Factory. + new(self, current_user). + fabricate! end end diff --git a/app/models/global_milestone.rb b/app/models/global_milestone.rb index b991d78e27f..84deb67ba9b 100644 --- a/app/models/global_milestone.rb +++ b/app/models/global_milestone.rb @@ -76,8 +76,8 @@ class GlobalMilestone end def labels - @labels ||= GlobalLabel.build_collection(milestones.includes(:labels).map(&:labels).flatten) - .sort_by!(&:title) + @labels ||= GlobalLabel.build_collection(milestones.includes(:labels).map(&:labels).flatten). + sort_by!(&:title) end def due_date diff --git a/app/models/group.rb b/app/models/group.rb index 5ef3f9513fc..1835ce118a1 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -71,9 +71,9 @@ class Group < Namespace def select_for_project_authorization if current_scope.joins_values.include?(:shared_projects) - joins('INNER JOIN namespaces project_namespace ON project_namespace.id = projects.namespace_id') - .where('project_namespace.share_with_group_lock = ?', false) - .select("members.user_id, projects.id AS project_id, LEAST(project_group_links.group_access, members.access_level) AS access_level") + joins('INNER JOIN namespaces project_namespace ON project_namespace.id = projects.namespace_id'). + where('project_namespace.share_with_group_lock = ?', false). + select("members.user_id, projects.id AS project_id, LEAST(project_group_links.group_access, members.access_level) AS access_level") else super end @@ -197,8 +197,8 @@ class Group < Namespace end def refresh_members_authorized_projects - UserProjectAccessChangedService.new(user_ids_for_project_authorizations) - .execute + UserProjectAccessChangedService.new(user_ids_for_project_authorizations). + execute end def user_ids_for_project_authorizations diff --git a/app/models/issue_collection.rb b/app/models/issue_collection.rb index 49f011c113f..f0b7d9914c8 100644 --- a/app/models/issue_collection.rb +++ b/app/models/issue_collection.rb @@ -17,9 +17,9 @@ class IssueCollection # Given all the issue projects we get a list of projects that the current # user has at least reporter access to. - projects_with_reporter_access = user - .projects_with_reporter_access_limited_to(project_ids) - .pluck(:id) + projects_with_reporter_access = user. + projects_with_reporter_access_limited_to(project_ids). + pluck(:id) collection.select do |issue| if projects_with_reporter_access.include?(issue.project_id) diff --git a/app/models/label.rb b/app/models/label.rb index e97e53301cc..27429e60e4a 100644 --- a/app/models/label.rb +++ b/app/models/label.rb @@ -34,18 +34,18 @@ class Label < ActiveRecord::Base scope :with_title, ->(title) { where(title: title) } def self.prioritized(project) - joins(:priorities) - .where(label_priorities: { project_id: project }) - .reorder('label_priorities.priority ASC, labels.title ASC') + joins(:priorities). + where(label_priorities: { project_id: project }). + reorder('label_priorities.priority ASC, labels.title ASC') end def self.unprioritized(project) labels = Label.arel_table priorities = LabelPriority.arel_table - label_priorities = labels.join(priorities, Arel::Nodes::OuterJoin) - .on(labels[:id].eq(priorities[:label_id]).and(priorities[:project_id].eq(project.id))) - .join_sources + label_priorities = labels.join(priorities, Arel::Nodes::OuterJoin). + on(labels[:id].eq(priorities[:label_id]).and(priorities[:project_id].eq(project.id))). + join_sources joins(label_priorities).where(priorities[:priority].eq(nil)) end @@ -54,9 +54,9 @@ class Label < ActiveRecord::Base labels = Label.arel_table priorities = LabelPriority.arel_table - label_priorities = labels.join(priorities, Arel::Nodes::OuterJoin) - .on(labels[:id].eq(priorities[:label_id])) - .join_sources + label_priorities = labels.join(priorities, Arel::Nodes::OuterJoin). + on(labels[:id].eq(priorities[:label_id])). + join_sources joins(label_priorities) end diff --git a/app/models/lfs_object.rb b/app/models/lfs_object.rb index 7712d5783e0..ee9ac282e39 100644 --- a/app/models/lfs_object.rb +++ b/app/models/lfs_object.rb @@ -19,8 +19,8 @@ class LfsObject < ActiveRecord::Base end def self.destroy_unreferenced - joins("LEFT JOIN lfs_objects_projects ON lfs_objects_projects.lfs_object_id = #{table_name}.id") - .where(lfs_objects_projects: { id: nil }) - .destroy_all + joins("LEFT JOIN lfs_objects_projects ON lfs_objects_projects.lfs_object_id = #{table_name}.id"). + where(lfs_objects_projects: { id: nil }). + destroy_all end end diff --git a/app/models/member.rb b/app/models/member.rb index f198fbe9056..abe9aee3edf 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -41,9 +41,9 @@ class Member < ActiveRecord::Base is_external_invite = arel_table[:user_id].eq(nil).and(arel_table[:invite_token].not_eq(nil)) user_is_active = User.arel_table[:state].eq(:active) - includes(:user).references(:users) - .where(is_external_invite.or(user_is_active)) - .where(requested_at: nil) + includes(:user).references(:users). + where(is_external_invite.or(user_is_active)). + where(requested_at: nil) end scope :invite, -> { where.not(invite_token: nil) } @@ -99,9 +99,9 @@ class Member < ActiveRecord::Base users = User.arel_table members = Member.arel_table - member_users = members.join(users, Arel::Nodes::OuterJoin) - .on(members[:user_id].eq(users[:id])) - .join_sources + member_users = members.join(users, Arel::Nodes::OuterJoin). + on(members[:user_id].eq(users[:id])). + join_sources joins(member_users) end diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index c4520c16a43..ea784f77015 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -475,10 +475,10 @@ class MergeRequest < ActiveRecord::Base end def discussions - @discussions ||= self.related_notes - .inc_relations_for_view - .fresh - .discussions + @discussions ||= self.related_notes. + inc_relations_for_view. + fresh. + discussions end def diff_discussions @@ -564,8 +564,8 @@ class MergeRequest < ActiveRecord::Base messages = [title, description] messages.concat(commits.map(&:safe_message)) if merge_request_diff - Gitlab::ClosingIssueExtractor.new(project, current_user) - .closed_by_message(messages.join("\n")) + Gitlab::ClosingIssueExtractor.new(project, current_user). + closed_by_message(messages.join("\n")) else [] end @@ -813,9 +813,9 @@ class MergeRequest < ActiveRecord::Base def all_pipelines return Ci::Pipeline.none unless source_project - @all_pipelines ||= source_project.pipelines - .where(sha: all_commits_sha, ref: source_branch) - .order(id: :desc) + @all_pipelines ||= source_project.pipelines. + where(sha: all_commits_sha, ref: source_branch). + order(id: :desc) end # Note that this could also return SHA from now dangling commits diff --git a/app/models/merge_request_diff.rb b/app/models/merge_request_diff.rb index baee00b8fcd..53d08488788 100644 --- a/app/models/merge_request_diff.rb +++ b/app/models/merge_request_diff.rb @@ -169,8 +169,8 @@ class MergeRequestDiff < ActiveRecord::Base # When compare merge request versions we want diff A..B instead of A...B # so we handle cases when user does squash and rebase of the commits between versions. # For this reason we set straight to true by default. - CompareService.new(project, head_commit_sha) - .execute(project, sha, straight: straight) + CompareService.new(project, head_commit_sha). + execute(project, sha, straight: straight) end def commits_count diff --git a/app/models/merge_requests_closing_issues.rb b/app/models/merge_requests_closing_issues.rb index 7f7c114803d..daafb137be4 100644 --- a/app/models/merge_requests_closing_issues.rb +++ b/app/models/merge_requests_closing_issues.rb @@ -7,9 +7,9 @@ class MergeRequestsClosingIssues < ActiveRecord::Base class << self def count_for_collection(ids) - group(:issue_id) - .where(issue_id: ids) - .pluck('issue_id', 'COUNT(*) as count') + group(:issue_id). + where(issue_id: ids). + pluck('issue_id', 'COUNT(*) as count') end end end diff --git a/app/models/milestone.rb b/app/models/milestone.rb index 30e5dfd096e..7331000a9f2 100644 --- a/app/models/milestone.rb +++ b/app/models/milestone.rb @@ -98,11 +98,11 @@ class Milestone < ActiveRecord::Base if Gitlab::Database.postgresql? rel.order(:project_id, :due_date).select('DISTINCT ON (project_id) id') else - rel - .group(:project_id) - .having('due_date = MIN(due_date)') - .pluck(:id, :project_id, :due_date) - .map(&:first) + rel. + group(:project_id). + having('due_date = MIN(due_date)'). + pluck(:id, :project_id, :due_date). + map(&:first) end end @@ -177,8 +177,8 @@ class Milestone < ActiveRecord::Base conditions = 'WHEN id = ? THEN ? ' * ids.length - issues.where(id: ids) - .update_all(["position = CASE #{conditions} ELSE position END", *pairs]) + issues.where(id: ids). + update_all(["position = CASE #{conditions} ELSE position END", *pairs]) end private diff --git a/app/models/namespace.rb b/app/models/namespace.rb index 9334b7d9e61..e207ac3db4e 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -48,9 +48,9 @@ class Namespace < ActiveRecord::Base scope :root, -> { where('type IS NULL') } scope :with_statistics, -> do - joins('LEFT JOIN project_statistics ps ON ps.namespace_id = namespaces.id') - .group('namespaces.id') - .select( + joins('LEFT JOIN project_statistics ps ON ps.namespace_id = namespaces.id'). + group('namespaces.id'). + select( 'namespaces.*', 'COALESCE(SUM(ps.storage_size), 0) AS storage_size', 'COALESCE(SUM(ps.repository_size), 0) AS repository_size', @@ -251,10 +251,10 @@ class Namespace < ActiveRecord::Base end def refresh_access_of_projects_invited_groups - Group - .joins(project_group_links: :project) - .where(projects: { namespace_id: id }) - .find_each(&:refresh_members_authorized_projects) + Group. + joins(project_group_links: :project). + where(projects: { namespace_id: id }). + find_each(&:refresh_members_authorized_projects) end def remove_exports! diff --git a/app/models/network/commit.rb b/app/models/network/commit.rb index 8417f200e36..a48e872ad84 100644 --- a/app/models/network/commit.rb +++ b/app/models/network/commit.rb @@ -28,8 +28,8 @@ module Network if map.include?(p.id) map[p.id] end - end - .compact + end. + compact end end end diff --git a/app/models/network/graph.rb b/app/models/network/graph.rb index 0bbc9451ffd..2a7fa7d0607 100644 --- a/app/models/network/graph.rb +++ b/app/models/network/graph.rb @@ -23,12 +23,12 @@ module Network def collect_notes h = Hash.new(0) - @project - .notes - .where('noteable_type = ?', 'Commit') - .group('notes.commit_id') - .select('notes.commit_id, count(notes.id) as note_count') - .each do |item| + @project. + notes. + where('noteable_type = ?', 'Commit'). + group('notes.commit_id'). + select('notes.commit_id, count(notes.id) as note_count'). + each do |item| h[item.commit_id] = item.note_count.to_i end diff --git a/app/models/note.rb b/app/models/note.rb index c6406f644e0..d6d5396afa5 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -105,14 +105,14 @@ class Note < ActiveRecord::Base def grouped_diff_discussions active_notes = diff_notes.fresh.select(&:active?) - Discussion.for_diff_notes(active_notes) - .map { |d| [d.line_code, d] }.to_h + Discussion.for_diff_notes(active_notes). + map { |d| [d.line_code, d] }.to_h end def count_for_collection(ids, type) - user.select('noteable_id', 'COUNT(*) as count') - .group(:noteable_id) - .where(noteable_type: type, noteable_id: ids) + user.select('noteable_id', 'COUNT(*) as count'). + group(:noteable_id). + where(noteable_type: type, noteable_id: ids) end end diff --git a/app/models/project.rb b/app/models/project.rb index 698e742de48..301ff71cc01 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -235,8 +235,8 @@ class Project < ActiveRecord::Base scope :inside_path, ->(path) do # We need routes alias rs for JOIN so it does not conflict with # includes(:route) which we use in ProjectsFinder. - joins("INNER JOIN routes rs ON rs.source_id = projects.id AND rs.source_type = 'Project'") - .where('rs.path LIKE ?', "#{path}/%") + joins("INNER JOIN routes rs ON rs.source_id = projects.id AND rs.source_type = 'Project'"). + where('rs.path LIKE ?', "#{path}/%") end # "enabled" here means "not disabled". It includes private features! @@ -313,9 +313,9 @@ class Project < ActiveRecord::Base pattern = "%#{query}%" projects = select(:id).where( - ptable[:path].matches(pattern) - .or(ptable[:name].matches(pattern)) - .or(ptable[:description].matches(pattern)) + ptable[:path].matches(pattern). + or(ptable[:name].matches(pattern)). + or(ptable[:description].matches(pattern)) ) # We explicitly remove any eager loading clauses as they're: @@ -324,10 +324,10 @@ class Project < ActiveRecord::Base # 2. Combined with .joins(:namespace) lead to all columns from the # projects & namespaces tables being selected, leading to a SQL error # due to the columns of all UNION'd queries no longer being the same. - namespaces = select(:id) - .except(:includes) - .joins(:namespace) - .where(ntable[:name].matches(pattern)) + namespaces = select(:id). + except(:includes). + joins(:namespace). + where(ntable[:name].matches(pattern)) union = Gitlab::SQL::Union.new([projects, namespaces]) @@ -369,8 +369,8 @@ class Project < ActiveRecord::Base end def trending - joins('INNER JOIN trending_projects ON projects.id = trending_projects.project_id') - .reorder('trending_projects.id ASC') + joins('INNER JOIN trending_projects ON projects.id = trending_projects.project_id'). + reorder('trending_projects.id ASC') end def cached_count diff --git a/app/models/project_services/kubernetes_service.rb b/app/models/project_services/kubernetes_service.rb index 02e802bad6d..9819e723fe8 100644 --- a/app/models/project_services/kubernetes_service.rb +++ b/app/models/project_services/kubernetes_service.rb @@ -105,9 +105,9 @@ class KubernetesService < DeploymentService def terminals(environment) with_reactive_cache do |data| pods = data.fetch(:pods, nil) - filter_pods(pods, app: environment.slug) - .flat_map { |pod| terminals_for_pod(api_url, namespace, pod) } - .each { |terminal| add_terminal_auth(terminal, terminal_auth) } + filter_pods(pods, app: environment.slug). + flat_map { |pod| terminals_for_pod(api_url, namespace, pod) }. + each { |terminal| add_terminal_auth(terminal, terminal_auth) } end end diff --git a/app/models/project_services/mattermost_slash_commands_service.rb b/app/models/project_services/mattermost_slash_commands_service.rb index 26376fd87ff..56f42d63b2d 100644 --- a/app/models/project_services/mattermost_slash_commands_service.rb +++ b/app/models/project_services/mattermost_slash_commands_service.rb @@ -20,8 +20,8 @@ class MattermostSlashCommandsService < ChatSlashCommandsService end def configure(user, params) - token = Mattermost::Command.new(user) - .create(command(params)) + token = Mattermost::Command.new(user). + create(command(params)) update(active: true, token: token) if token rescue Mattermost::Error => e diff --git a/app/models/project_team.rb b/app/models/project_team.rb index 67cc06642f1..8a53e974b6f 100644 --- a/app/models/project_team.rb +++ b/app/models/project_team.rb @@ -169,10 +169,10 @@ class ProjectTeam # Lookup only the IDs we need user_ids = user_ids - access.keys - users_access = project.project_authorizations - .where(user: user_ids) - .group(:user_id) - .maximum(:access_level) + users_access = project.project_authorizations. + where(user: user_ids). + group(:user_id). + maximum(:access_level) access.merge!(users_access) access diff --git a/app/models/repository.rb b/app/models/repository.rb index d1dd900d597..cd2568ad445 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -249,11 +249,11 @@ class Repository cache.fetch(:"diverging_commit_counts_#{branch.name}") do # Rugged seems to throw a `ReferenceError` when given branch_names rather # than SHA-1 hashes - number_commits_behind = raw_repository - .count_commits_between(branch.dereferenced_target.sha, root_ref_hash) + number_commits_behind = raw_repository. + count_commits_between(branch.dereferenced_target.sha, root_ref_hash) - number_commits_ahead = raw_repository - .count_commits_between(root_ref_hash, branch.dereferenced_target.sha) + number_commits_ahead = raw_repository. + count_commits_between(root_ref_hash, branch.dereferenced_target.sha) { behind: number_commits_behind, ahead: number_commits_ahead } end @@ -755,8 +755,8 @@ class Repository check_tree_entry_for_dir(branch_name, path) if start_branch_name - start_project.repository - .check_tree_entry_for_dir(start_branch_name, path) + start_project.repository. + check_tree_entry_for_dir(start_branch_name, path) end commit_file( diff --git a/app/models/todo.rb b/app/models/todo.rb index 32bb9bf2045..47789a21133 100644 --- a/app/models/todo.rb +++ b/app/models/todo.rb @@ -64,9 +64,9 @@ class Todo < ActiveRecord::Base highest_priority = highest_label_priority(params).to_sql - select("#{table_name}.*, (#{highest_priority}) AS highest_priority") - .order(Gitlab::Database.nulls_last_order('highest_priority', 'ASC')) - .order('todos.created_at') + select("#{table_name}.*, (#{highest_priority}) AS highest_priority"). + order(Gitlab::Database.nulls_last_order('highest_priority', 'ASC')). + order('todos.created_at') end end diff --git a/app/models/user.rb b/app/models/user.rb index 801c84dc011..fada0e567f0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -197,13 +197,13 @@ class User < ActiveRecord::Base scope :order_oldest_sign_in, -> { reorder(Gitlab::Database.nulls_last_order('last_sign_in_at', 'ASC')) } def self.with_two_factor - joins("LEFT OUTER JOIN u2f_registrations AS u2f ON u2f.user_id = users.id") - .where("u2f.id IS NOT NULL OR otp_required_for_login = ?", true).distinct(arel_table[:id]) + joins("LEFT OUTER JOIN u2f_registrations AS u2f ON u2f.user_id = users.id"). + where("u2f.id IS NOT NULL OR otp_required_for_login = ?", true).distinct(arel_table[:id]) end def self.without_two_factor - joins("LEFT OUTER JOIN u2f_registrations AS u2f ON u2f.user_id = users.id") - .where("u2f.id IS NULL AND otp_required_for_login = ?", false) + joins("LEFT OUTER JOIN u2f_registrations AS u2f ON u2f.user_id = users.id"). + where("u2f.id IS NULL AND otp_required_for_login = ?", false) end # @@ -274,9 +274,9 @@ class User < ActiveRecord::Base pattern = "%#{query}%" where( - table[:name].matches(pattern) - .or(table[:email].matches(pattern)) - .or(table[:username].matches(pattern)) + table[:name].matches(pattern). + or(table[:email].matches(pattern)). + or(table[:username].matches(pattern)) ) end @@ -291,10 +291,10 @@ class User < ActiveRecord::Base matched_by_emails_user_ids = email_table.project(email_table[:user_id]).where(email_table[:email].matches(pattern)) where( - table[:name].matches(pattern) - .or(table[:email].matches(pattern)) - .or(table[:username].matches(pattern)) - .or(table[:id].in(matched_by_emails_user_ids)) + table[:name].matches(pattern). + or(table[:email].matches(pattern)). + or(table[:username].matches(pattern)). + or(table[:id].in(matched_by_emails_user_ids)) ) end @@ -447,8 +447,8 @@ class User < ActiveRecord::Base # Returns the groups a user has access to def authorized_groups - union = Gitlab::SQL::Union - .new([groups.select(:id), authorized_projects.select(:namespace_id)]) + union = Gitlab::SQL::Union. + new([groups.select(:id), authorized_projects.select(:namespace_id)]) Group.where("namespaces.id IN (#{union.to_sql})") end @@ -458,8 +458,8 @@ class User < ActiveRecord::Base end def nested_projects - Project.joins(:namespace).where('namespaces.parent_id IS NOT NULL') - .member_descendants(id) + Project.joins(:namespace).where('namespaces.parent_id IS NOT NULL'). + member_descendants(id) end def refresh_authorized_projects @@ -579,9 +579,9 @@ class User < ActiveRecord::Base next unless project if project.repository.branch_exists?(event.branch_name) - merge_requests = MergeRequest.where("created_at >= ?", event.created_at) - .where(source_project_id: project.id, - source_branch: event.branch_name) + merge_requests = MergeRequest.where("created_at >= ?", event.created_at). + where(source_project_id: project.id, + source_branch: event.branch_name) merge_requests.empty? end end @@ -793,8 +793,8 @@ class User < ActiveRecord::Base def toggle_star(project) UsersStarProject.transaction do - user_star_project = users_star_projects - .where(project: project, user: self).lock(true).first + user_star_project = users_star_projects. + where(project: project, user: self).lock(true).first if user_star_project user_star_project.destroy @@ -830,11 +830,11 @@ class User < ActiveRecord::Base # ms on a database with a similar size to GitLab.com's database. On the other # hand, using a subquery means we can get the exact same data in about 40 ms. def contributed_projects - events = Event.select(:project_id) - .contributions.where(author_id: self) - .where("created_at > ?", Time.now - 1.year) - .uniq - .reorder(nil) + events = Event.select(:project_id). + contributions.where(author_id: self). + where("created_at > ?", Time.now - 1.year). + uniq. + reorder(nil) Project.where(id: events) end @@ -845,9 +845,9 @@ class User < ActiveRecord::Base def ci_authorized_runners @ci_authorized_runners ||= begin - runner_ids = Ci::RunnerProject - .where("ci_runner_projects.gl_project_id IN (#{ci_projects_union.to_sql})") - .select(:runner_id) + runner_ids = Ci::RunnerProject. + where("ci_runner_projects.gl_project_id IN (#{ci_projects_union.to_sql})"). + select(:runner_id) Ci::Runner.specific.where(id: runner_ids) end end diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index 0fa9d77a771..2caebb496db 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -22,16 +22,16 @@ class WikiPage def self.group_by_directory(pages) return [] if pages.blank? - pages.sort_by { |page| [page.directory, page.slug] } - .group_by(&:directory) - .map do |dir, pages| + pages.sort_by { |page| [page.directory, page.slug] }. + group_by(&:directory). + map do |dir, pages| if dir.present? WikiDirectory.new(dir, pages) else pages end - end - .flatten + end. + flatten end def self.unhyphenize(name) diff --git a/app/serializers/base_serializer.rb b/app/serializers/base_serializer.rb index 311ee9c96be..032c44274ef 100644 --- a/app/serializers/base_serializer.rb +++ b/app/serializers/base_serializer.rb @@ -4,9 +4,9 @@ class BaseSerializer end def represent(resource, opts = {}) - self.class.entity_class - .represent(resource, opts.merge(request: @request)) - .as_json + self.class.entity_class. + represent(resource, opts.merge(request: @request)). + as_json end def self.entity(entity_class) diff --git a/app/serializers/environment_serializer.rb b/app/serializers/environment_serializer.rb index d0a60f134da..ffc4fd34c75 100644 --- a/app/serializers/environment_serializer.rb +++ b/app/serializers/environment_serializer.rb @@ -36,9 +36,9 @@ class EnvironmentSerializer < BaseSerializer private def itemize(resource) - items = resource.order('folder_name ASC') - .group('COALESCE(environment_type, name)') - .select('COALESCE(environment_type, name) AS folder_name', + items = resource.order('folder_name ASC'). + group('COALESCE(environment_type, name)'). + select('COALESCE(environment_type, name) AS folder_name', 'COUNT(*) AS size', 'MAX(id) AS last_id') # It makes a difference when you call `paginate` method, because diff --git a/app/services/after_branch_delete_service.rb b/app/services/after_branch_delete_service.rb index 227e9ea9c6d..95492f709bb 100644 --- a/app/services/after_branch_delete_service.rb +++ b/app/services/after_branch_delete_service.rb @@ -14,8 +14,8 @@ class AfterBranchDeleteService < BaseService private def stop_environments - Ci::StopEnvironmentsService - .new(project, current_user) - .execute(branch_name) + Ci::StopEnvironmentsService. + new(project, current_user). + execute(branch_name) end end diff --git a/app/services/boards/issues/list_service.rb b/app/services/boards/issues/list_service.rb index 8a94c54b6ab..2d664f3f0c8 100644 --- a/app/services/boards/issues/list_service.rb +++ b/app/services/boards/issues/list_service.rb @@ -57,15 +57,15 @@ module Boards return issues unless board_label_ids.any? issues.where.not( - LabelLink.where("label_links.target_type = 'Issue' AND label_links.target_id = issues.id") - .where(label_id: board_label_ids).limit(1).arel.exists + LabelLink.where("label_links.target_type = 'Issue' AND label_links.target_id = issues.id"). + where(label_id: board_label_ids).limit(1).arel.exists ) end def with_list_label(issues) issues.where( - LabelLink.where("label_links.target_type = 'Issue' AND label_links.target_id = issues.id") - .where("label_links.label_id = ?", list.label_id).limit(1).arel.exists + LabelLink.where("label_links.target_type = 'Issue' AND label_links.target_id = issues.id"). + where("label_links.label_id = ?", list.label_id).limit(1).arel.exists ) end end diff --git a/app/services/boards/lists/destroy_service.rb b/app/services/boards/lists/destroy_service.rb index f986e05944c..6c80dd61873 100644 --- a/app/services/boards/lists/destroy_service.rb +++ b/app/services/boards/lists/destroy_service.rb @@ -17,8 +17,8 @@ module Boards attr_reader :board def decrement_higher_lists(list) - board.lists.movable.where('position > ?', list.position) - .update_all('position = position - 1') + board.lists.movable.where('position > ?', list.position). + update_all('position = position - 1') end def remove_list(list) diff --git a/app/services/boards/lists/move_service.rb b/app/services/boards/lists/move_service.rb index f2a68865f7b..2f109934ea9 100644 --- a/app/services/boards/lists/move_service.rb +++ b/app/services/boards/lists/move_service.rb @@ -33,15 +33,15 @@ module Boards end def decrement_intermediate_lists - board.lists.movable.where('position > ?', old_position) - .where('position <= ?', new_position) - .update_all('position = position - 1') + board.lists.movable.where('position > ?', old_position). + where('position <= ?', new_position). + update_all('position = position - 1') end def increment_intermediate_lists - board.lists.movable.where('position >= ?', new_position) - .where('position < ?', old_position) - .update_all('position = position + 1') + board.lists.movable.where('position >= ?', new_position). + where('position < ?', old_position). + update_all('position = position + 1') end def update_list_position(list) diff --git a/app/services/ci/create_pipeline_builds_service.rb b/app/services/ci/create_pipeline_builds_service.rb index 4cbbd366cc4..70fb2c5e38f 100644 --- a/app/services/ci/create_pipeline_builds_service.rb +++ b/app/services/ci/create_pipeline_builds_service.rb @@ -34,8 +34,8 @@ module Ci end def new_builds - @new_builds ||= pipeline.config_builds_attributes - .reject { |build| existing_build_names.include?(build[:name]) } + @new_builds ||= pipeline.config_builds_attributes. + reject { |build| existing_build_names.include?(build[:name]) } end def existing_build_names diff --git a/app/services/ci/create_pipeline_service.rb b/app/services/ci/create_pipeline_service.rb index 38a85e9fc42..b53a467655f 100644 --- a/app/services/ci/create_pipeline_service.rb +++ b/app/services/ci/create_pipeline_service.rb @@ -48,9 +48,9 @@ module Ci Ci::Pipeline.transaction do pipeline.save - Ci::CreatePipelineBuildsService - .new(project, current_user) - .execute(pipeline) + Ci::CreatePipelineBuildsService. + new(project, current_user). + execute(pipeline) end pipeline.tap(&:process!) diff --git a/app/services/ci/create_trigger_request_service.rb b/app/services/ci/create_trigger_request_service.rb index 062e7be5be8..6af3c1ca5b1 100644 --- a/app/services/ci/create_trigger_request_service.rb +++ b/app/services/ci/create_trigger_request_service.rb @@ -3,8 +3,8 @@ module Ci def execute(project, trigger, ref, variables = nil) trigger_request = trigger.trigger_requests.create(variables: variables) - pipeline = Ci::CreatePipelineService.new(project, nil, ref: ref) - .execute(ignore_skip_ci: true, trigger_request: trigger_request) + pipeline = Ci::CreatePipelineService.new(project, nil, ref: ref). + execute(ignore_skip_ci: true, trigger_request: trigger_request) if pipeline.persisted? trigger_request end diff --git a/app/services/ci/process_pipeline_service.rb b/app/services/ci/process_pipeline_service.rb index 79eb97b7b55..442230abe29 100644 --- a/app/services/ci/process_pipeline_service.rb +++ b/app/services/ci/process_pipeline_service.rb @@ -78,9 +78,9 @@ module Ci def ensure_created_builds! return if created_builds.any? - Ci::CreatePipelineBuildsService - .new(project, current_user) - .execute(pipeline) + Ci::CreatePipelineBuildsService. + new(project, current_user). + execute(pipeline) end end end diff --git a/app/services/ci/register_build_service.rb b/app/services/ci/register_build_service.rb index 9c7abf97b4c..6f03bf2be13 100644 --- a/app/services/ci/register_build_service.rb +++ b/app/services/ci/register_build_service.rb @@ -42,15 +42,15 @@ module Ci def builds_for_shared_runner new_builds. # don't run projects which have not enabled shared runners and builds - joins(:project).where(projects: { shared_runners_enabled: true }) - .joins('LEFT JOIN project_features ON ci_builds.gl_project_id = project_features.project_id') - .where('project_features.builds_access_level IS NULL or project_features.builds_access_level > 0'). + joins(:project).where(projects: { shared_runners_enabled: true }). + joins('LEFT JOIN project_features ON ci_builds.gl_project_id = project_features.project_id'). + where('project_features.builds_access_level IS NULL or project_features.builds_access_level > 0'). # Implement fair scheduling # this returns builds that are ordered by number of running builds # we prefer projects that don't use shared runners at all - joins("LEFT JOIN (#{running_builds_for_shared_runners.to_sql}) AS project_builds ON ci_builds.gl_project_id=project_builds.gl_project_id") - .order('COALESCE(project_builds.running_builds, 0) ASC', 'ci_builds.id ASC') + joins("LEFT JOIN (#{running_builds_for_shared_runners.to_sql}) AS project_builds ON ci_builds.gl_project_id=project_builds.gl_project_id"). + order('COALESCE(project_builds.running_builds, 0) ASC', 'ci_builds.id ASC') end def builds_for_specific_runner @@ -58,8 +58,8 @@ module Ci end def running_builds_for_shared_runners - Ci::Build.running.where(runner: Ci::Runner.shared) - .group(:gl_project_id).select(:gl_project_id, 'count(*) AS running_builds') + Ci::Build.running.where(runner: Ci::Runner.shared). + group(:gl_project_id).select(:gl_project_id, 'count(*) AS running_builds') end def new_builds diff --git a/app/services/ci/retry_build_service.rb b/app/services/ci/retry_build_service.rb index 38ef323f6e5..c1fa9278f0f 100644 --- a/app/services/ci/retry_build_service.rb +++ b/app/services/ci/retry_build_service.rb @@ -2,8 +2,8 @@ module Ci class RetryBuildService < ::BaseService CLONE_ATTRIBUTES = %i[pipeline project ref tag options commands name allow_failure stage stage_idx trigger_request - yaml_variables when environment coverage_regex] - .freeze + yaml_variables when environment coverage_regex]. + freeze REJECT_ATTRIBUTES = %i[id status user token coverage trace runner artifacts_expire_at artifacts_file @@ -20,9 +20,9 @@ module Ci new_build.enqueue! - MergeRequests::AddTodoWhenBuildFailsService - .new(project, current_user) - .close(new_build) + MergeRequests::AddTodoWhenBuildFailsService. + new(project, current_user). + close(new_build) end end diff --git a/app/services/ci/retry_pipeline_service.rb b/app/services/ci/retry_pipeline_service.rb index 2c5e130e5aa..6e9781ca8cf 100644 --- a/app/services/ci/retry_pipeline_service.rb +++ b/app/services/ci/retry_pipeline_service.rb @@ -8,13 +8,13 @@ module Ci pipeline.builds.failed_or_canceled.find_each do |build| next unless build.retryable? - Ci::RetryBuildService.new(project, current_user) - .reprocess(build) + Ci::RetryBuildService.new(project, current_user). + reprocess(build) end - MergeRequests::AddTodoWhenBuildFailsService - .new(project, current_user) - .close_all(pipeline) + MergeRequests::AddTodoWhenBuildFailsService. + new(project, current_user). + close_all(pipeline) pipeline.process! end diff --git a/app/services/commits/change_service.rb b/app/services/commits/change_service.rb index 25e22f14e60..75281837b09 100644 --- a/app/services/commits/change_service.rb +++ b/app/services/commits/change_service.rb @@ -70,8 +70,8 @@ module Commits # Temporary branch exists and contains the change commit return if repository.find_branch(new_branch) - result = ValidateNewBranchService.new(@project, current_user) - .execute(new_branch) + result = ValidateNewBranchService.new(@project, current_user). + execute(new_branch) if result[:status] == :error raise ChangeError, "There was an error creating the source branch: #{result[:message]}" diff --git a/app/services/create_branch_service.rb b/app/services/create_branch_service.rb index 77459d8779d..1b5e504573a 100644 --- a/app/services/create_branch_service.rb +++ b/app/services/create_branch_service.rb @@ -1,7 +1,7 @@ class CreateBranchService < BaseService def execute(branch_name, ref) - result = ValidateNewBranchService.new(project, current_user) - .execute(branch_name) + result = ValidateNewBranchService.new(project, current_user). + execute(branch_name) return result if result[:status] == :error diff --git a/app/services/files/base_service.rb b/app/services/files/base_service.rb index dcec604b455..0a25f56d24c 100644 --- a/app/services/files/base_service.rb +++ b/app/services/files/base_service.rb @@ -72,8 +72,8 @@ module Files end def validate_target_branch - result = ValidateNewBranchService.new(project, current_user) - .execute(@target_branch) + result = ValidateNewBranchService.new(project, current_user). + execute(@target_branch) if result[:status] == :error raise_error("Something went wrong when we tried to create #{@target_branch} for you: #{result[:message]}") diff --git a/app/services/files/update_service.rb b/app/services/files/update_service.rb index b1e8d11fdcf..a71fe61a4b6 100644 --- a/app/services/files/update_service.rb +++ b/app/services/files/update_service.rb @@ -24,8 +24,8 @@ module Files end def last_commit - @last_commit ||= Gitlab::Git::Commit - .last_for_path(@start_project.repository, @start_branch, @file_path) + @last_commit ||= Gitlab::Git::Commit. + last_for_path(@start_project.repository, @start_branch, @file_path) end end end diff --git a/app/services/git_push_service.rb b/app/services/git_push_service.rb index ee6e695c134..f681f831cbd 100644 --- a/app/services/git_push_service.rb +++ b/app/services/git_push_service.rb @@ -85,8 +85,8 @@ class GitPushService < BaseService default = is_default_branch? push_commits.last(PROCESS_COMMIT_LIMIT).each do |commit| - ProcessCommitWorker - .perform_async(project.id, current_user.id, commit.to_hash, default) + ProcessCommitWorker. + perform_async(project.id, current_user.id, commit.to_hash, default) end end @@ -96,8 +96,8 @@ class GitPushService < BaseService # Update merge requests that may be affected by this push. A new branch # could cause the last commit of a merge request to change. # - UpdateMergeRequestsWorker - .perform_async(@project.id, current_user.id, params[:oldrev], params[:newrev], params[:ref]) + UpdateMergeRequestsWorker. + perform_async(@project.id, current_user.id, params[:oldrev], params[:newrev], params[:ref]) EventCreateService.new.push(@project, current_user, build_push_data) @project.execute_hooks(build_push_data.dup, :push_hooks) @@ -105,9 +105,9 @@ class GitPushService < BaseService Ci::CreatePipelineService.new(@project, current_user, build_push_data).execute if push_remove_branch? - AfterBranchDeleteService - .new(project, current_user) - .execute(branch_name) + AfterBranchDeleteService. + new(project, current_user). + execute(branch_name) end end diff --git a/app/services/issuable_base_service.rb b/app/services/issuable_base_service.rb index 457dcf76995..9500faf2862 100644 --- a/app/services/issuable_base_service.rb +++ b/app/services/issuable_base_service.rb @@ -144,8 +144,8 @@ class IssuableBaseService < BaseService def merge_slash_commands_into_params!(issuable) description, command_params = - SlashCommands::InterpretService.new(project, current_user) - .execute(params[:description], issuable) + SlashCommands::InterpretService.new(project, current_user). + execute(params[:description], issuable) # Avoid a description already set on an issuable to be overwritten by a nil params[:description] = description if params.has_key?(:description) diff --git a/app/services/issues/create_service.rb b/app/services/issues/create_service.rb index 9e0c90b56f6..366b3572738 100644 --- a/app/services/issues/create_service.rb +++ b/app/services/issues/create_service.rb @@ -29,8 +29,8 @@ module Issues def resolve_discussions_in_merge_request(issue) Discussions::ResolveService.new(project, current_user, merge_request: merge_request_for_resolving_discussions, - follow_up_issue: issue) - .execute(merge_request_for_resolving_discussions.resolvable_discussions) + follow_up_issue: issue). + execute(merge_request_for_resolving_discussions.resolvable_discussions) end private diff --git a/app/services/issues/move_service.rb b/app/services/issues/move_service.rb index a2a5f57d069..17b65947468 100644 --- a/app/services/issues/move_service.rb +++ b/app/services/issues/move_service.rb @@ -61,8 +61,8 @@ module Issues end def cloneable_milestone_id - @new_project.milestones - .find_by(title: @old_issue.milestone.try(:title)).try(:id) + @new_project.milestones. + find_by(title: @old_issue.milestone.try(:title)).try(:id) end def rewrite_notes diff --git a/app/services/labels/promote_service.rb b/app/services/labels/promote_service.rb index 43b539ded53..76d0ba67b07 100644 --- a/app/services/labels/promote_service.rb +++ b/app/services/labels/promote_service.rb @@ -26,29 +26,29 @@ module Labels private def label_ids_for_merge(new_label) - LabelsFinder - .new(current_user, title: new_label.title, group_id: project.group.id) - .execute(skip_authorization: true) - .where.not(id: new_label) - .select(:id) # Can't use pluck() to avoid object-creation because of the batching + LabelsFinder. + new(current_user, title: new_label.title, group_id: project.group.id). + execute(skip_authorization: true). + where.not(id: new_label). + select(:id) # Can't use pluck() to avoid object-creation because of the batching end def update_issuables(new_label, label_ids) - LabelLink - .where(label: label_ids) - .update_all(label_id: new_label) + LabelLink. + where(label: label_ids). + update_all(label_id: new_label) end def update_issue_board_lists(new_label, label_ids) - List - .where(label: label_ids) - .update_all(label_id: new_label) + List. + where(label: label_ids). + update_all(label_id: new_label) end def update_priorities(new_label, label_ids) - LabelPriority - .where(label: label_ids) - .update_all(label_id: new_label) + LabelPriority. + where(label: label_ids). + update_all(label_id: new_label) end def update_project_labels(label_ids) diff --git a/app/services/labels/transfer_service.rb b/app/services/labels/transfer_service.rb index d2ece354efc..514679ed29d 100644 --- a/app/services/labels/transfer_service.rb +++ b/app/services/labels/transfer_service.rb @@ -41,16 +41,16 @@ module Labels end def group_labels_applied_to_issues - Label.joins(:issues) - .where( + Label.joins(:issues). + where( issues: { project_id: project.id }, labels: { type: 'GroupLabel', group_id: old_group.id } ) end def group_labels_applied_to_merge_requests - Label.joins(:merge_requests) - .where( + Label.joins(:merge_requests). + where( merge_requests: { target_project_id: project.id }, labels: { type: 'GroupLabel', group_id: old_group.id } ) @@ -64,15 +64,15 @@ module Labels end def update_label_links(labels, old_label_id:, new_label_id:) - LabelLink.joins(:label) - .merge(labels) - .where(label_id: old_label_id) - .update_all(label_id: new_label_id) + LabelLink.joins(:label). + merge(labels). + where(label_id: old_label_id). + update_all(label_id: new_label_id) end def update_label_priorities(old_label_id:, new_label_id:) - LabelPriority.where(project_id: project.id, label_id: old_label_id) - .update_all(label_id: new_label_id) + LabelPriority.where(project_id: project.id, label_id: old_label_id). + update_all(label_id: new_label_id) end end end diff --git a/app/services/merge_requests/base_service.rb b/app/services/merge_requests/base_service.rb index 5a53b973059..fd9d7de35f4 100644 --- a/app/services/merge_requests/base_service.rb +++ b/app/services/merge_requests/base_service.rb @@ -40,11 +40,11 @@ module MergeRequests # Returns all origin and fork merge requests from `@project` satisfying passed arguments. def merge_requests_for(source_branch, mr_states: [:opened]) - MergeRequest - .with_state(mr_states) - .where(source_branch: source_branch, source_project_id: @project.id) - .preload(:source_project) # we don't need a #includes since we're just preloading for the #select - .select(&:source_project) + MergeRequest. + with_state(mr_states). + where(source_branch: source_branch, source_project_id: @project.id). + preload(:source_project). # we don't need a #includes since we're just preloading for the #select + select(&:source_project) end def pipeline_merge_requests(pipeline) diff --git a/app/services/merge_requests/merge_service.rb b/app/services/merge_requests/merge_service.rb index 1657f8624a7..3da1b657a41 100644 --- a/app/services/merge_requests/merge_service.rb +++ b/app/services/merge_requests/merge_service.rb @@ -63,8 +63,8 @@ module MergeRequests MergeRequests::PostMergeService.new(project, current_user).execute(merge_request) if params[:should_remove_source_branch].present? || @merge_request.force_remove_source_branch? - DeleteBranchService.new(@merge_request.source_project, branch_deletion_user) - .execute(merge_request.source_branch) + DeleteBranchService.new(@merge_request.source_project, branch_deletion_user). + execute(merge_request.source_branch) end end diff --git a/app/services/merge_requests/refresh_service.rb b/app/services/merge_requests/refresh_service.rb index 9277f67e5ae..edee3032683 100644 --- a/app/services/merge_requests/refresh_service.rb +++ b/app/services/merge_requests/refresh_service.rb @@ -43,9 +43,9 @@ module MergeRequests end filter_merge_requests(merge_requests).each do |merge_request| - MergeRequests::PostMergeService - .new(merge_request.target_project, @current_user) - .execute(merge_request) + MergeRequests::PostMergeService. + new(merge_request.target_project, @current_user). + execute(merge_request) end end @@ -56,13 +56,13 @@ module MergeRequests # Refresh merge request diff if we push to source or target branch of merge request # Note: we should update merge requests from forks too def reload_merge_requests - merge_requests = @project.merge_requests.opened - .by_source_or_target_branch(@branch_name).to_a + merge_requests = @project.merge_requests.opened. + by_source_or_target_branch(@branch_name).to_a # Fork merge requests - merge_requests += MergeRequest.opened - .where(source_branch: @branch_name, source_project: @project) - .where.not(target_project: @project).to_a + merge_requests += MergeRequest.opened. + where(source_branch: @branch_name, source_project: @project). + where.not(target_project: @project).to_a filter_merge_requests(merge_requests).each do |merge_request| if merge_request.source_branch == @branch_name || force_push? diff --git a/app/services/notes/slash_commands_service.rb b/app/services/notes/slash_commands_service.rb index addb6a7e65b..ad1e6f6774a 100644 --- a/app/services/notes/slash_commands_service.rb +++ b/app/services/notes/slash_commands_service.rb @@ -22,8 +22,8 @@ module Notes def extract_commands(note, options = {}) return [note.note, {}] unless supported?(note) - SlashCommands::InterpretService.new(project, current_user, options) - .execute(note.note, note.noteable) + SlashCommands::InterpretService.new(project, current_user, options). + execute(note.note, note.noteable) end def execute(command_params, note) diff --git a/app/services/tags/create_service.rb b/app/services/tags/create_service.rb index 674792f6138..1756da9e519 100644 --- a/app/services/tags/create_service.rb +++ b/app/services/tags/create_service.rb @@ -19,8 +19,8 @@ module Tags if new_tag if release_description - CreateReleaseService.new(@project, @current_user) - .execute(tag_name, release_description) + CreateReleaseService.new(@project, @current_user). + execute(tag_name, release_description) end success.merge(tag: new_tag) diff --git a/app/services/users/refresh_authorized_projects_service.rb b/app/services/users/refresh_authorized_projects_service.rb index 4411eda3b02..fad741531ea 100644 --- a/app/services/users/refresh_authorized_projects_service.rb +++ b/app/services/users/refresh_authorized_projects_service.rb @@ -103,11 +103,11 @@ module Users end def fresh_authorizations - ProjectAuthorization - .unscoped - .select('project_id, MAX(access_level) AS access_level') - .from("(#{project_authorizations_union.to_sql}) #{ProjectAuthorization.table_name}") - .group(:project_id) + ProjectAuthorization. + unscoped. + select('project_id, MAX(access_level) AS access_level'). + from("(#{project_authorizations_union.to_sql}) #{ProjectAuthorization.table_name}"). + group(:project_id) end private diff --git a/app/workers/build_coverage_worker.rb b/app/workers/build_coverage_worker.rb index def0ab1dde1..31e2dc448da 100644 --- a/app/workers/build_coverage_worker.rb +++ b/app/workers/build_coverage_worker.rb @@ -3,7 +3,7 @@ class BuildCoverageWorker include BuildQueue def perform(build_id) - Ci::Build.find_by(id: build_id) - .try(:update_coverage) + Ci::Build.find_by(id: build_id). + try(:update_coverage) end end diff --git a/app/workers/build_hooks_worker.rb b/app/workers/build_hooks_worker.rb index 9965af935d4..ff22313c491 100644 --- a/app/workers/build_hooks_worker.rb +++ b/app/workers/build_hooks_worker.rb @@ -3,7 +3,7 @@ class BuildHooksWorker include BuildQueue def perform(build_id) - Ci::Build.find_by(id: build_id) - .try(:execute_hooks) + Ci::Build.find_by(id: build_id). + try(:execute_hooks) end end diff --git a/app/workers/emails_on_push_worker.rb b/app/workers/emails_on_push_worker.rb index f5ccc84c160..d4c3f14ec06 100644 --- a/app/workers/emails_on_push_worker.rb +++ b/app/workers/emails_on_push_worker.rb @@ -33,15 +33,15 @@ class EmailsOnPushWorker reverse_compare = false if action == :push - compare = CompareService.new(project, after_sha) - .execute(project, before_sha) + compare = CompareService.new(project, after_sha). + execute(project, before_sha) diff_refs = compare.diff_refs return false if compare.same if compare.commits.empty? - compare = CompareService.new(project, before_sha) - .execute(project, after_sha) + compare = CompareService.new(project, before_sha). + execute(project, after_sha) diff_refs = compare.diff_refs reverse_compare = true diff --git a/app/workers/expire_build_instance_artifacts_worker.rb b/app/workers/expire_build_instance_artifacts_worker.rb index eb403c134d1..2c29a9a58e1 100644 --- a/app/workers/expire_build_instance_artifacts_worker.rb +++ b/app/workers/expire_build_instance_artifacts_worker.rb @@ -3,10 +3,10 @@ class ExpireBuildInstanceArtifactsWorker include DedicatedSidekiqQueue def perform(build_id) - build = Ci::Build - .with_expired_artifacts - .reorder(nil) - .find_by(id: build_id) + build = Ci::Build. + with_expired_artifacts. + reorder(nil). + find_by(id: build_id) return unless build.try(:project) diff --git a/app/workers/merge_worker.rb b/app/workers/merge_worker.rb index 48e2da338f6..79efca4f2f9 100644 --- a/app/workers/merge_worker.rb +++ b/app/workers/merge_worker.rb @@ -7,7 +7,7 @@ class MergeWorker current_user = User.find(current_user_id) merge_request = MergeRequest.find(merge_request_id) - MergeRequests::MergeService.new(merge_request.target_project, current_user, params) - .execute(merge_request) + MergeRequests::MergeService.new(merge_request.target_project, current_user, params). + execute(merge_request) end end diff --git a/app/workers/pipeline_hooks_worker.rb b/app/workers/pipeline_hooks_worker.rb index 7e36eacebf8..7480a055e6a 100644 --- a/app/workers/pipeline_hooks_worker.rb +++ b/app/workers/pipeline_hooks_worker.rb @@ -3,7 +3,7 @@ class PipelineHooksWorker include PipelineQueue def perform(pipeline_id) - Ci::Pipeline.find_by(id: pipeline_id) - .try(:execute_hooks) + Ci::Pipeline.find_by(id: pipeline_id). + try(:execute_hooks) end end diff --git a/app/workers/pipeline_process_worker.rb b/app/workers/pipeline_process_worker.rb index 357e4a9a1c3..5dcb09f553e 100644 --- a/app/workers/pipeline_process_worker.rb +++ b/app/workers/pipeline_process_worker.rb @@ -3,7 +3,7 @@ class PipelineProcessWorker include PipelineQueue def perform(pipeline_id) - Ci::Pipeline.find_by(id: pipeline_id) - .try(:process!) + Ci::Pipeline.find_by(id: pipeline_id). + try(:process!) end end diff --git a/app/workers/pipeline_success_worker.rb b/app/workers/pipeline_success_worker.rb index cc0eb708cf9..ef710f374ca 100644 --- a/app/workers/pipeline_success_worker.rb +++ b/app/workers/pipeline_success_worker.rb @@ -4,9 +4,9 @@ class PipelineSuccessWorker def perform(pipeline_id) Ci::Pipeline.find_by(id: pipeline_id).try do |pipeline| - MergeRequests::MergeWhenPipelineSucceedsService - .new(pipeline.project, nil) - .trigger(pipeline) + MergeRequests::MergeWhenPipelineSucceedsService. + new(pipeline.project, nil). + trigger(pipeline) end end end diff --git a/app/workers/pipeline_update_worker.rb b/app/workers/pipeline_update_worker.rb index 96c4152c674..e6d06d0577d 100644 --- a/app/workers/pipeline_update_worker.rb +++ b/app/workers/pipeline_update_worker.rb @@ -3,7 +3,7 @@ class PipelineUpdateWorker include PipelineQueue def perform(pipeline_id) - Ci::Pipeline.find_by(id: pipeline_id) - .try(:update_status) + Ci::Pipeline.find_by(id: pipeline_id). + try(:update_status) end end diff --git a/app/workers/process_commit_worker.rb b/app/workers/process_commit_worker.rb index 5d7561732f1..e9a5bd7f24e 100644 --- a/app/workers/process_commit_worker.rb +++ b/app/workers/process_commit_worker.rb @@ -45,16 +45,16 @@ class ProcessCommitWorker # therefor we use IssueCollection here and skip the authorization check in # Issues::CloseService#execute. IssueCollection.new(issues).updatable_by_user(user).each do |issue| - Issues::CloseService.new(project, author) - .close_issue(issue, commit: commit) + Issues::CloseService.new(project, author). + close_issue(issue, commit: commit) end end def update_issue_metrics(commit, author) mentioned_issues = commit.all_references(author).issues - Issue::Metrics.where(issue_id: mentioned_issues.map(&:id), first_mentioned_in_commit_at: nil) - .update_all(first_mentioned_in_commit_at: commit.committed_date) + Issue::Metrics.where(issue_id: mentioned_issues.map(&:id), first_mentioned_in_commit_at: nil). + update_all(first_mentioned_in_commit_at: commit.committed_date) end def build_commit(project, hash) diff --git a/app/workers/project_cache_worker.rb b/app/workers/project_cache_worker.rb index 505ff9e086e..8ff9d07860f 100644 --- a/app/workers/project_cache_worker.rb +++ b/app/workers/project_cache_worker.rb @@ -32,8 +32,8 @@ class ProjectCacheWorker private def try_obtain_lease_for(project_id, section) - Gitlab::ExclusiveLease - .new("project_cache_worker:#{project_id}:#{section}", timeout: LEASE_TIMEOUT) - .try_obtain + Gitlab::ExclusiveLease. + new("project_cache_worker:#{project_id}:#{section}", timeout: LEASE_TIMEOUT). + try_obtain end end diff --git a/app/workers/prune_old_events_worker.rb b/app/workers/prune_old_events_worker.rb index cee05b42dd7..392abb9c21b 100644 --- a/app/workers/prune_old_events_worker.rb +++ b/app/workers/prune_old_events_worker.rb @@ -10,9 +10,9 @@ class PruneOldEventsWorker '(id IN (SELECT id FROM (?) ids_to_remove))', Event.unscoped.where( 'created_at < ?', - (12.months + 1.day).ago) - .select(:id) - .limit(10_000) - ).delete_all + (12.months + 1.day).ago). + select(:id). + limit(10_000)). + delete_all end end diff --git a/app/workers/repository_check/batch_worker.rb b/app/workers/repository_check/batch_worker.rb index b94d83bd709..c3e7491ec4e 100644 --- a/app/workers/repository_check/batch_worker.rb +++ b/app/workers/repository_check/batch_worker.rb @@ -32,10 +32,10 @@ module RepositoryCheck # has to sit and wait for this query to finish. def project_ids limit = 10_000 - never_checked_projects = Project.where('last_repository_check_at IS NULL AND created_at < ?', 24.hours.ago) - .limit(limit).pluck(:id) - old_check_projects = Project.where('last_repository_check_at < ?', 1.month.ago) - .reorder('last_repository_check_at ASC').limit(limit).pluck(:id) + never_checked_projects = Project.where('last_repository_check_at IS NULL AND created_at < ?', 24.hours.ago). + limit(limit).pluck(:id) + old_check_projects = Project.where('last_repository_check_at < ?', 1.month.ago). + reorder('last_repository_check_at ASC').limit(limit).pluck(:id) never_checked_projects + old_check_projects end |