Skip to content

Commit 15ef55e

Browse files
authored
Merge pull request rails#29732 from kirs/frozen-activerecord
Use frozen-string-literal in ActiveRecord
2 parents 93c9a95 + 56de573 commit 15ef55e

File tree

678 files changed

+1367
-11
lines changed

Some content is hidden

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

678 files changed

+1367
-11
lines changed

.rubocop.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ Style/FrozenStringLiteralComment:
9090
- 'activesupport/**/*'
9191
- 'activemodel/**/*'
9292
- 'activejob/**/*'
93+
- 'activerecord/**/*'
9394

9495
# Use `foo {}` not `foo{}`.
9596
Layout/SpaceBeforeBlockBraces:

activerecord/Rakefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require "rake/testtask"
24

35
require_relative "test/config"

activerecord/activerecord.gemspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
version = File.read(File.expand_path("../RAILS_VERSION", __dir__)).strip
24

35
Gem::Specification.new do |s|

activerecord/bin/test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
23

34
COMPONENT_ROOT = File.expand_path("..", __dir__)
45
require_relative "../../tools/test"

activerecord/examples/performance.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require "active_record"
24
require "benchmark/ips"
35

activerecord/examples/simple.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require "active_record"
24

35
class Person < ActiveRecord::Base

activerecord/lib/active_record.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
#--
24
# Copyright (c) 2004-2017 David Heinemeier Hansson
35
#

activerecord/lib/active_record/aggregations.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
# See ActiveRecord::Aggregations::ClassMethods for documentation
35
module Aggregations

activerecord/lib/active_record/association_relation.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
class AssociationRelation < Relation
35
def initialize(klass, table, predicate_builder, association)

activerecord/lib/active_record/associations.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require "active_support/core_ext/enumerable"
24
require "active_support/core_ext/string/conversions"
35
require "active_support/core_ext/module/remove_method"

activerecord/lib/active_record/associations/alias_tracker.rb

Lines changed: 2 additions & 0 deletions
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/conversions"
24

35
module ActiveRecord

activerecord/lib/active_record/associations/association.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require "active_support/core_ext/array/wrap"
24

35
module ActiveRecord

activerecord/lib/active_record/associations/association_scope.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
module Associations
35
class AssociationScope #:nodoc:

activerecord/lib/active_record/associations/belongs_to_association.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
# = Active Record Belongs To Association
35
module Associations

activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
# = Active Record Belongs To Polymorphic Association
35
module Associations

activerecord/lib/active_record/associations/builder/association.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
# This is the parent Association class which defines the variables
24
# used by all associations.
35
#

activerecord/lib/active_record/associations/builder/belongs_to.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord::Associations::Builder # :nodoc:
24
class BelongsTo < SingularAssociation #:nodoc:
35
def self.macro

activerecord/lib/active_record/associations/builder/collection_association.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require_relative "../../associations"
24

35
module ActiveRecord::Associations::Builder # :nodoc:

activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord::Associations::Builder # :nodoc:
24
class HasAndBelongsToMany # :nodoc:
35
class JoinTableResolver # :nodoc:

activerecord/lib/active_record/associations/builder/has_many.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord::Associations::Builder # :nodoc:
24
class HasMany < CollectionAssociation #:nodoc:
35
def self.macro

activerecord/lib/active_record/associations/builder/has_one.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord::Associations::Builder # :nodoc:
24
class HasOne < SingularAssociation #:nodoc:
35
def self.macro

activerecord/lib/active_record/associations/builder/singular_association.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
# This class is inherited by the has_one and belongs_to association classes
24

35
module ActiveRecord::Associations::Builder # :nodoc:

activerecord/lib/active_record/associations/collection_association.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
module Associations
35
# = Active Record Association Collection

activerecord/lib/active_record/associations/collection_proxy.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
module Associations
35
# Association proxies in Active Record are middlemen between the object that

activerecord/lib/active_record/associations/foreign_association.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord::Associations
24
module ForeignAssociation # :nodoc:
35
def foreign_key_present?

activerecord/lib/active_record/associations/has_many_association.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
# = Active Record Has Many Association
35
module Associations

activerecord/lib/active_record/associations/has_many_through_association.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
# = Active Record Has Many Through Association
35
module Associations

activerecord/lib/active_record/associations/has_one_association.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
# = Active Record Has One Association
35
module Associations

