Enable frozen string literals.

Make all string literals immutable by default.
This commit is contained in:
evazion
2021-12-14 21:33:27 -06:00
parent 67b96135dd
commit a7dc05ce63
392 changed files with 786 additions and 2 deletions
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Hooks into `respond_with` to add some custom behavior, including support for
# the `expires_in`, `expiry`, and `only` params.
#
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Demote all approvers who haven't approved at least 30 posts in the last 45
# days. Moderators and recently promoted approvers are exempt. Runs as a monthly
# maintenance task. Approvers who are facing demotion are sent a weekly warning
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Find the artist entry for a given artist profile URL.
module ArtistFinder
module_function
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Autocomplete tags, usernames, pools, and more.
#
# @example
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Perform a daily database dump to BigQuery and to Google Cloud Storage. This
# contains all data visible to anonymous users.
#
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Process a bulk update request. Parses the request and applies each line in
# sequence.
class BulkUpdateRequestProcessor
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Rejects bulk update requests that haven't been approved in 45 days.
module BulkUpdateRequestPruner
module_function
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# A wrapper around `Rails.cache` that adds some extra helper methods. All
# Danbooru code should use this class instead of using `Rails.cache` directly.
#
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# A simple Cloudflare API client for purging cached images after they're
# regenerated or deleted.
class CloudflareService
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Generates a set of CSS variables for site's color palette.
#
# The CSS variables are named like `var(--{hue}-{i})`, where `hue` is the color
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
module ArrayAttribute
extend ActiveSupport::Concern
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# A concern that adds common helper methods to models that are soft deletable.
#
# @example
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
module HasBitFlags
extend ActiveSupport::Concern
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# A concern that handles @mentions in comments and forum posts. Sends a DMail
# to mentioned users when a comment or forum post is created or edited to add
# new mentions.
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Normalizable
extend ActiveSupport::Concern
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Searchable
extend ActiveSupport::Concern
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# A global variable containing the current user, the current IP address, the
# current user's country code, whether safe mode is enabled, and whether
# save-data mode is enabled.
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'cgi'
require 'uri'
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Danbooru
module Helpers
module_function
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
require "danbooru/http/application_client"
require "danbooru/http/html_adapter"
require "danbooru/http/xml_adapter"
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# An extension to HTTP::Client that lets us write Rack-style middlewares that
# hook into the request/response cycle and override how requests are made. This
# works by extending http.rb's concept of features (HTTP::Feature) to give them
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Danbooru
class Http
class Cache < HTTP::Feature
@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Danbooru
class Http
class HtmlAdapter < HTTP::MimeType::Adapter
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Danbooru
class Http
class Logger < HTTP::Feature
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# A HTTP::Feature that automatically follows HTTP redirects.
#
# @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Redirections
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# A HTTP::Feature that automatically retries requests that return a 429 error
# or a Retry-After header.
#
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Danbooru
class Http
class Session < HTTP::Feature
@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Danbooru
class Http
class SpoofReferrer < HTTP::Feature
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Detect sites using Cloudflare Polish and bypass it by adding a random
# cache-busting URL param.
#
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Danbooru
class Http
class XmlAdapter < HTTP::MimeType::Adapter
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# A wrapper around the IPAddress gem that adds some extra utility methods.
#
# @see https://github.com/ipaddress-gem/ipaddress
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Danbooru
class MessageVerifier
attr_reader :purpose, :secret, :verifier
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# The DanbooruLogger class handles logging messages to the Rails log and to NewRelic.
#
# @see https://guides.rubyonrails.org/debugging_rails_applications.html#the-logger
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
module DanbooruMaintenance
module_function
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
class DeepDanbooruClient
attr_reader :http
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# A DeviantArt API client.
#
# Authentication is via OAuth2 with the client credentials grant. Register a
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Builds an HTML diff between two pieces of text.
class DiffBuilder
attr_reader :this_text, :that_text, :pattern
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# A Discord API Client.
#
# @see https://discord.com/developers/docs/intro
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# The parent class for a Discord slash command. Each slash command handled by
# Danbooru is a subclass of this class. Subclasses should set the {#name},
# {#description}, and {#options} class attributes defining the slash command's
@@ -1,3 +1,5 @@
# frozen_string_literal: true
class DiscordSlashCommand
class CountCommand < DiscordSlashCommand
self.name = "count"
@@ -1,3 +1,5 @@
# frozen_string_literal: true
class DiscordSlashCommand
class PostEmbed
attr_reader :post, :command
@@ -1,3 +1,5 @@
# frozen_string_literal: true
class DiscordSlashCommand
class PostsCommand < DiscordSlashCommand
extend Memoist
@@ -1,3 +1,5 @@
# frozen_string_literal: true
class DiscordSlashCommand
class RandomCommand < DiscordSlashCommand
self.name = "random"
@@ -1,3 +1,5 @@
# frozen_string_literal: true
class DiscordSlashCommand
class TagmeCommand < DiscordSlashCommand
self.name = "tagme"
@@ -1,3 +1,5 @@
# frozen_string_literal: true
class DiscordSlashCommand
class TimeCommand < DiscordSlashCommand
self.name = "time"
@@ -1,3 +1,5 @@
# frozen_string_literal: true
class DiscordSlashCommand
class WikiCommand < DiscordSlashCommand
extend Memoist
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Used for posting notifications to Discord about new forum posts.
# https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# A custom SimpleForm input for DText fields.
#
# Usage:
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'abbrev'
module DurationParser
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'resolv'
# Validates that an email address is well-formed, is deliverable, and is not a
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Parse the output of the Postgres EXPLAIN command to get how many rows Postgres
# *thinks* a SQL query will return. This is an estimate, and only accurate for
# queries that have a single condition. If the query has multiple conditions,
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
require "shellwords"
# A wrapper for the ffmpeg command.
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Add a post to a forum topic.
class ForumUpdater
attr_reader :forum_topic
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
class ImageProxy
class Error < StandardError; end
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Ensure ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Inet is loaded in
# the dev environment when eager loading is disabled.
require "active_record/connection_adapters/postgresql_adapter"
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# An API client for https://ipregistry.co. Looks up IP address information,
# including the geolocation and whether the IP is a proxy.
#
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# An API client for Danbooru's internal IQDB instance. Can add images, remove
# images, and search for images in IQDB.
#
+3 -1
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# An API client for Mastodon.
#
# @see https://docs.joinmastodon.org/api
@@ -50,7 +52,7 @@ class MastodonApiClient
end
def commentary
commentary = ""
commentary = "".dup
commentary << "<p>#{json["spoiler_text"]}</p>" if json["spoiler_text"].present?
commentary << json["content"] if json["content"].present?
commentary
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# A MediaFile represents an image, video, or flash file. It contains methods for
# detecting the file type, for generating a preview image, for getting metadata,
# and for resizing images.
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# This file contains code derived from
# https://github.com/dim/ruby-imagespec/blob/f2f3ce8bb5b1b411f8658e66a891a095261d94c0/lib/image_spec/parser/swf.rb
#
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# A MediaFile for a JPEG, PNG, or GIF file. Uses libvips for resizing images.
#
# @see https://github.com/libvips/ruby-vips
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# A MediaFile for a Pixiv ugoira file.
#
# A Pixiv ugoira is an animation format that consists of a zip file containing
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# A MediaFile for a webm or mp4 video. Uses ffmpeg to generate preview
# thumbnails.
#
@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Moderator
module Dashboard
module Queries
@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Moderator
module Dashboard
module Queries
@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Moderator
module Dashboard
module Queries
@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Moderator
module Dashboard
module Queries
@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Moderator
module Dashboard
module Queries
@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Moderator
module Dashboard
module Queries
@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Moderator
module Dashboard
module Queries
@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Moderator
module Dashboard
module Queries
@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Moderator
module Dashboard
module Queries
@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Moderator
module Dashboard
module Queries
@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Moderator
module Dashboard
class Report
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Moderator
class IpAddrSearch
attr_reader :params
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# An API client for the NicoSeiga XML API.
class NicoSeigaApiClient
extend Memoist
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Sanitizes the HTML used in notes. Only safe HTML tags, HTML attributes, and
# CSS properties are allowed.
module NoteSanitizer
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# A mixin that adds a `#paginate` method to an ActiveRecord relation.
#
# There are two pagination techniques. The first is page-based (numbered):
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
class ParameterBuilder
def self.serial_parameters(only_string, object)
only_array = split_only_string(only_string)
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# A client for Pixiv's AJAX API.
#
# Notes on the API:
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Delete posts that were unapproved after three days.
module PostPruner
module_function
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
require "strscan"
# A PostQueryBuilder represents a post search. It contains all logic for parsing
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# A PostSearchContext handles navigating to the next or previous post in a
# search. This is used in the search navbar above or below posts.
#
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# A PostSet is a set of posts returned by a search. This contains helper
# methods used on the post index page.
#
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# A RateLimiter handles HTTP rate limits for controller actions. Rate limits are
# based on the user, the user's IP, and the controller action.
#
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# An API client for the post recommendation service. The recommendation service
# is a separate Python microservice that generates recommended posts for users
# and posts. This client merely fetches the pre-generated recommendations from
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Calculate the tags similar to a given tag. Two tags are similar if they have
# nearly the same set of posts, and nearly the same size.
#
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Handle finding related tags by the {RelatedTagsController}. Used for finding
# related tags when tagging a post.
class RelatedTagQuery
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# An API client for the Reportbooru service. Reportbooru tracks post view
# counts, post search counts, and missed search counts.
#
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Allow Rails URL helpers to be used outside of views.
#
# @example
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Run a program inside an isolated sandbox, much like a Docker container. Inside the sandbox,
# the program doesn't have network access, can't see other programs, and can only see read-only
# OS directories like /usr and /lib. It can only communicate by reading from stdin and printing
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# This is a wrapper around seccomp, a Linux kernel feature used to limit the
# system calls the current process is allowed to make. This is used for
# sandboxing code when processing user-uploaded files.
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Returns status information about the running server, including software
# versions, basic load info, and Redis and Postgres info.
#
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Loads the current user from their session cookies or API key. Used by the
# ApplicationController to set the CurrentUser global early during the HTTP
# request cycle.
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Calculate a diff between two sets of strings. Used to calculate diffs between
# artist URLs and between other names. Tries to compare each set to detect which
# strings were added, which were removed, and which were changed.
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Sources
class Error < StandardError
end
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Sources
module Strategies
def self.all
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Page URLs:
#
# * https://www.artstation.com/artwork/04XA4
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# This is a collection of strategies for extracting information about a
# resource. At a minimum it tries to extract the artist name and a canonical
# URL to download the image from. But it can also be used to normalize a URL
@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Asset URLs:
#
## NORMALIZABLE

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