Skip to content

Commit

Permalink
Use frozen-string-literal in ActiveSupport
Browse files Browse the repository at this point in the history
  • Loading branch information
kirs committed Jul 9, 2017
1 parent 6f2b0eb commit 7295056
Show file tree
Hide file tree
Showing 429 changed files with 434 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ Layout/SpaceBeforeFirstArg:
Style/MethodDefParentheses:
Enabled: true

Style/FrozenStringLiteralComment:
Enabled: true
EnforcedStyle: always
Include:
- 'activesupport/**/*'

# Use `foo {}` not `foo{}`.
Layout/SpaceBeforeBlockBraces:
Enabled: true
Expand Down
1 change: 1 addition & 0 deletions activesupport/Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "rake/testtask"

task default: :test
Expand Down
1 change: 1 addition & 0 deletions activesupport/activesupport.gemspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
version = File.read(File.expand_path("../RAILS_VERSION", __dir__)).strip

Gem::Specification.new do |s|
Expand Down
1 change: 1 addition & 0 deletions activesupport/bin/generate_tables
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

begin
$:.unshift(File.expand_path("../lib", __dir__))
Expand Down
1 change: 1 addition & 0 deletions activesupport/bin/test
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

COMPONENT_ROOT = File.expand_path("..", __dir__)
require_relative "../../tools/test"
1 change: 1 addition & 0 deletions activesupport/lib/active_support.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
#--
# Copyright (c) 2005-2017 David Heinemeier Hansson
#
Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/all.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "active_support"
require_relative "time"
require_relative "core_ext"
1 change: 1 addition & 0 deletions activesupport/lib/active_support/array_inquirer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module ActiveSupport
# Wrapping an array in an +ArrayInquirer+ gives a friendlier way to check
# its string-like contents:
Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/backtrace_cleaner.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module ActiveSupport
# Backtraces often include many lines that are not relevant for the context
# under review. This makes it hard to find the signal amongst the backtrace
Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/benchmarkable.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require_relative "core_ext/benchmark"
require_relative "core_ext/hash/keys"

Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/builder.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
begin
require "builder"
rescue LoadError => e
Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/cache.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "zlib"
require_relative "core_ext/array/extract_options"
require_relative "core_ext/array/wrap"
Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/cache/file_store.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require_relative "../core_ext/marshal"
require_relative "../core_ext/file/atomic"
require_relative "../core_ext/string/conversions"
Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/cache/mem_cache_store.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
begin
require "dalli"
rescue LoadError => e
Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/cache/memory_store.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "monitor"

module ActiveSupport
Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/cache/null_store.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module ActiveSupport
module Cache
# A cache store implementation which doesn't actually store anything. Useful in
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require_relative "../../core_ext/object/duplicable"
require_relative "../../core_ext/string/inflections"
require_relative "../../per_thread_registry"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "rack/body_proxy"
require "rack/utils"

Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/callbacks.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require_relative "concern"
require_relative "descendants_tracker"
require_relative "core_ext/array/extract_options"
Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/concern.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module ActiveSupport
# A typical module looks like this:
#
Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/concurrency/share_lock.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "thread"
require "monitor"

Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/configurable.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require_relative "concern"
require_relative "ordered_options"
require_relative "core_ext/array/extract_options"
Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/core_ext.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
Dir.glob(File.expand_path("core_ext/*.rb", __dir__)).each do |path|
require path
end
1 change: 1 addition & 0 deletions activesupport/lib/active_support/core_ext/array.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require_relative "array/wrap"
require_relative "array/access"
require_relative "array/conversions"
Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/core_ext/array/access.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Array
# Returns the tail of the array from +position+.
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require_relative "../../xml_mini"
require_relative "../hash/keys"
require_relative "../string/inflections"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Hash
# By default, only instances of Hash itself are extractable.
# Subclasses of Hash may implement this method and return
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Array
# Splits or iterates over the array in groups of size +number+,
# padding any remaining slots with +fill_with+ unless it is +false+.
Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/core_ext/array/inquiry.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require_relative "../../array_inquirer"

class Array
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Array
# The human way of thinking about adding stuff to the end of a list is with append.
alias_method :append, :push unless [].respond_to?(:append)
Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/core_ext/array/wrap.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Array
# Wraps its argument in an array unless it is already an array (or array-like).
#
Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/core_ext/benchmark.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "benchmark"

