Merge branch 'frozen-string-enable-app-services' into 'master'
Enable frozen string in apps/services/*.rb See merge request gitlab-org/gitlab-ce!20401
This commit is contained in:
commit
2c5e6b272e
48 changed files with 119 additions and 13 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class AccessTokenValidationService
|
class AccessTokenValidationService
|
||||||
# Results:
|
# Results:
|
||||||
VALID = :valid
|
VALID = :valid
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
##
|
##
|
||||||
# Branch can be deleted either by DeleteBranchService
|
# Branch can be deleted either by DeleteBranchService
|
||||||
# or by GitPushService.
|
# or by GitPushService.
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class AkismetService
|
class AkismetService
|
||||||
attr_accessor :owner, :text, :options
|
attr_accessor :owner, :text, :options
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class AuditEventService
|
class AuditEventService
|
||||||
def initialize(author, entity, details = {})
|
def initialize(author, entity, details = {})
|
||||||
@author, @entity, @details = author, entity, details
|
@author, @entity, @details = author, entity, details
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# Base class for services that count a single resource such as the number of
|
# Base class for services that count a single resource such as the number of
|
||||||
# issues for a project.
|
# issues for a project.
|
||||||
class BaseCountService
|
class BaseCountService
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class BaseRenderer
|
class BaseRenderer
|
||||||
attr_reader :current_user
|
attr_reader :current_user
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class BaseService
|
class BaseService
|
||||||
include Gitlab::Allowable
|
include Gitlab::Allowable
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class CohortsService
|
class CohortsService
|
||||||
MONTHS_INCLUDED = 12
|
MONTHS_INCLUDED = 12
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'securerandom'
|
require 'securerandom'
|
||||||
|
|
||||||
# Compare 2 refs for one repo or between repositories
|
# Compare 2 refs for one repo or between repositories
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class CreateBranchService < BaseService
|
class CreateBranchService < BaseService
|
||||||
def execute(branch_name, ref)
|
def execute(branch_name, ref)
|
||||||
create_master_branch if project.empty_repo?
|
create_master_branch if project.empty_repo?
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class CreateDeploymentService
|
class CreateDeploymentService
|
||||||
attr_reader :job
|
attr_reader :job
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class CreateReleaseService < BaseService
|
class CreateReleaseService < BaseService
|
||||||
def execute(tag_name, release_description)
|
def execute(tag_name, release_description)
|
||||||
repository = project.repository
|
repository = project.repository
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class CreateSnippetService < BaseService
|
class CreateSnippetService < BaseService
|
||||||
include SpamCheckService
|
include SpamCheckService
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class DeleteBranchService < BaseService
|
class DeleteBranchService < BaseService
|
||||||
def execute(branch_name)
|
def execute(branch_name)
|
||||||
repository = project.repository
|
repository = project.repository
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class DeleteMergedBranchesService < BaseService
|
class DeleteMergedBranchesService < BaseService
|
||||||
def async_execute
|
def async_execute
|
||||||
DeleteMergedBranchesWorker.perform_async(project.id, current_user.id)
|
DeleteMergedBranchesWorker.perform_async(project.id, current_user.id)
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# EventCreateService class
|
# EventCreateService class
|
||||||
#
|
#
|
||||||
# Used for creating events feed on dashboard after certain user action
|
# Used for creating events feed on dashboard after certain user action
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class GitPushService < BaseService
|
class GitPushService < BaseService
|
||||||
attr_accessor :push_data, :push_commits
|
attr_accessor :push_data, :push_commits
|
||||||
include Gitlab::Access
|
include Gitlab::Access
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class GitTagPushService < BaseService
|
class GitTagPushService < BaseService
|
||||||
attr_accessor :push_data
|
attr_accessor :push_data
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class GravatarService
|
class GravatarService
|
||||||
def execute(email, size = nil, scale = 2, username: nil)
|
def execute(email, size = nil, scale = 2, username: nil)
|
||||||
return unless Gitlab::CurrentSettings.gravatar_enabled?
|
return unless Gitlab::CurrentSettings.gravatar_enabled?
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class HamService
|
class HamService
|
||||||
attr_accessor :spam_log
|
attr_accessor :spam_log
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class ImportExportCleanUpService
|
class ImportExportCleanUpService
|
||||||
LAST_MODIFIED_TIME_IN_MINUTES = 1440
|
LAST_MODIFIED_TIME_IN_MINUTES = 1440
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class IssuableBaseService < BaseService
|
class IssuableBaseService < BaseService
|
||||||
private
|
private
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class MergeRequestMetricsService
|
class MergeRequestMetricsService
|
||||||
delegate :update!, to: :@merge_request_metrics
|
delegate :update!, to: :@merge_request_metrics
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'prometheus/client/formats/text'
|
require 'prometheus/client/formats/text'
|
||||||
|
|
||||||
class MetricsService
|
class MetricsService
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class NoteSummary
|
class NoteSummary
|
||||||
attr_reader :note
|
attr_reader :note
|
||||||
attr_reader :metadata
|
attr_reader :metadata
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
#
|
#
|
||||||
# Used by NotificationService to determine who should receive notification
|
# Used by NotificationService to determine who should receive notification
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# rubocop:disable GitlabSecurity/PublicSend
|
# rubocop:disable GitlabSecurity/PublicSend
|
||||||
|
|
||||||
# NotificationService class
|
# NotificationService class
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class PreviewMarkdownService < BaseService
|
class PreviewMarkdownService < BaseService
|
||||||
def execute
|
def execute
|
||||||
text, commands = explain_quick_actions(params[:text])
|
text, commands = explain_quick_actions(params[:text])
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# Service class for creating push event payloads as stored in the
|
# Service class for creating push event payloads as stored in the
|
||||||
# "push_event_payloads" table.
|
# "push_event_payloads" table.
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class RepairLdapBlockedUserService
|
class RepairLdapBlockedUserService
|
||||||
attr_accessor :user
|
attr_accessor :user
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class RepositoryArchiveCleanUpService
|
class RepositoryArchiveCleanUpService
|
||||||
LAST_MODIFIED_TIME_IN_MINUTES = 120
|
LAST_MODIFIED_TIME_IN_MINUTES = 120
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class ResetProjectCacheService < BaseService
|
class ResetProjectCacheService < BaseService
|
||||||
def execute
|
def execute
|
||||||
@project.increment!(:jobs_cache_index)
|
@project.increment!(:jobs_cache_index)
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class SearchService
|
class SearchService
|
||||||
include Gitlab::Allowable
|
include Gitlab::Allowable
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# SpamCheckService
|
# SpamCheckService
|
||||||
#
|
#
|
||||||
# Provide helper methods for checking if a given spammable object has
|
# Provide helper methods for checking if a given spammable object has
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class SpamService
|
class SpamService
|
||||||
attr_accessor :spammable, :request, :options
|
attr_accessor :spammable, :request, :options
|
||||||
attr_reader :spam_log
|
attr_reader :spam_log
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class SubmitUsagePingService
|
class SubmitUsagePingService
|
||||||
URL = 'https://version.gitlab.com/usage_data'.freeze
|
URL = 'https://version.gitlab.com/usage_data'.freeze
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class SystemHooksService
|
class SystemHooksService
|
||||||
def execute_hooks_for(model, event)
|
def execute_hooks_for(model, event)
|
||||||
data = build_event_data(model, event)
|
data = build_event_data(model, event)
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# SystemNoteService
|
# SystemNoteService
|
||||||
#
|
#
|
||||||
# Used for creating system notes (e.g., when a user references a merge request
|
# Used for creating system notes (e.g., when a user references a merge request
|
||||||
|
@ -21,9 +23,11 @@ module SystemNoteService
|
||||||
total_count = new_commits.length + existing_commits.length
|
total_count = new_commits.length + existing_commits.length
|
||||||
commits_text = "#{total_count} commit".pluralize(total_count)
|
commits_text = "#{total_count} commit".pluralize(total_count)
|
||||||
|
|
||||||
body = "added #{commits_text}\n\n"
|
text_parts = ["added #{commits_text}"]
|
||||||
body << commits_list(noteable, new_commits, existing_commits, oldrev)
|
text_parts << commits_list(noteable, new_commits, existing_commits, oldrev)
|
||||||
body << "\n\n[Compare with previous version](#{diff_comparison_url(noteable, project, oldrev)})"
|
text_parts << "[Compare with previous version](#{diff_comparison_url(noteable, project, oldrev)})"
|
||||||
|
|
||||||
|
body = text_parts.join("\n\n")
|
||||||
|
|
||||||
create_note(NoteSummary.new(noteable, project, author, body, action: 'commit', commit_count: total_count))
|
create_note(NoteSummary.new(noteable, project, author, body, action: 'commit', commit_count: total_count))
|
||||||
end
|
end
|
||||||
|
@ -103,18 +107,19 @@ module SystemNoteService
|
||||||
added_labels = added_labels.map(&references).join(' ')
|
added_labels = added_labels.map(&references).join(' ')
|
||||||
removed_labels = removed_labels.map(&references).join(' ')
|
removed_labels = removed_labels.map(&references).join(' ')
|
||||||
|
|
||||||
body = ''
|
text_parts = []
|
||||||
|
|
||||||
if added_labels.present?
|
if added_labels.present?
|
||||||
body << "added #{added_labels}"
|
text_parts << "added #{added_labels}"
|
||||||
body << ' and ' if removed_labels.present?
|
text_parts << 'and' if removed_labels.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
if removed_labels.present?
|
if removed_labels.present?
|
||||||
body << "removed #{removed_labels}"
|
text_parts << "removed #{removed_labels}"
|
||||||
end
|
end
|
||||||
|
|
||||||
body << ' ' << 'label'.pluralize(labels_count)
|
text_parts << 'label'.pluralize(labels_count)
|
||||||
|
body = text_parts.join(' ')
|
||||||
|
|
||||||
create_note(NoteSummary.new(noteable, project, author, body, action: 'label'))
|
create_note(NoteSummary.new(noteable, project, author, body, action: 'label'))
|
||||||
end
|
end
|
||||||
|
@ -188,8 +193,10 @@ module SystemNoteService
|
||||||
spent_at = noteable.spent_at
|
spent_at = noteable.spent_at
|
||||||
parsed_time = Gitlab::TimeTrackingFormatter.output(time_spent.abs)
|
parsed_time = Gitlab::TimeTrackingFormatter.output(time_spent.abs)
|
||||||
action = time_spent > 0 ? 'added' : 'subtracted'
|
action = time_spent > 0 ? 'added' : 'subtracted'
|
||||||
body = "#{action} #{parsed_time} of time spent"
|
|
||||||
body << " at #{spent_at}" if spent_at
|
text_parts = ["#{action} #{parsed_time} of time spent"]
|
||||||
|
text_parts << "at #{spent_at}" if spent_at
|
||||||
|
body = text_parts.join(' ')
|
||||||
end
|
end
|
||||||
|
|
||||||
create_note(NoteSummary.new(noteable, project, author, body, action: 'time_tracking'))
|
create_note(NoteSummary.new(noteable, project, author, body, action: 'time_tracking'))
|
||||||
|
@ -268,17 +275,19 @@ module SystemNoteService
|
||||||
diff_refs = change_position.diff_refs
|
diff_refs = change_position.diff_refs
|
||||||
version_index = merge_request.merge_request_diffs.viewable.count
|
version_index = merge_request.merge_request_diffs.viewable.count
|
||||||
|
|
||||||
body = "changed this line in"
|
text_parts = ["changed this line in"]
|
||||||
if version_params = merge_request.version_params_for(diff_refs)
|
if version_params = merge_request.version_params_for(diff_refs)
|
||||||
line_code = change_position.line_code(project.repository)
|
line_code = change_position.line_code(project.repository)
|
||||||
url = url_helpers.diffs_project_merge_request_url(project, merge_request, version_params.merge(anchor: line_code))
|
url = url_helpers.diffs_project_merge_request_url(project, merge_request, version_params.merge(anchor: line_code))
|
||||||
|
|
||||||
body << " [version #{version_index} of the diff](#{url})"
|
text_parts << "[version #{version_index} of the diff](#{url})"
|
||||||
else
|
else
|
||||||
body << " version #{version_index} of the diff"
|
text_parts << "version #{version_index} of the diff"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
body = text_parts.join(' ')
|
||||||
note_attributes = discussion.reply_attributes.merge(project: project, author: author, note: body)
|
note_attributes = discussion.reply_attributes.merge(project: project, author: author, note: body)
|
||||||
|
|
||||||
note = Note.create(note_attributes.merge(system: true))
|
note = Note.create(note_attributes.merge(system: true))
|
||||||
note.system_note_metadata = SystemNoteMetadata.new(action: 'outdated')
|
note.system_note_metadata = SystemNoteMetadata.new(action: 'outdated')
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# TodoService class
|
# TodoService class
|
||||||
#
|
#
|
||||||
# Used for creating/updating todos after certain user actions
|
# Used for creating/updating todos after certain user actions
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class UpdateReleaseService < BaseService
|
class UpdateReleaseService < BaseService
|
||||||
def execute(tag_name, release_description)
|
def execute(tag_name, release_description)
|
||||||
repository = project.repository
|
repository = project.repository
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class UpdateSnippetService < BaseService
|
class UpdateSnippetService < BaseService
|
||||||
include SpamCheckService
|
include SpamCheckService
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class UploadService
|
class UploadService
|
||||||
def initialize(model, file, uploader_class = FileUploader, **uploader_context)
|
def initialize(model, file, uploader_class = FileUploader, **uploader_context)
|
||||||
@model, @file, @uploader_class, @uploader_context = model, file, uploader_class, uploader_context
|
@model, @file, @uploader_class, @uploader_context = model, file, uploader_class, uploader_context
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class UserAgentDetailService
|
class UserAgentDetailService
|
||||||
attr_accessor :spammable, :request
|
attr_accessor :spammable, :request
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class UserProjectAccessChangedService
|
class UserProjectAccessChangedService
|
||||||
def initialize(user_ids)
|
def initialize(user_ids)
|
||||||
@user_ids = Array.wrap(user_ids)
|
@user_ids = Array.wrap(user_ids)
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require_relative 'base_service'
|
require_relative 'base_service'
|
||||||
|
|
||||||
class ValidateNewBranchService < BaseService
|
class ValidateNewBranchService < BaseService
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'resolv'
|
require 'resolv'
|
||||||
|
|
||||||
class VerifyPagesDomainService < BaseService
|
class VerifyPagesDomainService < BaseService
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class WebHookService
|
class WebHookService
|
||||||
class InternalErrorResponse
|
class InternalErrorResponse
|
||||||
attr_reader :body, :headers, :code
|
attr_reader :body, :headers, :code
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Enable frozen string in apps/uploaders/*.rb
|
||||||
|
merge_request: 20401
|
||||||
|
author: gfyoung
|
||||||
|
type: other
|
Loading…
Reference in a new issue