Enable frozen string in app/models/*.rb

Partially addresses #47424.
This commit is contained in:
gfyoung 2018-07-25 02:30:33 -07:00
parent caeb4597a5
commit 50abbd3e53
139 changed files with 286 additions and 7 deletions

View file

@ -1,3 +1,5 @@
# 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

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require_dependency 'declarative_policy'
class Ability

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AbuseReport < ActiveRecord::Base
include CacheMarkdownField

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ActiveSession
include ActiveModel::Model

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Appearance < ActiveRecord::Base
include CacheableAttributes
include CacheMarkdownField

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ApplicationSetting < ActiveRecord::Base
include CacheableAttributes
include CacheMarkdownField

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AuditEvent < ActiveRecord::Base
serialize :details, Hash # rubocop:disable Cop/ActiveRecordSerialize

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AwardEmoji < ActiveRecord::Base
DOWNVOTE_NAME = "thumbsdown".freeze
UPVOTE_NAME = "thumbsup".freeze

View file

@ -1,3 +1,5 @@
# 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

View file

@ -1,3 +1,5 @@
# 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

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Board < ActiveRecord::Base
belongs_to :group
belongs_to :project

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class BroadcastMessage < ActiveRecord::Base
include CacheMarkdownField
include Sortable

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ChatName < ActiveRecord::Base
LAST_USED_AT_INTERVAL = 1.hour

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ChatTeam < ActiveRecord::Base
validates :team_id, presence: true
validates :namespace, uniqueness: true

View file

@ -1,4 +1,6 @@
# 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)

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
# CommitRange makes it easier to work with commit ranges
#
# Examples:

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class CommitStatus < ActiveRecord::Base
include HasStatus
include Importable

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Compare
include Gitlab::Utils::StrongMemoize

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ContainerRepository < ActiveRecord::Base
belongs_to :project

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class CycleAnalytics
STAGES = %i[issue plan code test review staging production].freeze

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class DashboardMilestone < GlobalMilestone
def issues_finder_params
{ authorized_only: true }

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class DeployKey < Key
include IgnorableColumn

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class DeployKeysProject < ActiveRecord::Base
belongs_to :project
belongs_to :deploy_key, inverse_of: :deploy_keys_projects

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class DeployToken < ActiveRecord::Base
include Expirable
include TokenAuthenticatable

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Deployment < ActiveRecord::Base
include AtomicInternalId
include IidRoutes

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
# A discussion on merge request or commit diffs consisting of `DiffNote` notes.
#
# A discussion of this type can be resolvable.

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
# A note on merge request or commit diffs
#
# A note of this type can be resolvable.

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class DirectlyAddressedUser
class << self
def reference_pattern

View file

@ -1,3 +1,5 @@
# 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.

View file

@ -1,3 +1,5 @@
# 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.

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Email < ActiveRecord::Base
include Sortable
include Gitlab::SQL::Pattern

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Environment < ActiveRecord::Base
# Used to generate random suffixes for the slug
LETTERS = 'a'..'z'
@ -173,7 +175,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])

View file

@ -1,3 +1,5 @@
# 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

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Event < ActiveRecord::Base
include Sortable
include IgnorableColumn

View file

@ -1,3 +1,5 @@
# 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.

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ExternalIssue
include Referable

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ForkNetwork < ActiveRecord::Base
belongs_to :root_project, class_name: 'Project'
has_many :fork_network_members

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ForkNetworkMember < ActiveRecord::Base
belongs_to :fork_network
belongs_to :project

View file

@ -1,3 +1,5 @@
# 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'

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class GenericCommitStatus < CommitStatus
before_validation :set_default_values

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class GlobalLabel
attr_accessor :title, :labels
alias_attribute :name, :title

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class GlobalMilestone
include Milestoneish

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class GpgKey < ActiveRecord::Base
KEY_PREFIX = '-----BEGIN PGP PUBLIC KEY BLOCK-----'.freeze
KEY_SUFFIX = '-----END PGP PUBLIC KEY BLOCK-----'.freeze

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class GpgKeySubkey < ActiveRecord::Base
include ShaAttribute

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class GpgSignature < ActiveRecord::Base
include ShaAttribute

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'carrierwave/orm/activerecord'
class Group < Namespace

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class GroupCustomAttribute < ActiveRecord::Base
belongs_to :group

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class GroupLabel < Label
belongs_to :group

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class GroupMilestone < GlobalMilestone
attr_accessor :group

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Guest
class << self
def can?(action, subject = :global)

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Identity < ActiveRecord::Base
def self.uniqueness_scope
:provider

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ImportExportUpload < ActiveRecord::Base
include WithUploads
include ObjectStorage::BackgroundMove

View file

@ -1,3 +1,5 @@
# 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.
#

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'resolv'
class InstanceConfiguration

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
# An InternalId is a strictly monotone sequence of integers
# generated for a given scope and usage.
#

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'carrierwave/orm/activerecord'
class Issue < ActiveRecord::Base

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class IssueAssignee < ActiveRecord::Base
belongs_to :issue
belongs_to :assignee, class_name: "User", foreign_key: :user_id

View file

@ -1,3 +1,5 @@
# 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

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'digest/md5'
class Key < ActiveRecord::Base

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Label < ActiveRecord::Base
include CacheMarkdownField
include Referable

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class LabelLink < ActiveRecord::Base
include Importable

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class LabelPriority < ActiveRecord::Base
belongs_to :project
belongs_to :label

View file

@ -1,3 +1,5 @@
# 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

View file

@ -1,3 +1,5 @@
# 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

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class LfsFileLock < ActiveRecord::Base
belongs_to :project
belongs_to :user

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class LfsObject < ActiveRecord::Base
include AfterCommitQueue
include ObjectStorage::BackgroundMove

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class LfsObjectsProject < ActiveRecord::Base
belongs_to :project
belongs_to :lfs_object

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class List < ActiveRecord::Base
belongs_to :board
belongs_to :label

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Member < ActiveRecord::Base
include AfterCommitQueue
include Sortable

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class MergeRequest < ActiveRecord::Base
include AtomicInternalId
include IidRoutes

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class MergeRequestDiff < ActiveRecord::Base
include Sortable
include Importable

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class MergeRequestDiffCommit < ActiveRecord::Base
include ShaAttribute

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class MergeRequestDiffFile < ActiveRecord::Base
include Gitlab::EncodingHelper
include DiffFile

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class MergeRequestsClosingIssues < ActiveRecord::Base
belongs_to :merge_request
belongs_to :issue

View file

@ -1,3 +1,5 @@
# 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.

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Namespace < ActiveRecord::Base
include CacheMarkdownField
include Sortable

View file

@ -1,3 +1,5 @@
# 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.

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class NoteDiffFile < ActiveRecord::Base
include DiffFile

View file

@ -1,3 +1,5 @@
# 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

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class NotificationRecipient
include Gitlab::Utils::StrongMemoize

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class NotificationSetting < ActiveRecord::Base
include IgnorableColumn

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class OauthAccessGrant < Doorkeeper::AccessGrant
belongs_to :resource_owner, class_name: 'User'
belongs_to :application, class_name: 'Doorkeeper::Application'

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class OauthAccessToken < Doorkeeper::AccessToken
belongs_to :resource_owner, class_name: 'User'
belongs_to :application, class_name: 'Doorkeeper::Application'

View file

@ -1,3 +1,5 @@
# 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.
#

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class PagesDomain < ActiveRecord::Base
VERIFICATION_KEY = 'gitlab-pages-verification-code'.freeze
VERIFICATION_THRESHOLD = 3.days.freeze

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class PersonalAccessToken < ActiveRecord::Base
include Expirable
include TokenAuthenticatable

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class PersonalSnippet < Snippet
include WithUploads
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'carrierwave/orm/activerecord'
class Project < ActiveRecord::Base

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ProjectAuthorization < ActiveRecord::Base
belongs_to :user
belongs_to :project

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ProjectAutoDevops < ActiveRecord::Base
belongs_to :project

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ProjectCiCdSetting < ActiveRecord::Base
belongs_to :project, inverse_of: :ci_cd_settings

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ProjectCustomAttribute < ActiveRecord::Base
belongs_to :project

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ProjectDeployToken < ActiveRecord::Base
belongs_to :project
belongs_to :deploy_token, inverse_of: :project_deploy_tokens

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ProjectFeature < ActiveRecord::Base
# == Project features permissions
#

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ProjectGroupLink < ActiveRecord::Base
include Expirable

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'carrierwave/orm/activerecord'
class ProjectImportData < ActiveRecord::Base

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ProjectImportState < ActiveRecord::Base
include AfterCommitQueue

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ProjectLabel < Label
MAX_NUMBER_OF_PRIORITIES = 1

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ProjectSnippet < Snippet
belongs_to :project
belongs_to :author, class_name: "User"

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ProjectStatistics < ActiveRecord::Base
belongs_to :project
belongs_to :namespace

Some files were not shown because too many files have changed in this diff Show more