Skip to content

Commit

Permalink
Add FrozenStringLiteral = true
Browse files Browse the repository at this point in the history
  • Loading branch information
the-teacher committed Jan 29, 2023
1 parent 8315730 commit 6b572c4
Show file tree
Hide file tree
Showing 60 changed files with 120 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require: rubocop-rails
Style/FrozenStringLiteralComment:
Enabled: false
Enabled: true
Style/Documentation:
Enabled: false
Style/StringLiterals:
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

Expand Down
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# 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: 2 additions & 0 deletions app/channels/application_cable/channel.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ApplicationCable
class Channel < ActionCable::Channel::Base
end
Expand Down
2 changes: 2 additions & 0 deletions app/channels/application_cable/connection.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ApplicationCable
class Connection < ActionCable::Connection::Base
end
Expand Down
2 changes: 2 additions & 0 deletions app/chewy/articles_index.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# @articles = ArticlesIndex.query(
# query_string: {
# query: 'Article',
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

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

class DemoController < ApplicationController
def index
# Example of ElasticSearch/Chewy search
Expand Down
2 changes: 2 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

module ApplicationHelper
end
2 changes: 2 additions & 0 deletions app/helpers/articles_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

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

class ApplicationJob < ActiveJob::Base
# Automatically retry jobs that encountered a deadlock
# retry_on ActiveRecord::Deadlocked
Expand Down
2 changes: 2 additions & 0 deletions app/jobs/example_job.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ExampleJob < ApplicationJob
queue_as :default

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

class ApplicationMailer < ActionMailer::Base
default from: "from@example.com"
layout "mailer"
Expand Down
2 changes: 2 additions & 0 deletions app/mailers/demo_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# rails generate mailer demo
#
# DemoMailer.welcome_email.deliver!
Expand Down
2 changes: 2 additions & 0 deletions app/models/application_record.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ApplicationRecord < ActiveRecord::Base
primary_abstract_class
end
2 changes: 2 additions & 0 deletions app/models/article.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# rails g model Article
# title:string
# content_raw:text
Expand Down
4 changes: 3 additions & 1 deletion app/models/currency_rate.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# rails g model currency_rate
# from:string
# to:string
Expand All @@ -8,7 +10,7 @@
# rails runner "CurrencyRate.get('USD', 'EUR')"

class CurrencyRate < ApplicationRecord
API = 'https://api.exchangerate.host/latest'.freeze
API = 'https://api.exchangerate.host/latest'

def self.get(from = 'USD', to = 'EUR')
uri = URI(CurrencyRate::API + "?base=#{from}&symbols=#{to}")
Expand Down
2 changes: 2 additions & 0 deletions bin/helpers/chewy.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

def chewy_index
puts 'Indexing with CHEWY'
container_exec('rails', 'rake chewy:update')
Expand Down
2 changes: 2 additions & 0 deletions bin/helpers/common.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

def prompt!(message = 'Are you sure to continue? [y/Y]')
puts message
prompt = $stdin.gets.chomp
Expand Down
2 changes: 2 additions & 0 deletions bin/helpers/cron.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

def cron_start
container_exec('--user root rails', '/etc/init.d/cron start')
end
Expand Down
2 changes: 2 additions & 0 deletions bin/helpers/docker.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

def check_docker!
return if system('docker -v')

Expand Down
4 changes: 3 additions & 1 deletion bin/helpers/helpers.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative './common'
require_relative './docker'
require_relative './chewy'
Expand All @@ -9,7 +11,7 @@
require_relative './rubocop'

DELAY = 3
ENV_NAME = ENV.fetch('RAILS_ENV') { 'development' }
ENV_NAME = ENV.fetch('RAILS_ENV', 'development')

$steps_counter = 1
$steps_messages = []
Expand Down
2 changes: 2 additions & 0 deletions bin/helpers/puma.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

def puma_start
puts 'Launching PUMA'
container_bash_exec('rails', @puma_start_command, detached = true)
Expand Down
2 changes: 2 additions & 0 deletions bin/helpers/rails.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

def rails_install_gems
puts 'Install Gems'
container_bash_exec('rails', 'bundle install')
Expand Down
2 changes: 2 additions & 0 deletions bin/helpers/rubocop.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

def rubocop
container_bash_exec('rails', 'rubocop --require rubocop-rails')
end
Expand Down
2 changes: 2 additions & 0 deletions bin/helpers/sidekiq.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

def sidekiq_start
puts 'Launching SIDEKIQ'
container_bash_exec('rails', 'bundle exec sidekiq -C config/_SIDEKIQ.yml', detached = true)
Expand Down
2 changes: 2 additions & 0 deletions bin/helpers/whenever.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

def whenever_start
container_exec('rails', 'bundle exec whenever --update-crontab --load-file config/_SCHEDULE.rb -i lucky')
end
Expand Down
2 changes: 2 additions & 0 deletions config.ru
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# This file is used by Rack-based servers to start the application.

