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
|
||||
# Results:
|
||||
VALID = :valid
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
##
|
||||
# Branch can be deleted either by DeleteBranchService
|
||||
# or by GitPushService.
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AkismetService
|
||||
attr_accessor :owner, :text, :options
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AuditEventService
|
||||
def initialize(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
|
||||
# issues for a project.
|
||||
class BaseCountService
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class BaseRenderer
|
||||
attr_reader :current_user
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class BaseService
|
||||
include Gitlab::Allowable
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CohortsService
|
||||
MONTHS_INCLUDED = 12
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'securerandom'
|
||||
|
||||
# Compare 2 refs for one repo or between repositories
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateBranchService < BaseService
|
||||
def execute(branch_name, ref)
|
||||
create_master_branch if project.empty_repo?
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateDeploymentService
|
||||
attr_reader :job
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateReleaseService < BaseService
|
||||
def execute(tag_name, release_description)
|
||||
repository = project.repository
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateSnippetService < BaseService
|
||||
include SpamCheckService
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DeleteBranchService < BaseService
|
||||
def execute(branch_name)
|
||||
repository = project.repository
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DeleteMergedBranchesService < BaseService
|
||||
def async_execute
|
||||
DeleteMergedBranchesWorker.perform_async(project.id, current_user.id)
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# EventCreateService class
|
||||
#
|
||||
# Used for creating events feed on dashboard after certain user action
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class GitPushService < BaseService
|
||||
attr_accessor :push_data, :push_commits
|
||||
include Gitlab::Access
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class GitTagPushService < BaseService
|
||||
attr_accessor :push_data
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class GravatarService
|
||||
def execute(email, size = nil, scale = 2, username: nil)
|
||||
return unless Gitlab::CurrentSettings.gravatar_enabled?
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class HamService
|
||||
attr_accessor :spam_log
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ImportExportCleanUpService
|
||||
LAST_MODIFIED_TIME_IN_MINUTES = 1440
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class IssuableBaseService < BaseService
|
||||
private
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class MergeRequestMetricsService
|
||||
delegate :update!, to: :@merge_request_metrics
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'prometheus/client/formats/text'
|
||||
|
||||
class MetricsService
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class NoteSummary
|
||||
attr_reader :note
|
||||
attr_reader :metadata
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
#
|
||||
# Used by NotificationService to determine who should receive notification
|
||||
#
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# rubocop:disable GitlabSecurity/PublicSend
|
||||
|
||||
# NotificationService class
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class PreviewMarkdownService < BaseService
|
||||
def execute
|
||||
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
|
||||
# "push_event_payloads" table.
|
||||
#
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RepairLdapBlockedUserService
|
||||
attr_accessor :user
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RepositoryArchiveCleanUpService
|
||||
LAST_MODIFIED_TIME_IN_MINUTES = 120
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ResetProjectCacheService < BaseService
|
||||
def execute
|
||||
@project.increment!(:jobs_cache_index)
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class SearchService
|
||||
include Gitlab::Allowable
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# SpamCheckService
|
||||
#
|
||||
# Provide helper methods for checking if a given spammable object has
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class SpamService
|
||||
attr_accessor :spammable, :request, :options
|
||||
attr_reader :spam_log
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class SubmitUsagePingService
|
||||
URL = 'https://version.gitlab.com/usage_data'.freeze
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class SystemHooksService
|
||||
def execute_hooks_for(model, event)
|
||||
data = build_event_data(model, event)
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# 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')
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# TodoService class
|
||||
#
|
||||
# Used for creating/updating todos after certain user actions
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class UpdateReleaseService < BaseService
|
||||
def execute(tag_name, release_description)
|
||||
repository = project.repository
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class UpdateSnippetService < BaseService
|
||||
include SpamCheckService
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# 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
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class UserAgentDetailService
|
||||
attr_accessor :spammable, :request
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class UserProjectAccessChangedService
|
||||
def initialize(user_ids)
|
||||
@user_ids = Array.wrap(user_ids)
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require_relative 'base_service'
|
||||
|
||||
class ValidateNewBranchService < BaseService
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'resolv'
|
||||
|
||||
class VerifyPagesDomainService < BaseService
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class WebHookService
|
||||
class InternalErrorResponse
|
||||
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