class << Benchmark
Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/core_ext/big_decimal.rb
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# frozen_string_literal: true
require_relative "big_decimal/conversions"
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "bigdecimal"
require "bigdecimal/util"

Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/core_ext/class.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# frozen_string_literal: true
require_relative "class/attribute"
require_relative "class/subclasses"
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require_relative "../kernel/singleton_class"
require_relative "../module/remove_method"
require_relative "../array/extract_options"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# cattr_* became mattr_* aliases in 7dfbd91b0780fbd6a1dd9bfbc176e10894871d2d,
# but we keep this around for libraries that directly require it knowing they
# want cattr_*. No need to deprecate.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require_relative "../module/anonymous"
require_relative "../module/reachable"

Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/core_ext/date.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require_relative "date/acts_like"
require_relative "date/blank"
require_relative "date/calculations"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require_relative "../object/acts_like"

class Date
Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/core_ext/date/blank.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "date"

class Date #:nodoc:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "date"
require_relative "../../duration"
require_relative "../object/acts_like"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "date"
require_relative "../../inflector/methods"
require_relative "zones"
Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/core_ext/date/zones.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "date"
require_relative "../date_and_time/zones"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require_relative "../object/try"

module DateAndTime
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require_relative "../module/attribute_accessors"

module DateAndTime
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module DateAndTime
module Zones
# Returns the simultaneous time in <tt>Time.zone</tt> if a zone is given or
Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/core_ext/date_time.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require_relative "date_time/acts_like"
require_relative "date_time/blank"
require_relative "date_time/calculations"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "date"
require_relative "../object/acts_like"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "date"

class DateTime #:nodoc:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "date"

class DateTime
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require_relative "../date_and_time/compatibility"
require_relative "../module/remove_method"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "date"
require_relative "../../inflector/methods"
require_relative "../time/conversions"
Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/core_ext/digest/uuid.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "securerandom"

module Digest
Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/core_ext/enumerable.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Enumerable
# Enumerable#sum was added in Ruby 2.4, but it only works with Numeric elements
# when we omit an identity.
Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/core_ext/file.rb
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# frozen_string_literal: true
require_relative "file/atomic"
1 change: 1 addition & 0 deletions activesupport/lib/active_support/core_ext/file/atomic.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "fileutils"

class File
Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/core_ext/hash.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require_relative "hash/compact"
require_relative "hash/conversions"
require_relative "hash/deep_merge"
Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/core_ext/hash/compact.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Hash
unless Hash.instance_methods(false).include?(:compact)
# Returns a hash with non +nil+ values.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require_relative "../../xml_mini"
require_relative "../../time"
require_relative "../object/blank"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Hash
# Returns a new hash with +self+ and +other_hash+ merged recursively.
#
Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/core_ext/hash/except.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Hash
# Returns a hash that includes everything except given keys.
# hash = { a: true, b: false, c: nil }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require_relative "../../hash_with_indifferent_access"

class Hash
Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/core_ext/hash/keys.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Hash
# Returns a new hash with all keys converted using the +block+ operation.
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Hash
# Merges the caller into +other_hash+. For example,
#
Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/core_ext/hash/slice.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Hash
# Slices a hash to include only the given keys. Returns a hash containing
# the given keys.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Hash
# Returns a new hash with the results of running +block+ once for every value.
# The keys are unchanged.
Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/core_ext/integer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require_relative "integer/multiple"
require_relative "integer/inflections"
require_relative "integer/time"
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require_relative "../../inflector"

class Integer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Integer
# Check whether the integer is evenly divisible by the argument.
#
Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/core_ext/integer/time.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require_relative "../../duration"
require_relative "../numeric/time"

Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/core_ext/kernel.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require_relative "kernel/agnostics"
require_relative "kernel/concern"
require_relative "kernel/reporting"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Object
# Makes backticks behave (somewhat more) similarly on all platforms.
# On win32 `nonexistent_command` raises Errno::ENOENT; on Unix, the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require_relative "../module/concerning"

module Kernel
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Kernel
module_function

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Kernel
# class_eval on an object acts like singleton_class.class_eval.
def class_eval(*args, &block)
Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/core_ext/load_error.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class LoadError
REGEXPS = [
/^no such file to load -- (.+)$/i,
Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/core_ext/marshal.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module ActiveSupport
module MarshalWithAutoloading # :nodoc:
def load(source, proc = nil)
Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/core_ext/module.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require_relative "module/aliasing"
require_relative "module/introspection"
require_relative "module/anonymous"
Expand Down
Loading

0 comments on commit 7295056

Please sign in to comment.