Enable frozen string literals.
Make all string literals immutable by default.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ApiKey < ApplicationRecord
|
||||
attribute :permitted_ip_addresses, :ip_address, array: true
|
||||
attribute :last_ip_address, :ip_address
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ApplicationRecord < ActiveRecord::Base
|
||||
self.abstract_class = true
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Artist < ApplicationRecord
|
||||
extend Memoist
|
||||
class RevertError < StandardError; end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ArtistCommentary < ApplicationRecord
|
||||
class RevertError < StandardError; end
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ArtistCommentaryVersion < ApplicationRecord
|
||||
belongs_to :post
|
||||
belongs_to_updater
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ArtistUrl < ApplicationRecord
|
||||
before_validation :initialize_normalized_url, on: :create
|
||||
before_validation :normalize
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ArtistVersion < ApplicationRecord
|
||||
array_attribute :urls
|
||||
array_attribute :other_names
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Ban < ApplicationRecord
|
||||
attribute :duration, :interval
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class BulkUpdateRequest < ApplicationRecord
|
||||
STATUSES = %w[pending approved rejected processing failed]
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Comment < ApplicationRecord
|
||||
belongs_to :post
|
||||
belongs_to :creator, class_name: "User"
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class CommentVote < ApplicationRecord
|
||||
attr_accessor :updater
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Dmail < ApplicationRecord
|
||||
validate :validate_sender_is_not_limited, on: :create
|
||||
validates :title, presence: true, length: { maximum: 200 }, if: :title_changed?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class DtextLink < ApplicationRecord
|
||||
belongs_to :model, polymorphic: true
|
||||
belongs_to :linked_wiki, primary_key: :title, foreign_key: :link_target, class_name: "WikiPage", optional: true
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class EmailAddress < ApplicationRecord
|
||||
belongs_to :user, inverse_of: :email_address
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Favorite < ApplicationRecord
|
||||
belongs_to :post, counter_cache: :fav_count
|
||||
belongs_to :user, counter_cache: :favorite_count
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class FavoriteGroup < ApplicationRecord
|
||||
belongs_to :creator, class_name: "User"
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ForumPost < ApplicationRecord
|
||||
attr_readonly :topic_id
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ForumPostVote < ApplicationRecord
|
||||
belongs_to :creator, class_name: "User"
|
||||
belongs_to :forum_post
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ForumTopic < ApplicationRecord
|
||||
CATEGORIES = {
|
||||
0 => "General",
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ForumTopicVisit < ApplicationRecord
|
||||
belongs_to :user
|
||||
belongs_to :forum_topic
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class IpAddress < ApplicationRecord
|
||||
belongs_to :model, polymorphic: true
|
||||
belongs_to :user
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class IpBan < ApplicationRecord
|
||||
belongs_to :creator, class_name: "User"
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# An IpGeolocation contains metadata associated with an IP address, primarily geolocation data.
|
||||
|
||||
class IpGeolocation < ApplicationRecord
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class MediaAsset < ApplicationRecord
|
||||
class Error < StandardError; end
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# MediaMetadata represents the EXIF and other metadata associated with a
|
||||
# MediaAsset (an uploaded image or video file). The `metadata` field contains a
|
||||
# JSON hash of the file's metadata as returned by ExifTool.
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ModAction < ApplicationRecord
|
||||
belongs_to :creator, :class_name => "User"
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ModerationReport < ApplicationRecord
|
||||
MODEL_TYPES = %w[Dmail Comment ForumPost]
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class NewsUpdate < ApplicationRecord
|
||||
belongs_to :creator, class_name: "User"
|
||||
belongs_to_updater
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Note < ApplicationRecord
|
||||
class RevertError < StandardError; end
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class NoteVersion < ApplicationRecord
|
||||
belongs_to :post
|
||||
belongs_to :note
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class PixivUgoiraFrameData < ApplicationRecord
|
||||
belongs_to :post, optional: true, foreign_key: :md5, primary_key: :md5
|
||||
belongs_to :media_asset, foreign_key: :md5, primary_key: :md5
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Pool < ApplicationRecord
|
||||
class RevertError < StandardError; end
|
||||
POOL_ORDER_LIMIT = 1000
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class PoolVersion < ApplicationRecord
|
||||
belongs_to :updater, :class_name => "User"
|
||||
belongs_to :pool
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Post < ApplicationRecord
|
||||
class RevertError < StandardError; end
|
||||
class DeletionError < StandardError; end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class PostAppeal < ApplicationRecord
|
||||
belongs_to :creator, :class_name => "User"
|
||||
belongs_to :post
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class PostApproval < ApplicationRecord
|
||||
belongs_to :user
|
||||
belongs_to :post, inverse_of: :approvals
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class PostDisapproval < ApplicationRecord
|
||||
DELETION_THRESHOLD = 1.month
|
||||
REASONS = %w[breaks_rules poor_quality disinterest]
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class PostEvent
|
||||
include ActiveModel::Model
|
||||
include ActiveModel::Serializers::JSON
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class PostFlag < ApplicationRecord
|
||||
module Reasons
|
||||
UNAPPROVED = "Unapproved in three days"
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class PostReplacement < ApplicationRecord
|
||||
belongs_to :post
|
||||
belongs_to :creator, class_name: "User"
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class PostVersion < ApplicationRecord
|
||||
class RevertError < StandardError; end
|
||||
extend Memoist
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class PostVote < ApplicationRecord
|
||||
attr_accessor :updater
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class RateLimit < ApplicationRecord
|
||||
scope :expired, -> { where("updated_at < ?", 1.hour.ago) }
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class SavedSearch < ApplicationRecord
|
||||
REDIS_EXPIRY = 1.hour
|
||||
QUERY_LIMIT = 1000
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Tag < ApplicationRecord
|
||||
ABBREVIATION_REGEXP = /([a-z0-9])[a-z0-9']*($|[^a-z0-9']+)/
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class TagAlias < TagRelationship
|
||||
# Validate that the alias doesn't exist yet when it's created or when a BUR
|
||||
# is requested, but not when a BUR is approved (to allow failed BURs to be reapproved)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class TagImplication < TagRelationship
|
||||
MINIMUM_TAG_COUNT = 10
|
||||
MINIMUM_TAG_PERCENTAGE = 0.0001
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class TagRelationship < ApplicationRecord
|
||||
STATUSES = %w[active deleted retired]
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Upload < ApplicationRecord
|
||||
class Error < StandardError; end
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class User < ApplicationRecord
|
||||
class PrivilegeError < StandardError; end
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# A UserEvent is used to track important events related to a user's account,
|
||||
# such as signups, logins, password changes, etc. A UserEvent is associated
|
||||
# with a UserSession, which contains the IP and browser information associated
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class UserFeedback < ApplicationRecord
|
||||
self.table_name = "user_feedback"
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class UserNameChangeRequest < ApplicationRecord
|
||||
belongs_to :user
|
||||
belongs_to :approver, class_name: "User", optional: true
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# A UserSession contains browser and IP metadata associated with a UserEvent. This
|
||||
# includes the user's session ID from their session cookie, their IP address,
|
||||
# and their browser user agent. This is used to track logins and other events.
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class UserUpgrade < ApplicationRecord
|
||||
belongs_to :recipient, class_name: "User"
|
||||
belongs_to :purchaser, class_name: "User"
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class WikiPage < ApplicationRecord
|
||||
class RevertError < StandardError; end
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class WikiPageVersion < ApplicationRecord
|
||||
array_attribute :other_names
|
||||
belongs_to :wiki_page
|
||||
|
||||
Reference in New Issue
Block a user