Skip to content

Commit 94e599b

Browse files
authored
Enable frozen string literals across the project (#3483)
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.
1 parent a95b177 commit 94e599b

File tree

423 files changed

+828
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

423 files changed

+828
-6
lines changed

.rubocop.yml

-3
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,6 @@ Style/Encoding:
168168
Style/EndlessMethod:
169169
Enabled: true
170170

171-
Style/FrozenStringLiteralComment:
172-
Enabled: false
173-
174171
Style/HashConversion:
175172
Enabled: true
176173

Appraisals

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
appraise 'rails-6.0' do
24
gem 'rails', '~> 6.0.0'
35
gem 'sassc-rails', '~> 2.1'

Gemfile

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
source 'https://rubygems.org'
24

35
gem 'appraisal', '>= 2.0'

Rakefile

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
# Add your own tasks in files placed in lib/tasks ending in .rake,
24
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
35

app/controllers/rails_admin/application_controller.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'rails_admin/abstract_model'
24

35
module RailsAdmin

app/controllers/rails_admin/main_controller.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module RailsAdmin
24
class MainController < RailsAdmin::ApplicationController
35
include ActionView::Helpers::TextHelper

app/helpers/rails_admin/application_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module RailsAdmin
24
module ApplicationHelper
35
def authorized?(action_name, abstract_model = nil, object = nil)

app/helpers/rails_admin/form_builder.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'nested_form/builder_mixin'
24

35
module RailsAdmin

app/helpers/rails_admin/main_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module RailsAdmin
24
module MainHelper
35
def rails_admin_form_for(*args, &block)

config/initializers/active_record_extensions.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
ActiveSupport.on_load(:active_record) do
24
module ActiveRecord
35
class Base

config/initializers/mongoid_extensions.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
if defined?(::Mongoid::Document)
24
require 'rails_admin/adapters/mongoid/extension'
35
Mongoid::Document.include RailsAdmin::Adapters::Mongoid::Extension

config/routes.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
RailsAdmin::Engine.routes.draw do
24
controller 'main' do
35
RailsAdmin::Config::Actions.all(:root).each { |action| match "/#{action.route_fragment}", action: action.action_name, as: action.action_name, via: action.http_methods }

lib/generators/rails_admin/install_generator.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'rails/generators'
24
require 'rails_admin/version'
35
require File.expand_path('utils', __dir__)

lib/generators/rails_admin/utils.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module RailsAdmin
24
module Generators
35
module Utils

lib/rails_admin.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'rails_admin/engine'
24
require 'rails_admin/abstract_model'
35
require 'rails_admin/config'

lib/rails_admin/abstract_model.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'rails_admin/support/datetime'
24

35
module RailsAdmin

lib/rails_admin/adapters/active_record.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'active_record'
24
require 'rails_admin/adapters/active_record/association'
35
require 'rails_admin/adapters/active_record/object_extension'

lib/rails_admin/adapters/active_record/association.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module RailsAdmin
24
module Adapters
35
module ActiveRecord

lib/rails_admin/adapters/active_record/object_extension.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module RailsAdmin
24
module Adapters
35
module ActiveRecord

lib/rails_admin/adapters/active_record/property.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module RailsAdmin
24
module Adapters
35
module ActiveRecord

lib/rails_admin/adapters/mongoid.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'mongoid'
24
require 'rails_admin/config/sections/list'
35
require 'rails_admin/adapters/mongoid/association'

lib/rails_admin/adapters/mongoid/association.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module RailsAdmin
24
module Adapters
35
module Mongoid

lib/rails_admin/adapters/mongoid/bson.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'mongoid'
24

35
module RailsAdmin

lib/rails_admin/adapters/mongoid/extension.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module RailsAdmin
24
module Adapters
35
module Mongoid

lib/rails_admin/adapters/mongoid/object_extension.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module RailsAdmin
24
module Adapters
35
module Mongoid

lib/rails_admin/adapters/mongoid/property.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module RailsAdmin
24
module Adapters
35
module Mongoid

lib/rails_admin/config.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'rails_admin/config/model'
24
require 'rails_admin/config/sections/list'
35
require 'active_support/core_ext/module/attribute_accessors'
@@ -260,7 +262,7 @@ def model(entity, &block)
260262
def asset_source
261263
@asset_source ||=
262264
begin
263-
warn <<-MSG.gsub(/^ +/, '').freeze
265+
warn <<-MSG.gsub(/^ +/, '')
264266
[Warning] After upgrading RailsAdmin to 3.x you haven't set asset_source yet, using :sprockets as the default.
265267
To suppress this message, run 'rails rails_admin:install' to setup the asset delivery method suitable to you.
266268
MSG

lib/rails_admin/config/actions.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module RailsAdmin
24
module Config
35
module Actions

lib/rails_admin/config/actions/base.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'rails_admin/config/proxyable'
24
require 'rails_admin/config/configurable'
35
require 'rails_admin/config/hideable'

lib/rails_admin/config/actions/bulk_delete.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module RailsAdmin
24
module Config
35
module Actions

lib/rails_admin/config/actions/dashboard.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module RailsAdmin
24
module Config
35
module Actions

lib/rails_admin/config/actions/delete.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module RailsAdmin
24
module Config
35
module Actions

lib/rails_admin/config/actions/edit.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module RailsAdmin
24
module Config
35
module Actions

lib/rails_admin/config/actions/export.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module RailsAdmin
24
module Config
35
module Actions

lib/rails_admin/config/actions/history_index.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module RailsAdmin
24
module Config
35
module Actions

lib/rails_admin/config/actions/history_show.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module RailsAdmin
24
module Config
35
module Actions

lib/rails_admin/config/actions/index.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'activemodel-serializers-xml'
24

35
module RailsAdmin

lib/rails_admin/config/actions/new.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module RailsAdmin
24
module Config
35
module Actions

lib/rails_admin/config/actions/show.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module RailsAdmin
24
module Config
35
module Actions

lib/rails_admin/config/actions/show_in_app.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module RailsAdmin
24
module Config
35
module Actions

lib/rails_admin/config/configurable.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module RailsAdmin
24
module Config
35
# A module for all configurables.

lib/rails_admin/config/fields.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module RailsAdmin
24
module Config
35
module Fields

lib/rails_admin/config/fields/association.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'rails_admin/config'
24
require 'rails_admin/config/fields/base'
35

lib/rails_admin/config/fields/base.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'rails_admin/config/proxyable'
24
require 'rails_admin/config/configurable'
35
require 'rails_admin/config/hideable'

lib/rails_admin/config/fields/factories/action_text.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'rails_admin/config/fields'
24
require 'rails_admin/config/fields/types'
35

lib/rails_admin/config/fields/factories/active_storage.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'rails_admin/config/fields'
24
require 'rails_admin/config/fields/types'
35
require 'rails_admin/config/fields/types/file_upload'

lib/rails_admin/config/fields/factories/association.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'rails_admin/config/fields'
24
require 'rails_admin/config/fields/types'
35
require 'rails_admin/config/fields/types/belongs_to_association'

lib/rails_admin/config/fields/factories/carrierwave.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'rails_admin/config/fields'
24
require 'rails_admin/config/fields/types'
35
require 'rails_admin/config/fields/types/file_upload'

lib/rails_admin/config/fields/factories/devise.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'rails_admin/config/fields'
24
require 'rails_admin/config/fields/types'
35
require 'rails_admin/config/fields/types/password'

lib/rails_admin/config/fields/factories/dragonfly.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'rails_admin/config/fields'
24
require 'rails_admin/config/fields/types'
35
require 'rails_admin/config/fields/types/file_upload'

lib/rails_admin/config/fields/factories/enum.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'rails_admin/config/fields'
24
require 'rails_admin/config/fields/types/enum'
35
require 'rails_admin/config/fields/types/active_record_enum'

lib/rails_admin/config/fields/factories/paperclip.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'rails_admin/config/fields'
24
require 'rails_admin/config/fields/types'
35
require 'rails_admin/config/fields/types/file_upload'

lib/rails_admin/config/fields/factories/password.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'rails_admin/config/fields'
24
require 'rails_admin/config/fields/types/password'
35

lib/rails_admin/config/fields/factories/shrine.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'rails_admin/config/fields'
24
require 'rails_admin/config/fields/types'
35
require 'rails_admin/config/fields/types/file_upload'

lib/rails_admin/config/fields/group.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'active_support/core_ext/string/inflections'
24
require 'rails_admin/config/proxyable'
35
require 'rails_admin/config/configurable'

lib/rails_admin/config/fields/types.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'active_support/core_ext/string/inflections'
24
require 'rails_admin/config/fields'
35
require 'rails_admin/config/fields/association'

lib/rails_admin/config/fields/types/action_text.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'rails_admin/config/fields/types/text'
24

35
module RailsAdmin

lib/rails_admin/config/fields/types/active_record_enum.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'rails_admin/config/fields/types/enum'
24

35
module RailsAdmin

lib/rails_admin/config/fields/types/active_storage.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'rails_admin/config/fields/types/file_upload'
24

35
module RailsAdmin

lib/rails_admin/config/fields/types/all.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'rails_admin/config/fields/types/action_text'
24
require 'rails_admin/config/fields/types/active_record_enum'
35
require 'rails_admin/config/fields/types/active_storage'

lib/rails_admin/config/fields/types/belongs_to_association.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'rails_admin/config/fields/association'
24

35
module RailsAdmin

lib/rails_admin/config/fields/types/boolean.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module RailsAdmin
24
module Config
35
module Fields

lib/rails_admin/config/fields/types/bson_object_id.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'rails_admin/config/fields/types/string'
24

35
module RailsAdmin

lib/rails_admin/config/fields/types/carrierwave.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'rails_admin/config/fields/base'
24
require 'rails_admin/config/fields/types/file_upload'
35

0 commit comments

Comments
 (0)