require_relative 'config/environment'
Expand Down
4 changes: 3 additions & 1 deletion config/_PUMA.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# frozen_string_literal: true

workers 1
threads 2, 4

env_name = ENV.fetch('RAILS_ENV') { 'development' }
env_name = ENV.fetch('RAILS_ENV', 'development')
environment env_name

if env_name == 'development'
Expand Down
4 changes: 3 additions & 1 deletion config/_SCHEDULE.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Learn more: http://github.com/javan/whenever
#
# How to initialize whenever
Expand All @@ -13,7 +15,7 @@
# crontab -l

env :GEM_HOME, ENV['GEM_HOME']
set :environment, ENV.fetch('RAILS_ENV') { 'development' }
set :environment, ENV.fetch('RAILS_ENV', 'development')

set :output, {
standard: '/home/lucky/app/log/cron.log',
Expand Down
2 changes: 2 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative "boot"

require "rails/all"
Expand Down
2 changes: 2 additions & 0 deletions config/boot.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)

require "bundler/setup" # Set up gems listed in the Gemfile.
Expand Down
2 changes: 2 additions & 0 deletions config/environment.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Load the Rails application.
require_relative 'application'

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

require "active_support/core_ext/integer/time"

Rails.application.configure do
Expand Down
2 changes: 2 additions & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "active_support/core_ext/integer/time"

Rails.application.configure do
Expand Down
2 changes: 2 additions & 0 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "active_support/core_ext/integer/time"

# The test environment is used exclusively to run your application's
Expand Down
2 changes: 2 additions & 0 deletions config/importmap.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Pin npm packages by running ./bin/importmap

pin "application", preload: true
2 changes: 2 additions & 0 deletions config/initializers/_CHEWY.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

elastic_host = Settings.elastic.host
elastic_port = Settings.elastic.port

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

app = Rails.application

settings_file = "#{app.config.root}/config/_CONFIG.yml"
Expand Down
2 changes: 2 additions & 0 deletions config/initializers/_REDIS.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

redis_port = Settings.redis.port
redis_host = Settings.redis.host

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

# bundle exec sidekiq -C config/sidekiq.yml

redis_port = Settings.redis.port
Expand Down
2 changes: 2 additions & 0 deletions config/initializers/assets.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# 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.
Expand Down
2 changes: 2 additions & 0 deletions config/initializers/config.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

Config.setup do |config|
# Name of the constant exposing loaded settings
config.const_name = 'Settings'
Expand Down
1 change: 1 addition & 0 deletions config/initializers/content_security_policy.rb
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 2 additions & 0 deletions config/initializers/filter_parameter_logging.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# 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
Expand Down
1 change: 1 addition & 0 deletions config/initializers/inflections.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions config/initializers/permissions_policy.rb
Original file line number Diff line number Diff line change
@@ -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
#
Expand Down
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

Rails.application.routes.draw do
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html

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

class CreateArticles < ActiveRecord::Migration[7.0]
def change
create_table :articles do |t|
Expand Down
2 changes: 2 additions & 0 deletions db/migrate/20230121113818_create_currency_rates.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class CreateCurrencyRates < ActiveRecord::Migration[7.0]
def change
create_table :currency_rates do |t|
Expand Down
2 changes: 2 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# 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).
#
Expand Down
2 changes: 2 additions & 0 deletions test/application_system_test_case.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'test_helper'

class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
Expand Down
2 changes: 2 additions & 0 deletions test/channels/application_cable/connection_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'test_helper'

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

require 'test_helper'

class DemoControllerTest < ActionDispatch::IntegrationTest
Expand Down
2 changes: 2 additions & 0 deletions test/jobs/example_job_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'test_helper'

class ExampleJobTest < ActiveJob::TestCase
Expand Down
2 changes: 2 additions & 0 deletions test/mailers/demo_mailer_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'test_helper'

class DemoMailerTest < ActionMailer::TestCase
Expand Down
2 changes: 2 additions & 0 deletions test/mailers/previews/demo_mailer_preview.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Preview all emails at http://localhost:3000/rails/mailers/demo_mailer
class DemoMailerPreview < ActionMailer::Preview
# Accessible from http://localhost:3000/rails/mailers/demo_mailer/welcome_email
Expand Down
2 changes: 2 additions & 0 deletions test/models/article_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'test_helper'

class ArticleTest < ActiveSupport::TestCase
Expand Down
2 changes: 2 additions & 0 deletions test/models/currency_rate_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'test_helper'

class CurrencyRateTest < ActiveSupport::TestCase
Expand Down
2 changes: 2 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

ENV["RAILS_ENV"] ||= "test"
require_relative "../config/environment"
require "rails/test_help"
Expand Down

0 comments on commit 6b572c4

Please sign in to comment.