Skip to content

Commit

Permalink
Force frozen string literals ahead of Ruby 4.0
Browse files Browse the repository at this point in the history
Why not. I'm fairly confident in the test coverage that this won't lead to trouble
  • Loading branch information
Earlopain committed Jul 29, 2024
1 parent 6ffbd91 commit c891c7e
Show file tree
Hide file tree
Showing 173 changed files with 21 additions and 359 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ Style/Documentation:
Style/EmptyMethod:
EnforcedStyle: expanded

Style/FrozenStringLiteralComment:
EnforcedStyle: never

Style/HashSyntax:
EnforcedShorthandSyntax: never

Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ RUN apk --no-cache add \

ENV LD_PRELOAD=/usr/lib/libjemalloc.so.2
ENV RUBY_YJIT_ENABLE=1
ENV RUBYOPT=--enable=frozen-string-literal

RUN echo "[safe]" > ~/.gitconfig && \
echo " directory = /app" >> ~/.gitconfig
Expand Down
2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

source "https://rubygems.org"

rails_version = "~> 7.0"
Expand Down
2 changes: 0 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

Expand Down
2 changes: 0 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

class ApplicationController < ActionController::Base
skip_forgery_protection
before_action :set_start_time
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/archive_imports_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

class ArchiveImportsController < ApplicationController
def new
end
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/artist_urls_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

class ArtistUrlsController < ApplicationController
def index
@pagy, @artist_urls = ArtistUrl.search(index_search_params).pagy(params)
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/artists_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

class ArtistsController < ApplicationController
def index
@pagy, @artists = Artist.includes(:artist_urls).search(index_search_params).pagy(params)
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/config_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

class ConfigController < ApplicationController
def index
end
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/iqdb_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

class IqdbController < ApplicationController
def index
end
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/log_events_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

class LogEventsController < ApplicationController
def index
@pagy, @log_events = LogEvent.search(search_params).pagy_and_decorate(params)
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/stats_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

class StatsController < ApplicationController
def index
@original_size = sum_for("original", "SubmissionFile")
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/submission_files_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

class SubmissionFilesController < ApplicationController
def index
@search_params = search_params
Expand Down
2 changes: 0 additions & 2 deletions app/decorators/application_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

class ApplicationDecorator
include ActiveModel::Serialization
include ActiveModel::Serializers::JSON
Expand Down
2 changes: 0 additions & 2 deletions app/decorators/log_event_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

class LogEventDecorator < ApplicationDecorator
def preview
case action
Expand Down
2 changes: 0 additions & 2 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

module ApplicationHelper
include Pagy::Frontend

Expand Down
2 changes: 0 additions & 2 deletions app/helpers/artist_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

module ArtistHelper
def active_artist_urls_collection(artist)
scraping_enabled = artist.artist_urls.select(&:scraper?)
Expand Down
2 changes: 0 additions & 2 deletions app/helpers/artist_url_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

module ArtistUrlHelper
def gallery_url(artist_url)
artist_url.site.gallery_url(artist_url.unescaped_url_identifier)
Expand Down
2 changes: 0 additions & 2 deletions app/helpers/config_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

module ConfigHelper
def strip_config_prefix(definition, key)
key.to_s.delete_prefix("#{definition.site_type}_")
Expand Down
2 changes: 0 additions & 2 deletions app/helpers/nav_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

module NavHelper
def nav_link_to(text, url, **)
link = link_to(text, url, class: nav_link_class(url), **)
Expand Down
2 changes: 0 additions & 2 deletions app/helpers/submission_file_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

module SubmissionFileHelper
def display_artist_name?(submission_file)
s1 = submission_file.artist_url.url_identifier.downcase
Expand Down
2 changes: 0 additions & 2 deletions app/inputs/boolean_input.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

class BooleanInput < SimpleForm::Inputs::BooleanInput
# Fix styling because the input appears before the label
def label_input(wrapper_options = nil)
Expand Down
2 changes: 0 additions & 2 deletions app/jobs/application_job.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

class ApplicationJob < ActiveJob::Base
retry_on StandardError, wait: :polynomially_longer, attempts: 25 do |_job, exception|
log_exception(exception)
Expand Down
2 changes: 0 additions & 2 deletions app/jobs/archive_blob_import_job.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

