Skip to content

Commit

Permalink
Enable frozen string literals across the project
Browse files Browse the repository at this point in the history
https://docs.rubocop.org/rubocop/cops_style.html#stylefrozenstringliteralcomment

This feature is designed to help transition from mutable string literals
to frozen string literals. The "frozen_string_literal: true" magic
comment was added to the top of all files to enable frozen string
literals. Frozen string literals may be default in future Ruby. Using
frozen string literals is good practice and easier to reason about.
  • Loading branch information
jdufresne committed Feb 27, 2022
1 parent a95b177 commit 4effb5f
Show file tree
Hide file tree
Showing 423 changed files with 828 additions and 6 deletions.
3 changes: 0 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,6 @@ Style/Encoding:
Style/EndlessMethod:
Enabled: true

Style/FrozenStringLiteralComment:
Enabled: false

Style/HashConversion:
Enabled: true

Expand Down
2 changes: 2 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

appraise 'rails-6.0' do
gem 'rails', '~> 6.0.0'
gem 'sassc-rails', '~> 2.1'
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'

gem 'appraisal', '>= 2.0'
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/controllers/rails_admin/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rails_admin/abstract_model'

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

module RailsAdmin
class MainController < RailsAdmin::ApplicationController
include ActionView::Helpers::TextHelper
Expand Down
2 changes: 2 additions & 0 deletions app/helpers/rails_admin/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RailsAdmin
module ApplicationHelper
def authorized?(action_name, abstract_model = nil, object = nil)
Expand Down
2 changes: 2 additions & 0 deletions app/helpers/rails_admin/form_builder.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'nested_form/builder_mixin'

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

module RailsAdmin
module MainHelper
def rails_admin_form_for(*args, &block)
Expand Down
2 changes: 2 additions & 0 deletions config/initializers/active_record_extensions.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

ActiveSupport.on_load(:active_record) do
module ActiveRecord
class Base
Expand Down
2 changes: 2 additions & 0 deletions config/initializers/mongoid_extensions.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

if defined?(::Mongoid::Document)
require 'rails_admin/adapters/mongoid/extension'
Mongoid::Document.include RailsAdmin::Adapters::Mongoid::Extension
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

RailsAdmin::Engine.routes.draw do
controller 'main' do
RailsAdmin::Config::Actions.all(:root).each { |action| match "/#{action.route_fragment}", action: action.action_name, as: action.action_name, via: action.http_methods }
Expand Down
2 changes: 2 additions & 0 deletions lib/generators/rails_admin/install_generator.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rails/generators'
require 'rails_admin/version'
require File.expand_path('utils', __dir__)
Expand Down
2 changes: 2 additions & 0 deletions lib/generators/rails_admin/utils.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RailsAdmin
module Generators
module Utils
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rails_admin/engine'
require 'rails_admin/abstract_model'
require 'rails_admin/config'
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/abstract_model.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rails_admin/support/datetime'

module RailsAdmin
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/adapters/active_record.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'active_record'
require 'rails_admin/adapters/active_record/association'
require 'rails_admin/adapters/active_record/object_extension'
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/adapters/active_record/association.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RailsAdmin
module Adapters
module ActiveRecord
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/adapters/active_record/object_extension.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RailsAdmin
module Adapters
module ActiveRecord
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/adapters/active_record/property.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RailsAdmin
module Adapters
module ActiveRecord
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/adapters/mongoid.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'mongoid'
require 'rails_admin/config/sections/list'
require 'rails_admin/adapters/mongoid/association'
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/adapters/mongoid/association.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RailsAdmin
module Adapters
module Mongoid
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/adapters/mongoid/bson.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'mongoid'