activerecord/lib/active_record/associations/has_one_through_association.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
# = Active Record Has One Through Association
35
module Associations

activerecord/lib/active_record/associations/join_dependency.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
module Associations
35
class JoinDependency # :nodoc:

activerecord/lib/active_record/associations/join_dependency/join_association.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require_relative "join_part"
24

35
module ActiveRecord

activerecord/lib/active_record/associations/join_dependency/join_base.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require_relative "join_part"
24

35
module ActiveRecord

activerecord/lib/active_record/associations/join_dependency/join_part.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
module Associations
35
class JoinDependency # :nodoc:

activerecord/lib/active_record/associations/preloader.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
module Associations
35
# Implements the details of eager loading of Active Record associations.

activerecord/lib/active_record/associations/preloader/association.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
module Associations
35
class Preloader

activerecord/lib/active_record/associations/preloader/belongs_to.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
module Associations
35
class Preloader

activerecord/lib/active_record/associations/preloader/collection_association.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
module Associations
35
class Preloader

activerecord/lib/active_record/associations/preloader/has_many.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
module Associations
35
class Preloader

activerecord/lib/active_record/associations/preloader/has_many_through.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
module Associations
35
class Preloader

activerecord/lib/active_record/associations/preloader/has_one.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
module Associations
35
class Preloader

activerecord/lib/active_record/associations/preloader/has_one_through.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
module Associations
35
class Preloader

activerecord/lib/active_record/associations/preloader/singular_association.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
module Associations
35
class Preloader

activerecord/lib/active_record/associations/preloader/through_association.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
module Associations
35
class Preloader

activerecord/lib/active_record/associations/singular_association.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
module Associations
35
class SingularAssociation < Association #:nodoc:

activerecord/lib/active_record/associations/through_association.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
# = Active Record Through Association
35
module Associations

activerecord/lib/active_record/attribute.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
class Attribute # :nodoc:
35
class << self

activerecord/lib/active_record/attribute/user_provided_default.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require_relative "../attribute"
24

35
module ActiveRecord

activerecord/lib/active_record/attribute_assignment.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require "active_model/forbidden_attributes_protection"
24

35
module ActiveRecord

activerecord/lib/active_record/attribute_decorators.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
module AttributeDecorators # :nodoc:
35
extend ActiveSupport::Concern

activerecord/lib/active_record/attribute_methods.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require "mutex_m"
24

35
module ActiveRecord

activerecord/lib/active_record/attribute_methods/before_type_cast.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
module AttributeMethods
35
# = Active Record Attribute Methods Before Type Cast

activerecord/lib/active_record/attribute_methods/primary_key.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require "set"
24

35
module ActiveRecord

activerecord/lib/active_record/attribute_methods/query.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
module AttributeMethods
35
module Query

activerecord/lib/active_record/attribute_methods/read.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
module AttributeMethods
35
module Read

activerecord/lib/active_record/attribute_methods/serialization.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
module AttributeMethods
35
module Serialization

activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
module AttributeMethods
35
module TimeZoneConversion

activerecord/lib/active_record/attribute_methods/write.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
module AttributeMethods
35
module Write

activerecord/lib/active_record/attribute_mutation_tracker.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
class AttributeMutationTracker # :nodoc:
35
OPTION_NOT_GIVEN = Object.new

activerecord/lib/active_record/attribute_set.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require_relative "attribute_set/builder"
24
require_relative "attribute_set/yaml_encoder"
35

activerecord/lib/active_record/attribute_set/builder.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require_relative "../attribute"
24

35
module ActiveRecord

activerecord/lib/active_record/attribute_set/yaml_encoder.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
class AttributeSet
35
# Attempts to do more intelligent YAML dumping of an

activerecord/lib/active_record/attributes.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require_relative "attribute/user_provided_default"
24

35
module ActiveRecord

activerecord/lib/active_record/autosave_association.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
# = Active Record Autosave Association
35
#

activerecord/lib/active_record/base.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require "yaml"
24
require "active_support/benchmarkable"
35
require "active_support/dependencies"

activerecord/lib/active_record/callbacks.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
# = Active Record \Callbacks
35
#

activerecord/lib/active_record/coders/json.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ActiveRecord
24
module Coders # :nodoc:
35
class JSON # :nodoc:

0 commit comments

Comments
 (0)