class ArchiveBlobImportJob < ConcurrencyControlledJob
queue_as :submission_download
retry_on StandardError, attempts: 5
Expand Down
2 changes: 0 additions & 2 deletions app/jobs/concurrency_controlled_job.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

class ConcurrencyControlledJob < ApplicationJob
include GoodJob::ActiveJobExtensions::Concurrency
# Automatically scope keys to the job/queue.
Expand Down
2 changes: 0 additions & 2 deletions app/jobs/create_submission_file_job.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

class CreateSubmissionFileJob < ConcurrencyControlledJob
queue_as :submission_download
good_job_control_concurrency_with(total_limit: 1, key: -> { "#{arguments.first.id}-#{arguments.second[:identifier]}" })
Expand Down
2 changes: 0 additions & 2 deletions app/jobs/e6_iqdb_query_job.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

class E6IqdbQueryJob < ConcurrencyControlledJob
queue_as :e6_iqdb
good_job_control_concurrency_with(total_limit: 1, key: -> { arguments.first.id })
Expand Down
2 changes: 0 additions & 2 deletions app/jobs/purge_log_events_job.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

class PurgeLogEventsJob < ApplicationJob
def perform
LogEvent.where(created_at: ..1.month.ago).delete_all
Expand Down
2 changes: 0 additions & 2 deletions app/jobs/purge_unattached_blobs_job.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

class PurgeUnattachedBlobsJob < ApplicationJob
def perform
ActiveStorage::Blob.unattached.where(created_at: ..2.days.ago).find_each(&:purge)
Expand Down
2 changes: 0 additions & 2 deletions app/jobs/scrape_artist_url_job.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

class ScrapeArtistUrlJob < ConcurrencyControlledJob
queue_as :scraping
good_job_control_concurrency_with(total_limit: 1, key: -> { arguments.first.id })
Expand Down
2 changes: 0 additions & 2 deletions app/jobs/submission_file_update_job.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

class SubmissionFileUpdateJob < ApplicationJob
queue_as :variant_generation

Expand Down
2 changes: 0 additions & 2 deletions app/jobs/update_matching_e6_posts_job.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

class UpdateMatchingE6PostsJob < ConcurrencyControlledJob
good_job_control_concurrency_with(total_limit: 1, key: -> { arguments.first.to_s })

Expand Down
2 changes: 0 additions & 2 deletions app/logical/archives.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

