Enable more frozen string in app/services/**/*.rb

Partially addresses #47424.
This commit is contained in:
gfyoung 2018-07-17 09:50:37 -07:00
parent 489025bbdd
commit fbde835404
99 changed files with 207 additions and 3 deletions

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Lfs
# Usage: Calling `new_file` check to see if a file should be in LFS and
# return a transformed result with `content` and `encoding` to commit.

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Lfs
class LockFileService < BaseService
def execute

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Lfs
class LocksFinderService < BaseService
def execute

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Lfs
class UnlockFileService < BaseService
def execute

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Mattermost
class CreateTeamService < ::BaseService
def initialize(group, current_user)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Members
class ApproveAccessRequestService < Members::BaseService
def execute(access_requester, skip_authorization: false, skip_log_audit_event: false)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Members
class BaseService < ::BaseService
# current_user - The user that performs the action

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Members
class CreateService < Members::BaseService
DEFAULT_LIMIT = 100

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Members
class DestroyService < Members::BaseService
def execute(member, skip_authorization: false)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Members
class RequestAccessService < Members::BaseService
def execute(source)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Members
class UpdateService < Members::BaseService
# returns the updated member

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module MergeRequests
class AddTodoWhenBuildFailsService < MergeRequests::BaseService
# Adds a todo to the parent merge_request when a CI build fails

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module MergeRequests
class AssignIssuesService < BaseService
def assignable_issues

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module MergeRequests
class BaseService < ::IssuableBaseService
def create_note(merge_request, state = merge_request.state)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module MergeRequests
class BuildService < MergeRequests::BaseService
include Gitlab::Utils::StrongMemoize
@ -140,7 +142,8 @@ module MergeRequests
closes_issue = "Closes #{issue.to_reference}"
if description.present?
merge_request.description += closes_issue.prepend("\n\n")
descr_parts = [merge_request.description, closes_issue]
merge_request.description = descr_parts.join("\n\n")
else
merge_request.description = closes_issue
end
@ -164,9 +167,11 @@ module MergeRequests
return if merge_request.title.present?
if issue_iid.present?
merge_request.title = "Resolve #{issue.to_reference}"
title_parts = ["Resolve #{issue.to_reference}"]
branch_title = source_branch.downcase.remove(issue_iid.downcase).titleize.humanize
merge_request.title += " \"#{branch_title}\"" if branch_title.present?
title_parts << "\"#{branch_title}\"" if branch_title.present?
merge_request.title = title_parts.join(' ')
end
end

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module MergeRequests
class CloseService < MergeRequests::BaseService
def execute(merge_request, commit = nil)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module MergeRequests
module Conflicts
class BaseService

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module MergeRequests
module Conflicts
class ListService < MergeRequests::Conflicts::BaseService

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module MergeRequests
module Conflicts
class ResolveService < MergeRequests::Conflicts::BaseService

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module MergeRequests
class CreateFromIssueService < MergeRequests::CreateService
def initialize(project, user, params)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module MergeRequests
class CreateService < MergeRequests::BaseService
def execute

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module MergeRequests
class DeleteNonLatestDiffsService
BATCH_SIZE = 10

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module MergeRequests
# MergeService class
#

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module MergeRequests
class GetUrlsService < BaseService
attr_reader :project

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module MergeRequests
# MergeService class
#

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module MergeRequests
class MergeWhenPipelineSucceedsService < MergeRequests::BaseService
# Marks the passed `merge_request` to be merged when the pipeline succeeds or

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module MergeRequests
# PostMergeService class
#

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module MergeRequests
class RebaseService < MergeRequests::WorkingCopyBaseService
REBASE_ERROR = 'Rebase failed. Please rebase locally'.freeze

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module MergeRequests
class RefreshService < MergeRequests::BaseService
def execute(oldrev, newrev, ref)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module MergeRequests
class ReloadDiffsService
def initialize(merge_request, current_user)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module MergeRequests
class ReopenService < MergeRequests::BaseService
def execute(merge_request)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module MergeRequests
class ResolvedDiscussionNotificationService < MergeRequests::BaseService
def execute(merge_request)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module MergeRequests
class SquashService < MergeRequests::WorkingCopyBaseService
def execute(merge_request)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module MergeRequests
class UpdateService < MergeRequests::BaseService
def execute(merge_request)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module MergeRequests
class WorkingCopyBaseService < MergeRequests::BaseService
attr_reader :merge_request

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Milestones
class BaseService < ::BaseService
# Parent can either a group or a project

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Milestones
class CloseService < Milestones::BaseService
def execute(milestone)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Milestones
class CreateService < Milestones::BaseService
def execute

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Milestones
class DestroyService < Milestones::BaseService
def execute(milestone)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Milestones
class PromoteService < Milestones::BaseService
PromoteMilestoneError = Class.new(StandardError)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Milestones
class ReopenService < Milestones::BaseService
def execute(milestone)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Milestones
class UpdateService < Milestones::BaseService
def execute(milestone)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Notes
class BuildService < ::BaseService
def execute

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Notes
class CreateService < ::BaseService
def execute

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Notes
class DestroyService < BaseService
def execute(note)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Notes
class PostProcessService
attr_accessor :note

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Notes
class QuickActionsService < BaseService
UPDATE_SERVICES = {

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Notes
class RenderService < BaseRenderer
# Renders a collection of Note instances.

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Notes
class ResolveService < ::BaseService
def execute(note)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Notes
class UpdateService < BaseService
def execute(note)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
class AfterImportService
RESERVED_REF_PREFIXES = Repository::RESERVED_REFS_NAMES.map { |n| File.join('refs', n, '/') }

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
class AutocompleteService < BaseService
def issues

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
class BaseMoveRelationsService < BaseService
attr_reader :source_project

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
# Service class for getting and caching the number of elements of several projects
# Warning: do not user this service with a really large set of projects
# because the service use maps to retrieve the project ids.

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
# Service class for getting and caching the number of forks of several projects
# Warning: do not user this service with a really large set of projects
# because the service use maps to retrieve the project ids

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
# Service class for getting and caching the number of issues of several projects
# Warning: do not user this service with a really large set of projects
# because the service use maps to retrieve the project ids

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
# Base class for the various service classes that count project data (e.g.
# issues or forks).

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
class CreateFromTemplateService < BaseService
def initialize(user, params)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
class CreateService < BaseService
def initialize(user, params)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
class DestroyService < BaseService
include Gitlab::ShellAdapter

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
class DownloadService < BaseService
WHITELIST = [

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
class EnableDeployKeyService < BaseService
def execute

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
class ForkService < BaseService
def execute(fork_to_project = nil)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
# Service class for getting and caching the number of forks of a project.
class ForksCountService < Projects::CountService

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
# This service is an adapter used to for the GitLab Import feature, and
# creating a project from a template.
# The latter will under the hood just import an archive supplied by GitLab.

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
module GroupLinks
class CreateService < BaseService

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
module GroupLinks
class DestroyService < BaseService

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
module HashedStorage
AttachmentMigrationError = Class.new(StandardError)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
module HashedStorage
class MigrateRepositoryService < BaseService

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
class HashedStorageMigrationService < BaseService
attr_reader :logger

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
# Projects::HousekeepingService class
#
# Used for git housekeeping

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
module ImportExport
class ExportService < BaseService

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
class ImportService < BaseService
include Gitlab::ShellAdapter

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
# This service lists the download link from a remote source based on the
# oids provided
module Projects

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
# This service downloads and links lfs objects from a remote URL
module Projects
module LfsPointers

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
# This service manages the whole worflow of discovering the Lfs files in a
# repository, linking them to the project and downloading (and linking) the non
# existent ones.

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
# Given a list of oids, this services links the existent Lfs Objects to the project
module Projects
module LfsPointers

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
# This service list all existent Lfs objects in a repository
module Projects
module LfsPointers

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
class MoveAccessService < BaseMoveRelationsService
def execute(source_project, remove_remaining_elements: true)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
class MoveDeployKeysProjectsService < BaseMoveRelationsService
def execute(source_project, remove_remaining_elements: true)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
class MoveForksService < BaseMoveRelationsService
def execute(source_project, remove_remaining_elements: true)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
class MoveLfsObjectsProjectsService < BaseMoveRelationsService
def execute(source_project, remove_remaining_elements: true)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
class MoveNotificationSettingsService < BaseMoveRelationsService
def execute(source_project, remove_remaining_elements: true)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
# NOTE: This service cannot be used directly because it is part of a
# a bigger process. Instead, use the service MoveAccessService which moves
# project memberships, project group links, authorizations and refreshes

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
# NOTE: This service cannot be used directly because it is part of a
# a bigger process. Instead, use the service MoveAccessService which moves
# project memberships, project group links, authorizations and refreshes

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
# NOTE: This service cannot be used directly because it is part of a
# a bigger process. Instead, use the service MoveAccessService which moves
# project memberships, project group links, authorizations and refreshes

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
class MoveUsersStarProjectsService < BaseMoveRelationsService
def execute(source_project, remove_remaining_elements: true)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
# Service class for counting and caching the number of open issues of a
# project.

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
# Service class for counting and caching the number of open merge requests of
# a project.

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
class OverwriteProjectService < BaseService
def execute(source_project)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
class ParticipantsService < BaseService
include Users::ParticipableService

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
class PropagateServiceTemplate
BATCH_SIZE = 100

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
# Projects::TransferService class
#
# Used for transfer project to another namespace

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
class UnlinkForkService < BaseService
def execute

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
class UpdatePagesConfigurationService < BaseService
attr_reader :project

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
class UpdatePagesService < BaseService
InvalidStateError = Class.new(StandardError)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
class UpdateRemoteMirrorService < BaseService
attr_reader :errors

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
class UpdateService < BaseService
include UpdateVisibilityLevel

View File

@ -0,0 +1,5 @@
---
title: Enable more frozen string in app/services/**/*.rb
merge_request: 20677
author: gfyoung
type: performance