From 902e2d422bb9f4651d2b50ae588c9dd6169e9415 Mon Sep 17 00:00:00 2001 From: Neetpone <132411956+neetpone@users.noreply.github.com> Date: Thu, 4 Apr 2024 04:21:23 -0400 Subject: [PATCH] style: rubocop --- .rubocop.yml | 58 ++++++++ .rubocop_todo.yml | 124 ++++++++++++++++++ Gemfile | 28 ++-- Gemfile.lock | 24 ++++ Rakefile | 3 +- app/channels/application_cable/channel.rb | 5 +- app/channels/application_cable/connection.rb | 5 +- app/controllers/application_controller.rb | 1 + app/controllers/authors_controller.rb | 1 + app/controllers/chapters_controller.rb | 3 +- app/controllers/images_controller.rb | 12 +- app/controllers/search_controller.rb | 27 ++-- app/controllers/static_pages_controller.rb | 1 + app/controllers/stories_controller.rb | 1 + app/helpers/application_helper.rb | 1 + app/helpers/authors_helper.rb | 1 + app/helpers/chapters_helper.rb | 1 + app/helpers/images_helper.rb | 1 + app/helpers/search_helper.rb | 27 ++-- app/helpers/static_pages_helper.rb | 1 + app/helpers/stories_helper.rb | 1 + app/indexes/story_index.rb | 11 +- app/jobs/application_job.rb | 1 + app/jobs/index_update_job.rb | 6 +- app/jobs/recount_words_job.rb | 6 +- app/models/application_record.rb | 1 + app/models/author.rb | 1 + app/models/chapter.rb | 1 + app/models/story.rb | 1 + app/models/story/tagging.rb | 1 + app/models/tag.rb | 1 + bin/bundle | 28 ++-- bin/importmap | 5 +- bin/rails | 7 +- bin/rake | 5 +- bin/setup | 17 +-- config.ru | 3 +- config/application.rb | 48 ++++--- config/boot.rb | 5 +- config/environment.rb | 3 +- config/environments/development.rb | 7 +- config/environments/production.rb | 11 +- config/environments/test.rb | 7 +- config/importmap.rb | 11 +- config/initializers/assets.rb | 3 +- .../initializers/content_security_policy.rb | 1 + .../initializers/filter_parameter_logging.rb | 5 +- config/initializers/inflections.rb | 1 + config/initializers/permissions_policy.rb | 1 + config/initializers/redis.rb | 2 +- config/puma.rb | 13 +- config/routes.rb | 1 + db/seeds.rb | 1 + test/application_system_test_case.rb | 3 +- .../application_cable/connection_test.rb | 3 +- test/controllers/authors_controller_test.rb | 3 +- test/controllers/chapters_controller_test.rb | 3 +- test/controllers/images_controller_test.rb | 3 +- test/controllers/search_controller_test.rb | 3 +- .../static_pages_controller_test.rb | 3 +- test/controllers/stories_controller_test.rb | 3 +- test/models/author_test.rb | 3 +- test/models/chapter_test.rb | 3 +- test/models/story_test.rb | 3 +- test/models/tag_test.rb | 3 +- test/test_helper.rb | 7 +- 66 files changed, 430 insertions(+), 154 deletions(-) create mode 100644 .rubocop.yml create mode 100644 .rubocop_todo.yml diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..4fda21a --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,58 @@ +inherit_from: .rubocop_todo.yml +AllCops: + SuggestExtensions: false + NewCops: enable + Exclude: + - db/migrate/*.rb + - db/schema.rb + - vendor/**/* + - public/**/* + - tmp/**/* + - spec/rails_helper.rb + - lib/tasks/auto_annotate_models.rake + +Style/FetchEnvVar: + Enabled: false + +# I just don't like it +Layout/EmptyLineAfterMagicComment: + Enabled: false + +# These next two are stylistic choices I don't agree with +Style/MultilineIfModifier: + Enabled: false + +Style/IfUnlessModifier: + Enabled: false + +# It just feels wrong +Style/HashSyntax: + EnforcedShorthandSyntax: never + +# This is too convenient not to +Style/GlobalVars: + AllowedVariables: + - $redis + +Style/FrozenStringLiteralComment: + Enabled: true + +# Don't like it +Style/EmptyMethod: + Enabled: false + +Style/ClassVars: + Enabled: false + +Style/ClassAndModuleChildren: + EnforcedStyle: compact + +# This does the oppposite of what I want to do. +Layout/HashAlignment: + Enabled: false + +Layout/CaseIndentation: + IndentOneStep: true + +Style/NumericPredicate: + Enabled: false \ No newline at end of file diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000..dba7d69 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,124 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2024-04-04 07:59:52 UTC using RuboCop version 1.62.1. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, no_empty_lines +Layout/EmptyLinesAroundBlockBody: + Exclude: + - 'db/schema.rb' + +# Offense count: 4 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: IndentationWidth. +# SupportedStyles: special_inside_parentheses, consistent, align_braces +Layout/FirstHashElementIndentation: + EnforcedStyle: consistent + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. +# SupportedStyles: space, no_space, compact +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideHashLiteralBraces: + Exclude: + - 'app/controllers/search_controller.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: space, compact, no_space +Layout/SpaceInsideParens: + Exclude: + - 'app/controllers/search_controller.rb' + +# Offense count: 4 +# This cop supports safe autocorrection (--autocorrect). +Layout/SpaceInsidePercentLiteralDelimiters: + Exclude: + - 'Gemfile' + +# Offense count: 6 +# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. +Metrics/AbcSize: + Max: 48 + +# Offense count: 3 +# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. +# AllowedMethods: refine +Metrics/BlockLength: + Max: 53 + +# Offense count: 3 +# Configuration parameters: AllowedMethods, AllowedPatterns. +Metrics/CyclomaticComplexity: + Max: 16 + +# Offense count: 12 +# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. +Metrics/MethodLength: + Max: 50 + +# Offense count: 2 +# Configuration parameters: AllowedMethods, AllowedPatterns. +Metrics/PerceivedComplexity: + Max: 17 + +# Offense count: 2 +# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. +# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to +Naming/MethodParameterName: + Exclude: + - 'app/helpers/search_helper.rb' + +# Offense count: 22 +# Configuration parameters: AllowedConstants. +Style/Documentation: + Enabled: false + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/GlobalStdStream: + Exclude: + - 'config/environments/production.rb' + +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: literals, strict +Style/MutableConstant: + Exclude: + - 'app/controllers/search_controller.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/PerlBackrefs: + Exclude: + - 'bin/bundle' + +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: SafeForConstants. +Style/RedundantFetchBlock: + Exclude: + - 'config/puma.rb' + - +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: RequireEnglish. +# SupportedStyles: use_perl_names, use_english_names, use_builtin_english_names +Style/SpecialGlobalVars: + EnforcedStyle: use_perl_names + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. +# URISchemes: http, https +Layout/LineLength: + Max: 198 diff --git a/Gemfile b/Gemfile index 47bd80e..569811e 100644 --- a/Gemfile +++ b/Gemfile @@ -1,43 +1,45 @@ -source "https://rubygems.org" +# frozen_string_literal: true +source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } -ruby "3.2.2" +ruby '3.2.2' -gem "rails", "~> 7.0.8", ">= 7.0.8.1" -gem "sprockets-rails" -gem "pg", "~> 1.1" -gem "puma", "~> 5.0" -gem 'slim-rails' gem 'kaminari' +gem 'pg', '~> 1.1' +gem 'puma', '~> 5.0' +gem 'rails', '~> 7.0.8', '>= 7.0.8.1' gem 'redcarpet' +gem 'slim-rails' +gem 'sprockets-rails' gem 'redis' gem 'elasticsearch-model' -gem 'model-msearch' gem 'fancy_searchable', github: 'Twibooru/fancy_searchable', ref: '40687c9' +gem 'model-msearch' gem 'sidekiq' # Windows does not include zoneinfo files, so bundle the tzinfo-data gem -gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ] +gem 'tzinfo-data', platforms: %i[ mingw mswin x64_mingw jruby ] # Use Sass to process CSS # gem "sassc-rails" group :development, :test do # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem - gem "debug", platforms: %i[ mri mingw x64_mingw ] + gem 'debug', platforms: %i[ mri mingw x64_mingw ] end group :development do - gem "web-console" gem 'annotate' gem 'bullet' + gem 'rubocop', require: false + gem 'web-console' end group :test do # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing] - gem "capybara" - gem "selenium-webdriver" + gem 'capybara' + gem 'selenium-webdriver' end diff --git a/Gemfile.lock b/Gemfile.lock index c9f4989..1089632 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -80,6 +80,7 @@ GEM annotate (3.2.0) activerecord (>= 3.2, < 8.0) rake (>= 10.4, < 14.0) + ast (2.4.2) base64 (0.2.0) bindex (0.8.1) builder (3.2.4) @@ -128,6 +129,7 @@ GEM irb (1.12.0) rdoc reline (>= 0.4.2) + json (2.7.2) kaminari (1.2.2) activesupport (>= 4.1.0) kaminari-actionview (= 1.2.2) @@ -140,6 +142,7 @@ GEM activerecord kaminari-core (= 1.2.2) kaminari-core (1.2.2) + language_server-protocol (3.17.0.3) loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) @@ -170,6 +173,10 @@ GEM nio4r (2.7.1) nokogiri (1.16.3-x86_64-linux) racc (~> 1.4) + parallel (1.24.0) + parser (3.3.0.5) + ast (~> 2.4.1) + racc pg (1.5.6) psych (5.1.2) stringio @@ -208,6 +215,7 @@ GEM rake (>= 12.2) thor (~> 1.0) zeitwerk (~> 2.5) + rainbow (3.1.1) rake (13.1.0) rdoc (6.6.3.1) psych (>= 4.0.0) @@ -220,6 +228,20 @@ GEM reline (0.5.0) io-console (~> 0.5) rexml (3.2.6) + rubocop (1.62.1) + json (~> 2.3) + language_server-protocol (>= 3.17.0) + parallel (~> 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.31.1, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.31.2) + parser (>= 3.3.0.4) + ruby-progressbar (1.13.0) rubyzip (2.3.2) selenium-webdriver (4.19.0) base64 (~> 0.2) @@ -252,6 +274,7 @@ GEM timeout (0.4.1) tzinfo (2.0.6) concurrent-ruby (~> 1.0) + unicode-display_width (2.5.0) uniform_notifier (1.16.0) uri (0.13.0) web-console (4.2.1) @@ -284,6 +307,7 @@ DEPENDENCIES rails (~> 7.0.8, >= 7.0.8.1) redcarpet redis + rubocop selenium-webdriver sidekiq slim-rails diff --git a/Rakefile b/Rakefile index 9a5ea73..84f2bc3 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,7 @@ +# 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. -require_relative "config/application" +require_relative 'config/application' Rails.application.load_tasks diff --git a/app/channels/application_cable/channel.rb b/app/channels/application_cable/channel.rb index d672697..c7b05a0 100644 --- a/app/channels/application_cable/channel.rb +++ b/app/channels/application_cable/channel.rb @@ -1,4 +1,3 @@ -module ApplicationCable - class Channel < ActionCable::Channel::Base - end +# frozen_string_literal: true +class ApplicationCable::Channel < ActionCable::Channel::Base end diff --git a/app/channels/application_cable/connection.rb b/app/channels/application_cable/connection.rb index 0ff5442..313f5ed 100644 --- a/app/channels/application_cable/connection.rb +++ b/app/channels/application_cable/connection.rb @@ -1,4 +1,3 @@ -module ApplicationCable - class Connection < ActionCable::Connection::Base - end +# frozen_string_literal: true +class ApplicationCable::Connection < ActionCable::Connection::Base end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 841d3da..5c70698 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true class ApplicationController < ActionController::Base before_action :start_timer before_action :setup_pagination_and_tags diff --git a/app/controllers/authors_controller.rb b/app/controllers/authors_controller.rb index 14b2cd8..4e96a7a 100644 --- a/app/controllers/authors_controller.rb +++ b/app/controllers/authors_controller.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true class AuthorsController < ApplicationController def show @author = Author.find(params[:id]) diff --git a/app/controllers/chapters_controller.rb b/app/controllers/chapters_controller.rb index 1ab16be..c7dd82a 100644 --- a/app/controllers/chapters_controller.rb +++ b/app/controllers/chapters_controller.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'redcarpet' class ChaptersController < ApplicationController @@ -17,7 +18,7 @@ class ChaptersController < ApplicationController # This is fucking bad, this gets rid of the redundant title - this should be fixed upstairs, # in the actual generation of the Markdown. - if body.length >= 2 && body[0] == @chapter.title && body[1].length > 0 && body[1][0] == '=' + if body.length >= 2 && body[0] == @chapter.title && !body[1].empty? && body[1][0] == '=' body = body[2..] end diff --git a/app/controllers/images_controller.rb b/app/controllers/images_controller.rb index ef14b30..32e22b2 100644 --- a/app/controllers/images_controller.rb +++ b/app/controllers/images_controller.rb @@ -1,8 +1,9 @@ +# frozen_string_literal: true require 'open-uri' # Handles proxying images from the FiMFiction CDN and caching them locally, in case they disappear. class ImagesController < ApplicationController - #noinspection RubyMismatchedArgumentType + # noinspection RubyMismatchedArgumentType def show url = params[:url] parsed = URI.parse(url) @@ -15,16 +16,17 @@ class ImagesController < ApplicationController ext = File.extname(url) hash = Digest::SHA256.hexdigest(url) path = Rails.root.join('public', 'cached-images', hash + ext) - our_url = '/cached-images/' + hash + ext + our_url = "/cached-images/#{hash}#{ext}" if File.exist? path redirect_to our_url return end - File.open(path, 'wb') do |fp| - fp.write(Net::HTTP.get(parsed)) - end + File.binwrite( + path, + Net::HTTP.get(parsed) + ) redirect_to our_url end diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 9547223..4028fa5 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -1,7 +1,8 @@ +# frozen_string_literal: true # This whole class is a giant mess but I coded it fast so give me a break. class SearchController < ApplicationController - ALLOWED_SORT_DIRS = [:asc, :desc] - ALLOWED_SORT_FIELDS = [:title, :author, :date_published, :date_updated, :num_words, :rel] + ALLOWED_SORT_DIRS = %i[asc desc] + ALLOWED_SORT_FIELDS = %i[title author date_published date_updated num_words rel] before_action :load_tags @@ -74,10 +75,10 @@ class SearchController < ApplicationController # returns: [included tags, excluded tags] def parse_tag_queries - tag_searches = (@search_params['tags'] + ',' + @search_params['characters']).split(',').reject &:blank? + tag_searches = "#{@search_params['tags']},#{@search_params['characters']}".split(',').reject(&:blank?) [ - tag_searches.select { |t| t[0] != '-' }, + tag_searches.reject { |t| t[0] == '-' }, tag_searches.select { |t| t[0] == '-' } .map { |t| t[1..] } ] @@ -89,14 +90,14 @@ class SearchController < ApplicationController # we need to sort on the keyword versions of text fields, to avoid using fielddata. sf = case sf - when :rel then - :_score - when :title then - :title_keyword - when :author then - :author_keyword - else - sf + when :rel + :_score + when :title + :title_keyword + when :author + :author_keyword + else + sf end {sf => sd} @@ -111,7 +112,7 @@ class SearchController < ApplicationController if params[:scope].present? result = $redis.get("search_scope/#{params[:scope]}") if result.present? - @search_params = JSON.load(result) + @search_params = JSON.parse(result) @scope_key = params[:scope] scope_valid = true else diff --git a/app/controllers/static_pages_controller.rb b/app/controllers/static_pages_controller.rb index 6fd914a..86a2f8f 100644 --- a/app/controllers/static_pages_controller.rb +++ b/app/controllers/static_pages_controller.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true class StaticPagesController < ApplicationController def about end diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb index cce75ed..61713c0 100644 --- a/app/controllers/stories_controller.rb +++ b/app/controllers/stories_controller.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true class StoriesController < ApplicationController def index end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9747f8a..e1413e7 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module ApplicationHelper # https://infusion.media/content-marketing/how-to-calculate-reading-time/ def reading_time(words) diff --git a/app/helpers/authors_helper.rb b/app/helpers/authors_helper.rb index f22e1f9..6899313 100644 --- a/app/helpers/authors_helper.rb +++ b/app/helpers/authors_helper.rb @@ -1,2 +1,3 @@ +# frozen_string_literal: true module AuthorsHelper end diff --git a/app/helpers/chapters_helper.rb b/app/helpers/chapters_helper.rb index 063540b..b6ede51 100644 --- a/app/helpers/chapters_helper.rb +++ b/app/helpers/chapters_helper.rb @@ -1,2 +1,3 @@ +# frozen_string_literal: true module ChaptersHelper end diff --git a/app/helpers/images_helper.rb b/app/helpers/images_helper.rb index 7b3a8bc..7cdc611 100644 --- a/app/helpers/images_helper.rb +++ b/app/helpers/images_helper.rb @@ -1,2 +1,3 @@ +# frozen_string_literal: true module ImagesHelper end diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index 944642d..6541b1f 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -1,36 +1,37 @@ +# frozen_string_literal: true module SearchHelper def rating_display(rating) case rating - when 'everyone' then + when 'everyone' tag.div class: 'frating ev', title: 'Rated Everyone' do 'Everyone' end - when 'teen' then - tag.div class: 'frating', title: 'Rated Teen' do - 'Teen' - end - when 'explicit' then - tag.div class: 'frating', title: 'Rated Explicit' do - 'Explicit' - end + when 'teen' + tag.div class: 'frating', title: 'Rated Teen' do + 'Teen' + end + when 'explicit' + tag.div class: 'frating', title: 'Rated Explicit' do + 'Explicit' + end end end def status_display(status) case status - when 'complete' then + when 'complete' tag.div class: 'fstatus sc', title: 'Complete' do 'Complete' end - when 'incomplete' then + when 'incomplete' tag.div class: 'fstatus si', title: 'Incomplete' do 'Incomplete' end - when 'hiatus' then + when 'hiatus' tag.div class: 'fstatus sh', title: 'On Hiatus' do 'On Hiatus' end - when 'cancelled' then + when 'cancelled' tag.div class: 'fstatus sn', title: 'Cancelled' do 'Cancelled' end diff --git a/app/helpers/static_pages_helper.rb b/app/helpers/static_pages_helper.rb index 2d63e79..cd6ab05 100644 --- a/app/helpers/static_pages_helper.rb +++ b/app/helpers/static_pages_helper.rb @@ -1,2 +1,3 @@ +# frozen_string_literal: true module StaticPagesHelper end diff --git a/app/helpers/stories_helper.rb b/app/helpers/stories_helper.rb index 43e5cd8..fbae0ad 100644 --- a/app/helpers/stories_helper.rb +++ b/app/helpers/stories_helper.rb @@ -1,2 +1,3 @@ +# frozen_string_literal: true module StoriesHelper end diff --git a/app/indexes/story_index.rb b/app/indexes/story_index.rb index 6dca9b7..a3fd5e8 100644 --- a/app/indexes/story_index.rb +++ b/app/indexes/story_index.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module StoryIndex def self.included(base) base.settings index: { number_of_shards: 5, max_result_window: 10_000_000 } do @@ -31,10 +32,10 @@ module StoryIndex [date_published: :desc] end - def allowed_search_fields(access_options = {}) - [:title, :completion_status, :content_rating, :date_published, :date_updated, :date_modified, - :num_comments, :num_views, :num_words, :rating, :short_description, :description_html, - :title, :title_keyword, :tags, :author, :author_keyword] + def allowed_search_fields(_access_options = {}) + %i[title completion_status content_rating date_published date_updated date_modified + num_comments num_views num_words rating short_description description_html + title title_keyword tags author author_keyword] end end @@ -64,4 +65,4 @@ module StoryIndex def as_indexed_json(*) as_json end -end \ No newline at end of file +end diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb index d394c3d..15f4fa9 100644 --- a/app/jobs/application_job.rb +++ b/app/jobs/application_job.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true class ApplicationJob < ActiveJob::Base # Automatically retry jobs that encountered a deadlock # retry_on ActiveRecord::Deadlocked diff --git a/app/jobs/index_update_job.rb b/app/jobs/index_update_job.rb index 258868d..674a131 100644 --- a/app/jobs/index_update_job.rb +++ b/app/jobs/index_update_job.rb @@ -4,8 +4,8 @@ class IndexUpdateJob < ApplicationJob queue_as :high def perform(cls, id) obj = cls.constantize.find(id) - obj.update_index(defer: false) if obj - rescue StandardError => ex - Rails.logger.error ex.message + obj&.update_index(defer: false) + rescue StandardError => e + Rails.logger.error e.message end end diff --git a/app/jobs/recount_words_job.rb b/app/jobs/recount_words_job.rb index 1c02192..a6e2570 100644 --- a/app/jobs/recount_words_job.rb +++ b/app/jobs/recount_words_job.rb @@ -1,10 +1,12 @@ +# frozen_string_literal: true class RecountWordsJob < ApplicationJob def perform(*) Story.find_each do |story| word_count = 0 story.chapters.each do |chapter| next unless chapter.body - count = chapter.body.split(' ').size + + count = chapter.body.split.size chapter.update_columns( num_words: count ) @@ -16,4 +18,4 @@ class RecountWordsJob < ApplicationJob ) end end -end \ No newline at end of file +end diff --git a/app/models/application_record.rb b/app/models/application_record.rb index b63caeb..72b9338 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true class ApplicationRecord < ActiveRecord::Base primary_abstract_class end diff --git a/app/models/author.rb b/app/models/author.rb index 903da1e..c76efa1 100644 --- a/app/models/author.rb +++ b/app/models/author.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # == Schema Information # # Table name: authors diff --git a/app/models/chapter.rb b/app/models/chapter.rb index 647ef26..eb0575c 100644 --- a/app/models/chapter.rb +++ b/app/models/chapter.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # == Schema Information # # Table name: chapters diff --git a/app/models/story.rb b/app/models/story.rb index 1b355c6..067a63d 100644 --- a/app/models/story.rb +++ b/app/models/story.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # == Schema Information # # Table name: stories diff --git a/app/models/story/tagging.rb b/app/models/story/tagging.rb index 8fe5f27..d0c936c 100644 --- a/app/models/story/tagging.rb +++ b/app/models/story/tagging.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # == Schema Information # # Table name: story_taggings diff --git a/app/models/tag.rb b/app/models/tag.rb index 857e1d2..80a5c60 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # == Schema Information # # Table name: tags diff --git a/bin/bundle b/bin/bundle index 42c7fd7..d359435 100755 --- a/bin/bundle +++ b/bin/bundle @@ -8,7 +8,7 @@ # this file is here to facilitate running it. # -require "rubygems" +require 'rubygems' m = Module.new do module_function @@ -18,12 +18,13 @@ m = Module.new do end def env_var_version - ENV["BUNDLER_VERSION"] + ENV['BUNDLER_VERSION'] end def cli_arg_version return unless invoked_as_script? # don't want to hijack other binstubs - return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update` + return unless 'update'.start_with?(ARGV.first || ' ') # must be running `bundle update` + bundler_version = nil update_index = nil ARGV.each_with_index do |a, i| @@ -31,6 +32,7 @@ m = Module.new do bundler_version = a end next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/ + bundler_version = $1 update_index = i end @@ -38,25 +40,27 @@ m = Module.new do end def gemfile - gemfile = ENV["BUNDLE_GEMFILE"] + gemfile = ENV['BUNDLE_GEMFILE'] return gemfile if gemfile && !gemfile.empty? - File.expand_path("../Gemfile", __dir__) + File.expand_path('../Gemfile', __dir__) end def lockfile lockfile = case File.basename(gemfile) - when "gems.rb" then gemfile.sub(/\.rb$/, ".locked") - else "#{gemfile}.lock" + when 'gems.rb' then gemfile.sub(/\.rb$/, '.locked') + else "#{gemfile}.lock" end File.expand_path(lockfile) end def lockfile_version return unless File.file?(lockfile) + lockfile_contents = File.read(lockfile) return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/ + Regexp.last_match(1) end @@ -76,20 +80,22 @@ m = Module.new do end def load_bundler! - ENV["BUNDLE_GEMFILE"] ||= gemfile + ENV['BUNDLE_GEMFILE'] ||= gemfile activate_bundler end def activate_bundler gem_error = activation_error_handling do - gem "bundler", bundler_requirement + gem 'bundler', bundler_requirement end return if gem_error.nil? + require_error = activation_error_handling do - require "bundler/version" + require 'bundler/version' end return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION)) + warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`" exit 42 end @@ -105,5 +111,5 @@ end m.load_bundler! if m.invoked_as_script? - load Gem.bin_path("bundler", "bundle") + load Gem.bin_path('bundler', 'bundle') end diff --git a/bin/importmap b/bin/importmap index 36502ab..d423864 100755 --- a/bin/importmap +++ b/bin/importmap @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +# frozen_string_literal: true -require_relative "../config/application" -require "importmap/commands" +require_relative '../config/application' +require 'importmap/commands' diff --git a/bin/rails b/bin/rails index efc0377..dd027b4 100755 --- a/bin/rails +++ b/bin/rails @@ -1,4 +1,5 @@ #!/usr/bin/env ruby -APP_PATH = File.expand_path("../config/application", __dir__) -require_relative "../config/boot" -require "rails/commands" +# frozen_string_literal: true +APP_PATH = File.expand_path('../config/application', __dir__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/bin/rake b/bin/rake index 4fbf10b..609af74 100755 --- a/bin/rake +++ b/bin/rake @@ -1,4 +1,5 @@ #!/usr/bin/env ruby -require_relative "../config/boot" -require "rake" +# frozen_string_literal: true +require_relative '../config/boot' +require 'rake' Rake.application.run diff --git a/bin/setup b/bin/setup index ec47b79..f500d54 100755 --- a/bin/setup +++ b/bin/setup @@ -1,8 +1,9 @@ #!/usr/bin/env ruby -require "fileutils" +# frozen_string_literal: true +require 'fileutils' # path to your application root. -APP_ROOT = File.expand_path("..", __dir__) +APP_ROOT = File.expand_path('..', __dir__) def system!(*args) system(*args) || abort("\n== Command #{args} failed ==") @@ -13,9 +14,9 @@ FileUtils.chdir APP_ROOT do # This script is idempotent, so that you can run it at any time and get an expectable outcome. # Add necessary setup steps to this file. - puts "== Installing dependencies ==" - system! "gem install bundler --conservative" - system("bundle check") || system!("bundle install") + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') # puts "\n== Copying sample files ==" # unless File.exist?("config/database.yml") @@ -23,11 +24,11 @@ FileUtils.chdir APP_ROOT do # end puts "\n== Preparing database ==" - system! "bin/rails db:prepare" + system! 'bin/rails db:prepare' puts "\n== Removing old logs and tempfiles ==" - system! "bin/rails log:clear tmp:clear" + system! 'bin/rails log:clear tmp:clear' puts "\n== Restarting application server ==" - system! "bin/rails restart" + system! 'bin/rails restart' end diff --git a/config.ru b/config.ru index 4a3c09a..7999c79 100644 --- a/config.ru +++ b/config.ru @@ -1,6 +1,7 @@ +# frozen_string_literal: true # This file is used by Rack-based servers to start the application. -require_relative "config/environment" +require_relative 'config/environment' run Rails.application Rails.application.load_server diff --git a/config/application.rb b/config/application.rb index 604ffe7..1e70dc7 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,34 +1,40 @@ -require_relative "boot" +# frozen_string_literal: true +require_relative 'boot' -require "rails" +require 'rails' # Pick the frameworks you want: -require "active_model/railtie" -require "active_job/railtie" -require "active_record/railtie" +require 'active_model/railtie' +require 'active_job/railtie' +require 'active_record/railtie' # require "active_storage/engine" -require "action_controller/railtie" +require 'action_controller/railtie' # require "action_mailer/railtie" # require "action_mailbox/engine" # require "action_text/engine" -require "action_view/railtie" -require "action_cable/engine" -require "rails/test_unit/railtie" +require 'action_view/railtie' +require 'action_cable/engine' +require 'rails/test_unit/railtie' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) -module Foalfetch - class Application < Rails::Application - # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 7.0 +# Configuration for the application, engines, and railties goes here. +# +# These settings can be overridden in specific environments using the files +# in config/environments, which are processed later. +# +# config.time_zone = "Central Time (US & Canada)" +# config.eager_load_paths << Rails.root.join("extras") +class Foalfetch::Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 7.0 - # Configuration for the application, engines, and railties goes here. - # - # These settings can be overridden in specific environments using the files - # in config/environments, which are processed later. - # - # config.time_zone = "Central Time (US & Canada)" - # config.eager_load_paths << Rails.root.join("extras") - end + # Configuration for the application, engines, and railties goes here. + # + # These settings can be overridden in specific environments using the files + # in config/environments, which are processed later. + # + # config.time_zone = "Central Time (US & Canada)" + # config.eager_load_paths << Rails.root.join("extras") end diff --git a/config/boot.rb b/config/boot.rb index 2820116..9be337a 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,3 +1,4 @@ -ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) +# frozen_string_literal: true +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) -require "bundler/setup" # Set up gems listed in the Gemfile. +require 'bundler/setup' # Set up gems listed in the Gemfile. diff --git a/config/environment.rb b/config/environment.rb index cac5315..12ea62f 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,6 @@ +# frozen_string_literal: true # Load the Rails application. -require_relative "application" +require_relative 'application' # Initialize the Rails application. Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index 96d7ccd..4f0b085 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,4 +1,5 @@ -require "active_support/core_ext/integer/time" +# frozen_string_literal: true +require 'active_support/core_ext/integer/time' Rails.application.configure do config.after_initialize do @@ -28,13 +29,13 @@ Rails.application.configure do # Enable/disable caching. By default caching is disabled. # Run rails dev:cache to toggle caching. - if Rails.root.join("tmp/caching-dev.txt").exist? + if Rails.root.join('tmp/caching-dev.txt').exist? config.action_controller.perform_caching = true config.action_controller.enable_fragment_cache_logging = true config.cache_store = :memory_store config.public_file_server.headers = { - "Cache-Control" => "public, max-age=#{2.days.to_i}" + 'Cache-Control' => "public, max-age=#{2.days.to_i}" } else config.action_controller.perform_caching = false diff --git a/config/environments/production.rb b/config/environments/production.rb index d84da77..896b188 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,4 +1,5 @@ -require "active_support/core_ext/integer/time" +# frozen_string_literal: true +require 'active_support/core_ext/integer/time' Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. @@ -22,7 +23,7 @@ Rails.application.configure do # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. - config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? # Compress CSS using a preprocessor. # config.assets.css_compressor = :sass @@ -50,7 +51,7 @@ Rails.application.configure do config.log_level = :info # Prepend all log lines with the following tags. - config.log_tags = [ :request_id ] + config.log_tags = [:request_id] # Use a different cache store in production. # config.cache_store = :mem_cache_store @@ -67,13 +68,13 @@ Rails.application.configure do config.active_support.report_deprecations = false # Use default logging formatter so that PID and timestamp are not suppressed. - config.log_formatter = ::Logger::Formatter.new + config.log_formatter = Logger::Formatter.new # Use a different logger for distributed setups. # require "syslog/logger" # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name") - if ENV["RAILS_LOG_TO_STDOUT"].present? + if ENV['RAILS_LOG_TO_STDOUT'].present? logger = ActiveSupport::Logger.new(STDOUT) logger.formatter = config.log_formatter config.logger = ActiveSupport::TaggedLogging.new(logger) diff --git a/config/environments/test.rb b/config/environments/test.rb index eb2f171..d668df9 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,4 +1,5 @@ -require "active_support/core_ext/integer/time" +# frozen_string_literal: true +require 'active_support/core_ext/integer/time' # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that @@ -14,12 +15,12 @@ Rails.application.configure do # Eager loading loads your whole application. When running a single test locally, # this probably isn't necessary. It's a good idea to do in a continuous integration # system, or in some way before deploying your code. - config.eager_load = ENV["CI"].present? + config.eager_load = ENV['CI'].present? # Configure public file server for tests with Cache-Control for performance. config.public_file_server.enabled = true config.public_file_server.headers = { - "Cache-Control" => "public, max-age=#{1.hour.to_i}" + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" } # Show full error reports and disable caching. diff --git a/config/importmap.rb b/config/importmap.rb index 909dfc5..ec1b844 100644 --- a/config/importmap.rb +++ b/config/importmap.rb @@ -1,7 +1,8 @@ +# frozen_string_literal: true # Pin npm packages by running ./bin/importmap -pin "application" -pin "@hotwired/turbo-rails", to: "turbo.min.js" -pin "@hotwired/stimulus", to: "stimulus.min.js" -pin "@hotwired/stimulus-loading", to: "stimulus-loading.js" -pin_all_from "app/javascript/controllers", under: "controllers" +pin 'application' +pin '@hotwired/turbo-rails', to: 'turbo.min.js' +pin '@hotwired/stimulus', to: 'stimulus.min.js' +pin '@hotwired/stimulus-loading', to: 'stimulus-loading.js' +pin_all_from 'app/javascript/controllers', under: 'controllers' diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 2eeef96..f7deda5 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -1,7 +1,8 @@ +# frozen_string_literal: true # Be sure to restart your server when you modify this file. # Version of your assets, change this if you want to expire all your assets. -Rails.application.config.assets.version = "1.0" +Rails.application.config.assets.version = '1.0' # Add additional assets to the asset load path. # Rails.application.config.assets.paths << Emoji.images_path diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index 54f47cf..691cfa1 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # Be sure to restart your server when you modify this file. # Define an application-wide content security policy. diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index adc6568..93964ab 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -1,8 +1,9 @@ +# frozen_string_literal: true # Be sure to restart your server when you modify this file. # Configure parameters to be filtered from the log file. Use this to limit dissemination of # sensitive information. See the ActiveSupport::ParameterFilter documentation for supported # notations and behaviors. -Rails.application.config.filter_parameters += [ - :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn +Rails.application.config.filter_parameters += %i[ + passw secret token _key crypt salt certificate otp ssn ] diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index 3860f65..6c78420 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # Be sure to restart your server when you modify this file. # Add new inflection rules using the following format. Inflections diff --git a/config/initializers/permissions_policy.rb b/config/initializers/permissions_policy.rb index 00f64d7..50bcf4e 100644 --- a/config/initializers/permissions_policy.rb +++ b/config/initializers/permissions_policy.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # Define an application-wide HTTP permissions policy. For further # information see https://developers.google.com/web/updates/2018/06/feature-policy # diff --git a/config/initializers/redis.rb b/config/initializers/redis.rb index df64f5d..1e51582 100644 --- a/config/initializers/redis.rb +++ b/config/initializers/redis.rb @@ -2,7 +2,7 @@ ENV['REDIS_HOST'] ||= 'localhost' -#require 'hiredis' +# require 'hiredis' require 'redis' $redis = Redis.new(host: ENV['REDIS_HOST']) diff --git a/config/puma.rb b/config/puma.rb index daaf036..124410e 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,28 +1,29 @@ +# frozen_string_literal: true # Puma can serve each request in a thread from an internal thread pool. # The `threads` method setting takes two numbers: a minimum and maximum. # Any libraries that use thread pools should be configured to match # the maximum value specified for Puma. Default is set to 5 threads for minimum # and maximum; this matches the default thread size of Active Record. # -max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } -min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } +max_threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 } +min_threads_count = ENV.fetch('RAILS_MIN_THREADS') { max_threads_count } threads min_threads_count, max_threads_count # Specifies the `worker_timeout` threshold that Puma will use to wait before # terminating a worker in development environments. # -worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" +worker_timeout 3600 if ENV.fetch('RAILS_ENV', 'development') == 'development' # Specifies the `port` that Puma will listen on to receive requests; default is 3000. # -port ENV.fetch("PORT") { 3000 } +port ENV.fetch('PORT') { 3000 } # Specifies the `environment` that Puma will run in. # -environment ENV.fetch("RAILS_ENV") { "development" } +environment ENV.fetch('RAILS_ENV') { 'development' } # Specifies the `pidfile` that Puma will use. -pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } +pidfile ENV.fetch('PIDFILE') { 'tmp/pids/server.pid' } # Specifies the number of `workers` to boot in clustered mode. # Workers are forked web server processes. If using threads and workers together diff --git a/config/routes.rb b/config/routes.rb index 6faf6df..5ea098e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true Rails.application.routes.draw do root 'search#index' post '/search' => 'search#search' diff --git a/db/seeds.rb b/db/seeds.rb index bc25fce..0664d1b 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup). # diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb index d19212a..7ff7b4d 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -1,4 +1,5 @@ -require "test_helper" +# frozen_string_literal: true +require 'test_helper' class ApplicationSystemTestCase < ActionDispatch::SystemTestCase driven_by :selenium, using: :chrome, screen_size: [1400, 1400] diff --git a/test/channels/application_cable/connection_test.rb b/test/channels/application_cable/connection_test.rb index 800405f..9d96719 100644 --- a/test/channels/application_cable/connection_test.rb +++ b/test/channels/application_cable/connection_test.rb @@ -1,4 +1,5 @@ -require "test_helper" +# frozen_string_literal: true +require 'test_helper' class ApplicationCable::ConnectionTest < ActionCable::Connection::TestCase # test "connects with cookies" do diff --git a/test/controllers/authors_controller_test.rb b/test/controllers/authors_controller_test.rb index 088844c..968c04a 100644 --- a/test/controllers/authors_controller_test.rb +++ b/test/controllers/authors_controller_test.rb @@ -1,4 +1,5 @@ -require "test_helper" +# frozen_string_literal: true +require 'test_helper' class AuthorsControllerTest < ActionDispatch::IntegrationTest # test "the truth" do diff --git a/test/controllers/chapters_controller_test.rb b/test/controllers/chapters_controller_test.rb index 9c91965..cfca8e8 100644 --- a/test/controllers/chapters_controller_test.rb +++ b/test/controllers/chapters_controller_test.rb @@ -1,4 +1,5 @@ -require "test_helper" +# frozen_string_literal: true +require 'test_helper' class ChaptersControllerTest < ActionDispatch::IntegrationTest # test "the truth" do diff --git a/test/controllers/images_controller_test.rb b/test/controllers/images_controller_test.rb index 086c20d..5d9b3eb 100644 --- a/test/controllers/images_controller_test.rb +++ b/test/controllers/images_controller_test.rb @@ -1,4 +1,5 @@ -require "test_helper" +# frozen_string_literal: true +require 'test_helper' class ImagesControllerTest < ActionDispatch::IntegrationTest # test "the truth" do diff --git a/test/controllers/search_controller_test.rb b/test/controllers/search_controller_test.rb index 3b2d011..95d3447 100644 --- a/test/controllers/search_controller_test.rb +++ b/test/controllers/search_controller_test.rb @@ -1,4 +1,5 @@ -require "test_helper" +# frozen_string_literal: true +require 'test_helper' class SearchControllerTest < ActionDispatch::IntegrationTest # test "the truth" do diff --git a/test/controllers/static_pages_controller_test.rb b/test/controllers/static_pages_controller_test.rb index bbd5bd9..1f9ab34 100644 --- a/test/controllers/static_pages_controller_test.rb +++ b/test/controllers/static_pages_controller_test.rb @@ -1,4 +1,5 @@ -require "test_helper" +# frozen_string_literal: true +require 'test_helper' class StaticPagesControllerTest < ActionDispatch::IntegrationTest # test "the truth" do diff --git a/test/controllers/stories_controller_test.rb b/test/controllers/stories_controller_test.rb index 5c4a3da..006d7e3 100644 --- a/test/controllers/stories_controller_test.rb +++ b/test/controllers/stories_controller_test.rb @@ -1,4 +1,5 @@ -require "test_helper" +# frozen_string_literal: true +require 'test_helper' class StoriesControllerTest < ActionDispatch::IntegrationTest # test "the truth" do diff --git a/test/models/author_test.rb b/test/models/author_test.rb index 6cd7eb9..27102f6 100644 --- a/test/models/author_test.rb +++ b/test/models/author_test.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # == Schema Information # # Table name: authors @@ -10,7 +11,7 @@ # num_blog_posts :integer default(0), not null # num_followers :integer default(0), not null # -require "test_helper" +require 'test_helper' class AuthorTest < ActiveSupport::TestCase # test "the truth" do diff --git a/test/models/chapter_test.rb b/test/models/chapter_test.rb index f36de24..20011fd 100644 --- a/test/models/chapter_test.rb +++ b/test/models/chapter_test.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # == Schema Information # # Table name: chapters @@ -16,7 +17,7 @@ # # index_chapters_on_story_id (story_id) # -require "test_helper" +require 'test_helper' class ChapterTest < ActiveSupport::TestCase # test "the truth" do diff --git a/test/models/story_test.rb b/test/models/story_test.rb index eadadba..f230d11 100644 --- a/test/models/story_test.rb +++ b/test/models/story_test.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # == Schema Information # # Table name: stories @@ -25,7 +26,7 @@ # # index_stories_on_author_id (author_id) # -require "test_helper" +require 'test_helper' class StoryTest < ActiveSupport::TestCase # test "the truth" do diff --git a/test/models/tag_test.rb b/test/models/tag_test.rb index ccf7251..5425d8f 100644 --- a/test/models/tag_test.rb +++ b/test/models/tag_test.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # == Schema Information # # Table name: tags @@ -7,7 +8,7 @@ # type :text not null # old_id :text # -require "test_helper" +require 'test_helper' class TagTest < ActiveSupport::TestCase # test "the truth" do diff --git a/test/test_helper.rb b/test/test_helper.rb index d713e37..108129c 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,6 +1,7 @@ -ENV["RAILS_ENV"] ||= "test" -require_relative "../config/environment" -require "rails/test_help" +# frozen_string_literal: true +ENV['RAILS_ENV'] ||= 'test' +require_relative '../config/environment' +require 'rails/test_help' class ActiveSupport::TestCase # Run tests in parallel with specified workers