Enable frozen string literals.

Make all string literals immutable by default.
This commit is contained in:
evazion
2021-12-14 19:29:23 -06:00
parent 67b96135dd
commit a7dc05ce63
392 changed files with 786 additions and 2 deletions

View File

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

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Artist < ApplicationRecord
extend Memoist
class RevertError < StandardError; end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class ArtistCommentary < ApplicationRecord
class RevertError < StandardError; end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class ArtistCommentaryVersion < ApplicationRecord
belongs_to :post
belongs_to_updater

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class ArtistUrl < ApplicationRecord
before_validation :initialize_normalized_url, on: :create
before_validation :normalize

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class ArtistVersion < ApplicationRecord
array_attribute :urls
array_attribute :other_names

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Ban < ApplicationRecord
attribute :duration, :interval

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class BulkUpdateRequest < ApplicationRecord
STATUSES = %w[pending approved rejected processing failed]

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Comment < ApplicationRecord
belongs_to :post
belongs_to :creator, class_name: "User"

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class CommentVote < ApplicationRecord
attr_accessor :updater

View File

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

View File

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

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class EmailAddress < ApplicationRecord
belongs_to :user, inverse_of: :email_address

View File

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

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class FavoriteGroup < ApplicationRecord
belongs_to :creator, class_name: "User"

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class ForumPost < ApplicationRecord
attr_readonly :topic_id

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class ForumPostVote < ApplicationRecord
belongs_to :creator, class_name: "User"
belongs_to :forum_post

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class ForumTopic < ApplicationRecord
CATEGORIES = {
0 => "General",

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class ForumTopicVisit < ApplicationRecord
belongs_to :user
belongs_to :forum_topic

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class IpAddress < ApplicationRecord
belongs_to :model, polymorphic: true
belongs_to :user

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class IpBan < ApplicationRecord
belongs_to :creator, class_name: "User"

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
# An IpGeolocation contains metadata associated with an IP address, primarily geolocation data.
class IpGeolocation < ApplicationRecord

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class MediaAsset < ApplicationRecord
class Error < StandardError; end

View File

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

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class ModAction < ApplicationRecord
belongs_to :creator, :class_name => "User"

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class ModerationReport < ApplicationRecord
MODEL_TYPES = %w[Dmail Comment ForumPost]

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class NewsUpdate < ApplicationRecord
belongs_to :creator, class_name: "User"
belongs_to_updater

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Note < ApplicationRecord
class RevertError < StandardError; end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class NoteVersion < ApplicationRecord
belongs_to :post
belongs_to :note

View File

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

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pool < ApplicationRecord
class RevertError < StandardError; end
POOL_ORDER_LIMIT = 1000

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class PoolVersion < ApplicationRecord
belongs_to :updater, :class_name => "User"
belongs_to :pool

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Post < ApplicationRecord
class RevertError < StandardError; end
class DeletionError < StandardError; end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class PostAppeal < ApplicationRecord
belongs_to :creator, :class_name => "User"
belongs_to :post

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class PostApproval < ApplicationRecord
belongs_to :user
belongs_to :post, inverse_of: :approvals

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class PostDisapproval < ApplicationRecord
DELETION_THRESHOLD = 1.month
REASONS = %w[breaks_rules poor_quality disinterest]

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class PostEvent
include ActiveModel::Model
include ActiveModel::Serializers::JSON

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class PostFlag < ApplicationRecord
module Reasons
UNAPPROVED = "Unapproved in three days"

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class PostReplacement < ApplicationRecord
belongs_to :post
belongs_to :creator, class_name: "User"

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class PostVersion < ApplicationRecord
class RevertError < StandardError; end
extend Memoist

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class PostVote < ApplicationRecord
attr_accessor :updater

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class RateLimit < ApplicationRecord
scope :expired, -> { where("updated_at < ?", 1.hour.ago) }

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class SavedSearch < ApplicationRecord
REDIS_EXPIRY = 1.hour
QUERY_LIMIT = 1000

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Tag < ApplicationRecord
ABBREVIATION_REGEXP = /([a-z0-9])[a-z0-9']*($|[^a-z0-9']+)/

View File

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

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class TagImplication < TagRelationship
MINIMUM_TAG_COUNT = 10
MINIMUM_TAG_PERCENTAGE = 0.0001

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class TagRelationship < ApplicationRecord
STATUSES = %w[active deleted retired]

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Upload < ApplicationRecord
class Error < StandardError; end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class User < ApplicationRecord
class PrivilegeError < StandardError; end

View File

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

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class UserFeedback < ApplicationRecord
self.table_name = "user_feedback"

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class UserNameChangeRequest < ApplicationRecord
belongs_to :user
belongs_to :approver, class_name: "User", optional: true

View File

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

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class UserUpgrade < ApplicationRecord
belongs_to :recipient, class_name: "User"
belongs_to :purchaser, class_name: "User"

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class WikiPage < ApplicationRecord
class RevertError < StandardError; end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class WikiPageVersion < ApplicationRecord
array_attribute :other_names
belongs_to :wiki_page