module Archives
ALL = [
Archives::Tumblr,
Expand Down
2 changes: 0 additions & 2 deletions app/logical/archives/base.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

module Archives
class Base
attr_accessor :imported_files, :already_imported_count, :failed_imports, :error
Expand Down
2 changes: 0 additions & 2 deletions app/logical/archives/manual.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

module Archives
class Manual < Base
def import_submission_files(artist_id, source_url)
Expand Down
2 changes: 0 additions & 2 deletions app/logical/archives/tumblr.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

module Archives
# Archive Structure
#
Expand Down
2 changes: 0 additions & 2 deletions app/logical/config.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

module Config
module_function

Expand Down
4 changes: 1 addition & 3 deletions app/logical/docker_env.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

module DockerEnv
NEEDED_PG_VERSION = "16"
NEEDED_PG_VERSION = "16".freeze

module_function

Expand Down
4 changes: 1 addition & 3 deletions app/logical/e6_api_client.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

module E6ApiClient
ORIGIN = "https://e621.net"
ORIGIN = "https://e621.net".freeze
extend self

def iqdb_query(file)
Expand Down
2 changes: 0 additions & 2 deletions app/logical/esbuild_manifest.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

module EsbuildManifest
FILE_LOCATION = Rails.public_path.join("build/manifest.json")

Expand Down
2 changes: 0 additions & 2 deletions app/logical/git_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

module GitHelper
REPO = begin
Rugged::Repository.new(Rails.root)
Expand Down
2 changes: 0 additions & 2 deletions app/logical/hideable_search_form_builder.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

class HideableSearchFormBuilder < SimpleForm::FormBuilder
def input(attribute_name, options = {}, &)
value = @options[:search_params][attribute_name]
Expand Down
2 changes: 0 additions & 2 deletions app/logical/icon_generator.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

module IconGenerator
module_function

Expand Down
2 changes: 0 additions & 2 deletions app/logical/iqdb_proxy.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

# Contains functions to interact with the iqdb server
module IqdbProxy
class Error < RuntimeError; end
Expand Down
2 changes: 0 additions & 2 deletions app/logical/job_stats.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

class JobStats
def active_urls
(e6_iqdb_queued.keys + submission_download_queued.keys + scraping_queued.keys + scraping_now).uniq
Expand Down
2 changes: 0 additions & 2 deletions app/logical/pg_version_mismatch_handler.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

class PgVersionMismatchHandler
def initialize(app)
@app = app
Expand Down
2 changes: 0 additions & 2 deletions app/logical/printable_string_validator.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

class PrintableStringValidator < ActiveModel::EachValidator
REGEX = /^[0-9a-zA-Z_.+()-]*$/

Expand Down
2 changes: 0 additions & 2 deletions app/logical/scraper/artconomy.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

module Scraper
class Artconomy < Base
STATE = :page
Expand Down
2 changes: 0 additions & 2 deletions app/logical/scraper/artfight.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

module Scraper
class Artfight < BufferedScraper
STATE = :page
Expand Down
2 changes: 0 additions & 2 deletions app/logical/scraper/artstation.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

module Scraper
class Artstation < BufferedScraper
STATE = :page
Expand Down
2 changes: 0 additions & 2 deletions app/logical/scraper/baraag.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

module Scraper
class Baraag < MastodonV1
def domain
Expand Down
4 changes: 1 addition & 3 deletions app/logical/scraper/base.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

module Scraper
class Base
FRIENDLY_USER_AGENT = "FoxTrove/0.1 (by earlopain)"
FRIENDLY_USER_AGENT = "FoxTrove/0.1 (by earlopain)".freeze

delegate :url_identifier, :api_identifier, to: :@artist_url
attr_accessor :client
Expand Down
2 changes: 0 additions & 2 deletions app/logical/scraper/bluesky.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

module Scraper
class Bluesky < Base
STATE = :cursor
Expand Down
2 changes: 0 additions & 2 deletions app/logical/scraper/buffered_scraper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

module Scraper
# Some sites return many entries per page but fetching full data for these takes a long time.
# Loading all entries just to see if something is new is bad. Buffer it instead, so that
Expand Down
2 changes: 0 additions & 2 deletions app/logical/scraper/cohost.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

module Scraper
class Cohost < Base
STATE = :page
Expand Down
2 changes: 0 additions & 2 deletions app/logical/scraper/commishes.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

module Scraper
class Commishes < BufferedScraper
STATE = :until
Expand Down
4 changes: 1 addition & 3 deletions app/logical/scraper/deviantart.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# frozen_string_literal: true

module Scraper
# https://www.deviantart.com/developers/http/v1/20210526
# https://www.deviantart.com/developers/console
class Deviantart < Base
STATE = :next_offset
API_PREFIX = "https://www.deviantart.com/api/v1/oauth2"
API_PREFIX = "https://www.deviantart.com/api/v1/oauth2".freeze

def initialize(artist_url)
super
Expand Down
2 changes: 0 additions & 2 deletions app/logical/scraper/furaffinity.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

module Scraper
class Furaffinity < BufferedScraper
STATE = :page
Expand Down
4 changes: 1 addition & 3 deletions app/logical/scraper/furrynetwork.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# frozen_string_literal: true

module Scraper
class Furrynetwork < Base
STATE = :offset

PER_REQUEST = 72
API_PREFIX = "https://furrynetwork.com/api"
API_PREFIX = "https://furrynetwork.com/api".freeze

def initialize(artist_url)
super
Expand Down
2 changes: 0 additions & 2 deletions app/logical/scraper/httpx_plugin.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

module Scraper
module HttpxPlugin
module InstanceMethods
Expand Down
2 changes: 0 additions & 2 deletions app/logical/scraper/inkbunny.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

module Scraper
# https://wiki.inkbunny.net/wiki/API
class Inkbunny < Base
Expand Down
Loading

0 comments on commit c891c7e

Please sign in to comment.