module RailsAdmin
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/adapters/mongoid/extension.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RailsAdmin
module Adapters
module Mongoid
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/adapters/mongoid/object_extension.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RailsAdmin
module Adapters
module Mongoid
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/adapters/mongoid/property.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RailsAdmin
module Adapters
module Mongoid
Expand Down
4 changes: 3 additions & 1 deletion lib/rails_admin/config.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rails_admin/config/model'
require 'rails_admin/config/sections/list'
require 'active_support/core_ext/module/attribute_accessors'
Expand Down Expand Up @@ -260,7 +262,7 @@ def model(entity, &block)
def asset_source
@asset_source ||=
begin
warn <<-MSG.gsub(/^ +/, '').freeze
warn <<-MSG.gsub(/^ +/, '')
[Warning] After upgrading RailsAdmin to 3.x you haven't set asset_source yet, using :sprockets as the default.
To suppress this message, run 'rails rails_admin:install' to setup the asset delivery method suitable to you.
MSG
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/config/actions.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RailsAdmin
module Config
module Actions
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/config/actions/base.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rails_admin/config/proxyable'
require 'rails_admin/config/configurable'
require 'rails_admin/config/hideable'
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/config/actions/bulk_delete.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RailsAdmin
module Config
module Actions
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/config/actions/dashboard.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RailsAdmin
module Config
module Actions
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/config/actions/delete.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RailsAdmin
module Config
module Actions
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/config/actions/edit.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RailsAdmin
module Config
module Actions
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/config/actions/export.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RailsAdmin
module Config
module Actions
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/config/actions/history_index.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RailsAdmin
module Config
module Actions
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/config/actions/history_show.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RailsAdmin
module Config
module Actions
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/config/actions/index.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'activemodel-serializers-xml'

module RailsAdmin
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/config/actions/new.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RailsAdmin
module Config
module Actions
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/config/actions/show.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RailsAdmin
module Config
module Actions
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/config/actions/show_in_app.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RailsAdmin
module Config
module Actions
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/config/configurable.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RailsAdmin
module Config
# A module for all configurables.
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/config/fields.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RailsAdmin
module Config
module Fields
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/config/fields/association.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rails_admin/config'
require 'rails_admin/config/fields/base'

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

require 'rails_admin/config/proxyable'
require 'rails_admin/config/configurable'
require 'rails_admin/config/hideable'
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/config/fields/factories/action_text.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rails_admin/config/fields'
require 'rails_admin/config/fields/types'

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

require 'rails_admin/config/fields'
require 'rails_admin/config/fields/types'
require 'rails_admin/config/fields/types/file_upload'
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/config/fields/factories/association.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rails_admin/config/fields'
require 'rails_admin/config/fields/types'
require 'rails_admin/config/fields/types/belongs_to_association'
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/config/fields/factories/carrierwave.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rails_admin/config/fields'
require 'rails_admin/config/fields/types'
require 'rails_admin/config/fields/types/file_upload'
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/config/fields/factories/devise.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rails_admin/config/fields'
require 'rails_admin/config/fields/types'
require 'rails_admin/config/fields/types/password'
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/config/fields/factories/dragonfly.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rails_admin/config/fields'
require 'rails_admin/config/fields/types'
require 'rails_admin/config/fields/types/file_upload'
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/config/fields/factories/enum.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rails_admin/config/fields'
require 'rails_admin/config/fields/types/enum'
require 'rails_admin/config/fields/types/active_record_enum'
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/config/fields/factories/paperclip.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rails_admin/config/fields'
require 'rails_admin/config/fields/types'
require 'rails_admin/config/fields/types/file_upload'
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/config/fields/factories/password.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rails_admin/config/fields'
require 'rails_admin/config/fields/types/password'

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

require 'rails_admin/config/fields'
require 'rails_admin/config/fields/types'
require 'rails_admin/config/fields/types/file_upload'
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/config/fields/group.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'active_support/core_ext/string/inflections'
require 'rails_admin/config/proxyable'
require 'rails_admin/config/configurable'
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/config/fields/types.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'active_support/core_ext/string/inflections'
require 'rails_admin/config/fields'
require 'rails_admin/config/fields/association'
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/config/fields/types/action_text.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rails_admin/config/fields/types/text'

module RailsAdmin
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/config/fields/types/active_record_enum.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rails_admin/config/fields/types/enum'

module RailsAdmin
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/config/fields/types/active_storage.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rails_admin/config/fields/types/file_upload'

module RailsAdmin
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/config/fields/types/all.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rails_admin/config/fields/types/action_text'
require 'rails_admin/config/fields/types/active_record_enum'
require 'rails_admin/config/fields/types/active_storage'
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/config/fields/types/belongs_to_association.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rails_admin/config/fields/association'

module RailsAdmin
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/config/fields/types/boolean.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RailsAdmin
module Config
module Fields
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/config/fields/types/bson_object_id.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rails_admin/config/fields/types/string'

module RailsAdmin
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_admin/config/fields/types/carrierwave.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rails_admin/config/fields/base'
require 'rails_admin/config/fields/types/file_upload'

Expand Down
Loading

0 comments on commit 4effb5f

Please sign in to comment.