Commit 2c5e6b27 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'frozen-string-enable-app-services' into 'master'

Enable frozen string in apps/services/*.rb

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