Commit 8495952f authored by gfyoung's avatar gfyoung

Enable frozen string in app/models/*.rb

Partially addresses #47424.
parent 0399de90
# frozen_string_literal: true
class Admin::ServicesController < Admin::ApplicationController
include ServiceParams
......@@ -30,7 +32,7 @@ class Admin::ServicesController < Admin::ApplicationController
def services_templates
Service.available_services_names.map do |service_name|
service_template = service_name.concat("_service").camelize.constantize
service_template = "#{service_name}_service".camelize.constantize
service_template.where(template: true).first_or_create
end
end
......
# frozen_string_literal: true
require_dependency 'declarative_policy'
class Ability
......
# frozen_string_literal: true
class AbuseReport < ActiveRecord::Base
include CacheMarkdownField
......
# frozen_string_literal: true
class ActiveSession
include ActiveModel::Model
......
# frozen_string_literal: true
class Appearance < ActiveRecord::Base
include CacheableAttributes
include CacheMarkdownField
......
# frozen_string_literal: true
class ApplicationSetting < ActiveRecord::Base
include CacheableAttributes
include CacheMarkdownField
......
# frozen_string_literal: true
class AuditEvent < ActiveRecord::Base
prepend EE::AuditEvent
......
# frozen_string_literal: true
class AwardEmoji < ActiveRecord::Base
DOWNVOTE_NAME = "thumbsdown".freeze
UPVOTE_NAME = "thumbsup".freeze
......
# frozen_string_literal: true
class Badge < ActiveRecord::Base
# This structure sets the placeholders that the urls
# can have. This hash also sets which action to ask when
......
# frozen_string_literal: true
# Blob is a Rails-specific wrapper around Gitlab::Git::Blob objects
class Blob < SimpleDelegator
CACHE_TIME = 60 # Cache raw blobs referred to by a (mutable) ref for 1 minute
......
# frozen_string_literal: true
class Board < ActiveRecord::Base
prepend EE::Board
......
# frozen_string_literal: true
class BroadcastMessage < ActiveRecord::Base
prepend EE::BroadcastMessage
include CacheMarkdownField
......
# frozen_string_literal: true
class ChatName < ActiveRecord::Base
LAST_USED_AT_INTERVAL = 1.hour
......
# frozen_string_literal: true
class ChatTeam < ActiveRecord::Base
validates :team_id, presence: true
validates :namespace, uniqueness: true
......
# coding: utf-8
# frozen_string_literal: true
class Commit
extend ActiveModel::Naming
extend Gitlab::Cache::RequestCache
......@@ -339,21 +341,21 @@ class Commit
end
def cherry_pick_description(user)
message_body = "(cherry picked from commit #{sha})"
message_body = ["(cherry picked from commit #{sha})"]
if merged_merge_request?(user)
commits_in_merge_request = merged_merge_request(user).commits
if commits_in_merge_request.present?
message_body << "\n"
message_body << ""
commits_in_merge_request.reverse.each do |commit_in_merge|
message_body << "\n#{commit_in_merge.short_id} #{commit_in_merge.title}"
message_body << "#{commit_in_merge.short_id} #{commit_in_merge.title}"
end
end
end
message_body
message_body.join("\n")
end
def cherry_pick_message(user)
......
# frozen_string_literal: true
# CommitRange makes it easier to work with commit ranges
#
# Examples:
......
# frozen_string_literal: true
class CommitStatus < ActiveRecord::Base
include HasStatus
include Importable
......
# frozen_string_literal: true
class Compare
include Gitlab::Utils::StrongMemoize
......
# frozen_string_literal: true
class ContainerRepository < ActiveRecord::Base
belongs_to :project
......
# frozen_string_literal: true
class CycleAnalytics
STAGES = %i[issue plan code test review staging production].freeze
......
# frozen_string_literal: true
class DashboardMilestone < GlobalMilestone
def issues_finder_params
{ authorized_only: true }
......
# frozen_string_literal: true
class DeployKey < Key
include IgnorableColumn
......
# frozen_string_literal: true
class DeployKeysProject < ActiveRecord::Base
belongs_to :project
belongs_to :deploy_key, inverse_of: :deploy_keys_projects
......
# frozen_string_literal: true
class DeployToken < ActiveRecord::Base
include Expirable
include TokenAuthenticatable
......
# frozen_string_literal: true
class Deployment < ActiveRecord::Base
include AtomicInternalId
include IidRoutes
......
# frozen_string_literal: true
# A discussion on merge request or commit diffs consisting of `DiffNote` notes.
#
# A discussion of this type can be resolvable.
......
# frozen_string_literal: true
# A note on merge request or commit diffs
#
# A note of this type can be resolvable.
......
# frozen_string_literal: true
class DirectlyAddressedUser
class << self
def reference_pattern
......
# frozen_string_literal: true
# A non-diff discussion on an issue, merge request, commit, or snippet, consisting of `DiscussionNote` notes.
#
# A discussion of this type can be resolvable.
......
# frozen_string_literal: true
# A note in a non-diff discussion on an issue, merge request, commit, or snippet.
#
# A note of this type can be resolvable.
......
# frozen_string_literal: true
class Email < ActiveRecord::Base
include Sortable
include Gitlab::SQL::Pattern
......
# frozen_string_literal: true
class Environment < ActiveRecord::Base
prepend EE::Environment
......@@ -179,7 +181,7 @@ class Environment < ActiveRecord::Base
# * cannot end with `-`
def generate_slug
# Lowercase letters and numbers only
slugified = name.to_s.downcase.gsub(/[^a-z0-9]/, '-')
slugified = +name.to_s.downcase.gsub(/[^a-z0-9]/, '-')
# Must start with a letter
slugified = 'env-' + slugified unless LETTERS.cover?(slugified[0])
......
# frozen_string_literal: true
# Placeholder class for model that is implemented in EE
# It reserves '&' as a reference prefix, but the table does not exists in CE
class Epic < ActiveRecord::Base
......
# frozen_string_literal: true
class Event < ActiveRecord::Base
include Sortable
include IgnorableColumn
......
# frozen_string_literal: true
# A collection of events to display in an event list.
#
# An EventCollection is meant to be used for displaying events to a user (e.g.
......
# frozen_string_literal: true
class ExternalIssue
include Referable
......
# frozen_string_literal: true
class ForkNetwork < ActiveRecord::Base
belongs_to :root_project, class_name: 'Project'
has_many :fork_network_members
......
# frozen_string_literal: true
class ForkNetworkMember < ActiveRecord::Base
belongs_to :fork_network
belongs_to :project
......
# frozen_string_literal: true
class ForkedProjectLink < ActiveRecord::Base
belongs_to :forked_to_project, -> { where.not(pending_delete: true) }, class_name: 'Project'
belongs_to :forked_from_project, -> { where.not(pending_delete: true) }, class_name: 'Project'
......
# frozen_string_literal: true
class GenericCommitStatus < CommitStatus
before_validation :set_default_values
......
# frozen_string_literal: true
class GlobalLabel
attr_accessor :title, :labels
alias_attribute :name, :title
......
# frozen_string_literal: true
class GlobalMilestone
include Milestoneish
......
# frozen_string_literal: true
class GpgKey < ActiveRecord::Base
KEY_PREFIX = '-----BEGIN PGP PUBLIC KEY BLOCK-----'.freeze
KEY_SUFFIX = '-----END PGP PUBLIC KEY BLOCK-----'.freeze
......
# frozen_string_literal: true
class GpgKeySubkey < ActiveRecord::Base
include ShaAttribute
......
# frozen_string_literal: true
class GpgSignature < ActiveRecord::Base
include ShaAttribute
......
# frozen_string_literal: true
require 'carrierwave/orm/activerecord'
class Group < Namespace
......
# frozen_string_literal: true
class GroupCustomAttribute < ActiveRecord::Base
belongs_to :group
......
# frozen_string_literal: true
class GroupLabel < Label
belongs_to :group
......
# frozen_string_literal: true
class GroupMilestone < GlobalMilestone
include ::EE::GroupMilestone
......
# frozen_string_literal: true
class Guest
class << self
def can?(action, subject = :global)
......
# frozen_string_literal: true
class Identity < ActiveRecord::Base
def self.uniqueness_scope
:provider
......
# frozen_string_literal: true
class ImportExportUpload < ActiveRecord::Base
include WithUploads
include ObjectStorage::BackgroundMove
......
# frozen_string_literal: true
# A discussion to wrap a single `Note` note on the root of an issue, merge request,
# commit, or snippet, that is not displayed as a discussion.
#
......
# frozen_string_literal: true
require 'resolv'
class InstanceConfiguration
......
# frozen_string_literal: true
# An InternalId is a strictly monotone sequence of integers
# generated for a given scope and usage.
#
......
# frozen_string_literal: true
require 'carrierwave/orm/activerecord'
class Issue < ActiveRecord::Base
......
# frozen_string_literal: true
class IssueAssignee < ActiveRecord::Base
belongs_to :issue
belongs_to :assignee, class_name: "User", foreign_key: :user_id
......
# frozen_string_literal: true
# IssueCollection can be used to reduce a list of issues down to a subset.
#
# IssueCollection is not meant to be some sort of Enumerable, instead it's meant
......
# frozen_string_literal: true
require 'digest/md5'
class Key < ActiveRecord::Base
......
# frozen_string_literal: true
class Label < ActiveRecord::Base
include CacheMarkdownField
include Referable
......
# frozen_string_literal: true
class LabelLink < ActiveRecord::Base
include Importable
......
# frozen_string_literal: true
class LabelPriority < ActiveRecord::Base
belongs_to :project
belongs_to :label
......
# frozen_string_literal: true
# A discussion on merge request or commit diffs consisting of `LegacyDiffNote` notes.
#
# All new diff discussions are of the type `DiffDiscussion`, but any diff discussions created
......
# frozen_string_literal: true
# A note on merge request or commit diffs, using the legacy implementation.
#
# All new diff notes are of the type `DiffNote`, but any diff notes created
......
# frozen_string_literal: true
class LfsFileLock < ActiveRecord::Base
belongs_to :project
belongs_to :user
......
# frozen_string_literal: true
class LfsObject < ActiveRecord::Base
prepend EE::LfsObject
include AfterCommitQueue
......
# frozen_string_literal: true
class LfsObjectsProject < ActiveRecord::Base
belongs_to :project
belongs_to :lfs_object
......
# frozen_string_literal: true
class List < ActiveRecord::Base
prepend ::EE::List
......
# frozen_string_literal: true
class Member < ActiveRecord::Base
include AfterCommitQueue
include Sortable
......
# frozen_string_literal: true
class MergeRequest < ActiveRecord::Base
include AtomicInternalId
include IidRoutes
......
# frozen_string_literal: true
class MergeRequestDiff < ActiveRecord::Base
include Sortable
include Importable
......
# frozen_string_literal: true
class MergeRequestDiffCommit < ActiveRecord::Base
include ShaAttribute
......
# frozen_string_literal: true
class MergeRequestDiffFile < ActiveRecord::Base
include Gitlab::EncodingHelper
include DiffFile
......
# frozen_string_literal: true
class MergeRequestsClosingIssues < ActiveRecord::Base
belongs_to :merge_request
belongs_to :issue
......
# frozen_string_literal: true
class Milestone < ActiveRecord::Base
# Represents a "No Milestone" state used for filtering Issues and Merge
# Requests that have no milestone assigned.
......
# frozen_string_literal: true
class Namespace < ActiveRecord::Base
prepend EE::Namespace
include CacheMarkdownField
......
# frozen_string_literal: true
# A note on the root of an issue, merge request, commit, or snippet.
#
# A note of this type is never resolvable.
......
# frozen_string_literal: true
class NoteDiffFile < ActiveRecord::Base
include DiffFile
......
# frozen_string_literal: true
# Holds reasons for a notification to have been sent as well as a priority list to select which reason to use
# above the rest
class NotificationReason
......
# frozen_string_literal: true
class NotificationRecipient
include Gitlab::Utils::StrongMemoize
......
# frozen_string_literal: true
class NotificationSetting < ActiveRecord::Base
include IgnorableColumn
......
# frozen_string_literal: true
class OauthAccessGrant < Doorkeeper::AccessGrant
belongs_to :resource_owner, class_name: 'User'
belongs_to :application, class_name: 'Doorkeeper::Application'
......
# frozen_string_literal: true
class OauthAccessToken < Doorkeeper::AccessToken
belongs_to :resource_owner, class_name: 'User'
belongs_to :application, class_name: 'Doorkeeper::Application'
......
# frozen_string_literal: true
# When notes on a commit are displayed in the context of a merge request that
# contains that commit, they are displayed as if they were a discussion.
#
......
# frozen_string_literal: true
class PagesDomain < ActiveRecord::Base
VERIFICATION_KEY = 'gitlab-pages-verification-code'.freeze
VERIFICATION_THRESHOLD = 3.days.freeze
......
# frozen_string_literal: true
class PersonalAccessToken < ActiveRecord::Base
include Expirable
include TokenAuthenticatable
......
# frozen_string_literal: true
class PersonalSnippet < Snippet
# Elastic search configuration (it does not support STI)
document_type 'snippet'
......
# frozen_string_literal: true
require 'carrierwave/orm/activerecord'
class Project < ActiveRecord::Base
......
# frozen_string_literal: true
class ProjectAuthorization < ActiveRecord::Base
prepend ::EE::ProjectAuthorization
......
# frozen_string_literal: true
class ProjectAutoDevops < ActiveRecord::Base
belongs_to :project
......
# frozen_string_literal: true
class ProjectCiCdSetting < ActiveRecord::Base
belongs_to :project, inverse_of: :ci_cd_settings
......
# frozen_string_literal: true
class ProjectCustomAttribute < ActiveRecord::Base
belongs_to :project
......
# frozen_string_literal: true
class ProjectDeployToken < ActiveRecord::Base
belongs_to :project
belongs_to :deploy_token, inverse_of: :project_deploy_tokens
......
# frozen_string_literal: true
class ProjectFeature < ActiveRecord::Base
# == Project features permissions
#
......
# frozen_string_literal: true
class ProjectGroupLink < ActiveRecord::Base
include Expirable
......
# frozen_string_literal: true
require 'carrierwave/orm/activerecord'
class ProjectImportData < ActiveRecord::Base
......
# frozen_string_literal: true
class ProjectImportState < ActiveRecord::Base
include AfterCommitQueue
......
# frozen_string_literal: true
class ProjectLabel < Label
MAX_NUMBER_OF_PRIORITIES = 1
......
# frozen_string_literal: true
class ProjectSnippet < Snippet
# Elastic search configuration (it does not support STI)
document_type 'snippet'
......
# frozen_string_literal: true
class ProjectStatistics < ActiveRecord::Base
belongs_to :project
belongs_to :namespace
......
# frozen_string_literal: true
class ProjectTeam
include BulkMemberAccessLoad
......
# frozen_string_literal: true
class ProtectableDropdown
REF_TYPES = %i[branches tags].freeze
......
# frozen_string_literal: true
class ProtectedBranch < ActiveRecord::Base
include Gitlab::ShellAdapter
include ProtectedRef
......
# frozen_string_literal: true
class ProtectedRefMatcher
def initialize(protected_ref)
@protected_ref = protected_ref
......
# frozen_string_literal: true
class ProtectedTag < ActiveRecord::Base
include Gitlab::ShellAdapter
include ProtectedRef
......
# frozen_string_literal: true
class PushEvent < Event
# This validation exists so we can't accidentally use PushEvent with a
# different "action" value.
......
# frozen_string_literal: true
class PushEventPayload < ActiveRecord::Base
include ShaAttribute
......
# frozen_string_literal: true
class ReadmeBlob < SimpleDelegator
attr_reader :repository
......
# frozen_string_literal: true
class RedirectRoute < ActiveRecord::Base
belongs_to :source, polymorphic: true # rubocop:disable Cop/PolymorphicAssociations
......
# frozen_string_literal: true
class Release < ActiveRecord::Base
include CacheMarkdownField
......
# frozen_string_literal: true
class RemoteMirror < ActiveRecord::Base
include AfterCommitQueue
......
# coding: utf-8
# frozen_string_literal: true
require 'securerandom'
require 'forwardable'
......
# frozen_string_literal: true
class Route < ActiveRecord::Base
include CaseSensitivity
......
# frozen_string_literal: true
class SecurityEvent < AuditEvent
end
# frozen_string_literal: true
class SentNotification < ActiveRecord::Base
serialize :position, Gitlab::Diff::Position # rubocop:disable Cop/ActiveRecordSerialize
......
# frozen_string_literal: true
# To add new service you should build a class inherited from Service
# and implement a set of methods
class Service < ActiveRecord::Base
......
# frozen_string_literal: true
class Snippet < ActiveRecord::Base
include Gitlab::VisibilityLevel
include CacheMarkdownField
......
# frozen_string_literal: true
class SnippetBlob
include BlobLike
......
# frozen_string_literal: true
class SpamLog < ActiveRecord::Base
belongs_to :user
......
# frozen_string_literal: true
class Subscription < ActiveRecord::Base
belongs_to :user
belongs_to :project
......
# frozen_string_literal: true
class SystemNoteMetadata < ActiveRecord::Base
prepend EE::SystemNoteMetadata
......
# frozen_string_literal: true
class TermAgreement < ActiveRecord::Base
belongs_to :term, class_name: 'ApplicationSetting::Term'
belongs_to :user
......
# frozen_string_literal: true
class Timelog < ActiveRecord::Base
validates :time_spent, :user, presence: true
validate :issuable_id_is_present
......
# frozen_string_literal: true
class Todo < ActiveRecord::Base
include Sortable
......
# frozen_string_literal: true
class Tree
include Gitlab::MarkupHelper
......
# frozen_string_literal: true
class TrendingProject < ActiveRecord::Base
belongs_to :project
......
# frozen_string_literal: true
# Registration information for U2F (universal 2nd factor) devices, like Yubikeys
class U2fRegistration < ActiveRecord::Base
......
# frozen_string_literal: true
class Upload < ActiveRecord::Base
prepend EE::Upload
......
# frozen_string_literal: true
require 'carrierwave/orm/activerecord'
class User < ActiveRecord::Base
......
# frozen_string_literal: true
class UserAgentDetail < ActiveRecord::Base
belongs_to :subject, polymorphic: true # rubocop:disable Cop/PolymorphicAssociations
......
# frozen_string_literal: true
class UserCallout < ActiveRecord::Base
belongs_to :user
......
# frozen_string_literal: true
class UserCustomAttribute < ActiveRecord::Base
belongs_to :user
......
# frozen_string_literal: true
class UserInteractedProject < ActiveRecord::Base
belongs_to :user
belongs_to :project
......
# frozen_string_literal: true
class UserSyncedAttributesMetadata < ActiveRecord::Base
belongs_to :user
......
# frozen_string_literal: true
class UsersStarProject < ActiveRecord::Base
belongs_to :project, counter_cache: :star_count, touch: true
belongs_to :user
......
# frozen_string_literal: true
class WikiDirectory
include ActiveModel::Validations
......
# frozen_string_literal: true
# rubocop:disable Rails/ActiveRecordAliases
class WikiPage
PageChangedError = Class.new(StandardError)
......
---
title: Enable frozen string in app/models/*.rb
merge_request: 20851
author: gfyoung
type: performance
......@@ -13,7 +13,7 @@ describe Admin::ServicesController do
Service.available_services_names.each do |service_name|
context "#{service_name}" do
let!(:service) do
service_template = service_name.concat("_service").camelize.constantize
service_template = "#{service_name}_service".camelize.constantize
service_template.where(template: true).first_or_create
end
......
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