Commit 3dadf306 authored by Douwe Maan's avatar Douwe Maan

Enable Style/DotPosition

parent 547063b3
......@@ -136,6 +136,10 @@ Style/DefWithParentheses:
Style/Documentation:
Enabled: false
Style/DotPosition:
Enabled: true
EnforcedStyle: trailing
# Align elses and elsifs correctly.
Style/ElseAlignment:
Enabled: true
......
......@@ -305,13 +305,6 @@ Style/CommentAnnotation:
Style/ConditionalAssignment:
Enabled: false
# Offense count: 1304
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: leading, trailing
Style/DotPosition:
Enabled: false
# Offense count: 21
Style/DoubleNegation:
Exclude:
......
......@@ -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,
......
......@@ -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)
......
......@@ -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)
......
......@@ -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
......
......@@ -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
......
......@@ -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!
......
......@@ -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
......
......@@ -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
......
......@@ -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
}
......
......@@ -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?
......@@ -639,8 +639,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
......
......@@ -7,32 +7,32 @@ 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
@running_count = PipelinesFinder.
.new(project).execute(scope: 'running').count
@pending_count = PipelinesFinder
@pending_count = PipelinesFinder.
.new(project).execute(scope: 'pending').count
@finished_count = PipelinesFinder
@finished_count = PipelinesFinder.
.new(project).execute(scope: 'finished').count
@pipelines_count = PipelinesFinder
@pipelines_count = PipelinesFinder.
.new(project).execute.count
respond_to do |format|
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
......
......@@ -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
......
......@@ -118,8 +118,8 @@ class UsersController < ApplicationController
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
......
......@@ -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)
......
......@@ -63,9 +63,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
......@@ -96,9 +96,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?
......@@ -220,9 +220,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)
......
......@@ -89,9 +89,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))
......@@ -133,16 +133,16 @@ module Ci
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)])
......@@ -222,8 +222,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)
......@@ -355,15 +355,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
......
......@@ -23,8 +23,8 @@ 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
......
......@@ -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
......
......@@ -96,8 +96,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
......@@ -133,9 +133,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
......
......@@ -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
......
module Presentable
def present(**attributes)
Gitlab::View::Presenter::Factory
.new(self, attributes)
.fabricate!
Gitlab::View::Presenter::Factory.
new(self, attributes).
fabricate!
end
end
......@@ -42,15 +42,15 @@ module Subscribable
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
......
......@@ -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
......@@ -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
......
......@@ -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
......
......@@ -34,9 +34,9 @@ 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)
......
......@@ -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
......@@ -39,9 +39,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).