Enable frozen string in apps/uploaders/*.rb

Partially addresses #47424.
This commit is contained in:
gfyoung 2018-07-05 03:18:17 -07:00
parent 05af376805
commit ddca49e4b5
48 changed files with 119 additions and 13 deletions

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AccessTokenValidationService
# Results:
VALID = :valid

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
##
# Branch can be deleted either by DeleteBranchService
# or by GitPushService.

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AkismetService
attr_accessor :owner, :text, :options

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AuditEventService
def initialize(author, entity, details = {})
@author, @entity, @details = author, entity, details

View file

@ -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

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class BaseRenderer
attr_reader :current_user

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class BaseService
include Gitlab::Allowable

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class CohortsService
MONTHS_INCLUDED = 12

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'securerandom'
# Compare 2 refs for one repo or between repositories

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class CreateBranchService < BaseService
def execute(branch_name, ref)
create_master_branch if project.empty_repo?

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class CreateDeploymentService
attr_reader :job

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class CreateReleaseService < BaseService
def execute(tag_name, release_description)
repository = project.repository

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class CreateSnippetService < BaseService
include SpamCheckService

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class DeleteBranchService < BaseService
def execute(branch_name)
repository = project.repository

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class DeleteMergedBranchesService < BaseService
def async_execute
DeleteMergedBranchesWorker.perform_async(project.id, current_user.id)

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
# EventCreateService class
#
# Used for creating events feed on dashboard after certain user action

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class GitPushService < BaseService
attr_accessor :push_data, :push_commits
include Gitlab::Access

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class GitTagPushService < BaseService
attr_accessor :push_data

View file

@ -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?

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class HamService
attr_accessor :spam_log

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ImportExportCleanUpService
LAST_MODIFIED_TIME_IN_MINUTES = 1440

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class IssuableBaseService < BaseService
private

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class MergeRequestMetricsService
delegate :update!, to: :@merge_request_metrics

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'prometheus/client/formats/text'
class MetricsService

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class NoteSummary
attr_reader :note
attr_reader :metadata

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
#
# Used by NotificationService to determine who should receive notification
#

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
# rubocop:disable GitlabSecurity/PublicSend
# NotificationService class

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class PreviewMarkdownService < BaseService
def execute
text, commands = explain_quick_actions(params[:text])

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
# Service class for creating push event payloads as stored in the
# "push_event_payloads" table.
#

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class RepairLdapBlockedUserService
attr_accessor :user

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class RepositoryArchiveCleanUpService
LAST_MODIFIED_TIME_IN_MINUTES = 120

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ResetProjectCacheService < BaseService
def execute
@project.increment!(:jobs_cache_index)

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class SearchService
include Gitlab::Allowable

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
# SpamCheckService
#
# Provide helper methods for checking if a given spammable object has

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class SpamService
attr_accessor :spammable, :request, :options
attr_reader :spam_log

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class SubmitUsagePingService
URL = 'https://version.gitlab.com/usage_data'.freeze

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class SystemHooksService
def execute_hooks_for(model, event)
data = build_event_data(model, event)

View file

@ -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')

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
# TodoService class
#
# Used for creating/updating todos after certain user actions

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class UpdateReleaseService < BaseService
def execute(tag_name, release_description)
repository = project.repository

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class UpdateSnippetService < BaseService
include SpamCheckService

View file

@ -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

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class UserAgentDetailService
attr_accessor :spammable, :request

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class UserProjectAccessChangedService
def initialize(user_ids)
@user_ids = Array.wrap(user_ids)

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require_relative 'base_service'
class ValidateNewBranchService < BaseService

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'resolv'
class VerifyPagesDomainService < BaseService

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class WebHookService
class InternalErrorResponse
attr_reader :body, :headers, :code

View file

@ -0,0 +1,5 @@
---
title: Enable frozen string in apps/uploaders/*.rb
merge_request: 20401
author: gfyoung
type: other