aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2016-08-08 01:05:28 +0200
committerXavier Noria <fxn@hashref.com>2016-08-08 01:12:38 +0200
commita9dc45459abcd9437085f4dd0aa3c9d0e64e062f (patch)
treefe160bcd744ad3dffbe901a4b44df2c2343130de
parentb45c9ca9b6571108242c1dfc3d3e160f56baf025 (diff)
downloadrails-a9dc45459abcd9437085f4dd0aa3c9d0e64e062f.tar.gz
rails-a9dc45459abcd9437085f4dd0aa3c9d0e64e062f.tar.bz2
rails-a9dc45459abcd9437085f4dd0aa3c9d0e64e062f.zip
code gardening: removes redundant selfs
A few have been left for aesthetic reasons, but have made a pass and removed most of them. Note that if the method `foo` returns an array, `foo << 1` is a regular push, nothing to do with assignments, so no self required.
-rw-r--r--actionmailer/test/base_test.rb4
-rw-r--r--actionpack/lib/abstract_controller/collector.rb2
-rw-r--r--actionpack/lib/action_controller/metal/head.rb2
-rw-r--r--actionpack/lib/action_controller/metal/instrumentation.rb2
-rw-r--r--actionpack/lib/action_controller/metal/rendering.rb2
-rw-r--r--actionpack/lib/action_controller/metal/strong_parameters.rb2
-rw-r--r--actionpack/lib/action_controller/test_case.rb8
-rw-r--r--actionpack/test/abstract_unit.rb2
-rw-r--r--actionpack/test/controller/integration_test.rb2
-rw-r--r--actionpack/test/controller/new_base/content_negotiation_test.rb2
-rw-r--r--actionview/lib/action_view/lookup_context.rb2
-rw-r--r--actionview/lib/action_view/template.rb3
-rw-r--r--actionview/test/actionpack/abstract/abstract_controller_test.rb2
-rw-r--r--actionview/test/active_record_unit.rb2
-rw-r--r--actionview/test/template/controller_helper_test.rb4
-rw-r--r--actionview/test/template/test_case_test.rb2
-rw-r--r--actionview/test/template/url_helper_test.rb2
-rw-r--r--activejob/lib/active_job/enqueuing.rb4
-rw-r--r--activejob/test/cases/test_case_test.rb2
-rw-r--r--activejob/test/support/que/inline.rb2
-rw-r--r--activemodel/lib/active_model/errors.rb4
-rw-r--r--activemodel/lib/active_model/translation.rb2
-rw-r--r--activemodel/lib/active_model/type/integer.rb2
-rw-r--r--activemodel/test/cases/callbacks_test.rb4
-rw-r--r--activemodel/test/cases/validations/callbacks_test.rb32
-rw-r--r--activerecord/lib/active_record/associations/has_one_association.rb2
-rw-r--r--activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb2
-rw-r--r--activerecord/lib/active_record/core.rb4
-rw-r--r--activerecord/lib/active_record/counter_cache.rb2
-rw-r--r--activerecord/lib/active_record/enum.rb2
-rw-r--r--activerecord/lib/active_record/model_schema.rb2
-rw-r--r--activerecord/lib/active_record/nested_attributes.rb2
-rw-r--r--activerecord/lib/active_record/readonly_attributes.rb2
-rw-r--r--activerecord/lib/active_record/relation.rb2
-rw-r--r--activerecord/lib/active_record/relation/query_methods.rb2
-rw-r--r--activerecord/lib/active_record/scoping/default.rb4
-rw-r--r--activerecord/lib/active_record/store.rb4
-rw-r--r--activerecord/lib/active_record/timestamp.rb4
-rw-r--r--activerecord/test/cases/callbacks_test.rb2
-rw-r--r--activerecord/test/cases/fixtures_test.rb4
-rw-r--r--activerecord/test/cases/migration_test.rb2
-rw-r--r--activerecord/test/cases/test_case.rb2
-rw-r--r--activerecord/test/cases/transaction_callbacks_test.rb2
-rw-r--r--activerecord/test/models/subject.rb2
-rw-r--r--activerecord/test/models/topic.rb2
-rw-r--r--activesupport/lib/active_support/callbacks.rb6
-rw-r--r--activesupport/lib/active_support/core_ext/date_and_time/zones.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/digest/uuid.rb4
-rw-r--r--activesupport/lib/active_support/core_ext/hash/compact.rb4
-rw-r--r--activesupport/lib/active_support/core_ext/object/inclusion.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/string/access.rb4
-rw-r--r--activesupport/lib/active_support/core_ext/string/inflections.rb2
-rw-r--r--activesupport/lib/active_support/dependencies.rb2
-rw-r--r--activesupport/lib/active_support/hash_with_indifferent_access.rb2
-rw-r--r--activesupport/lib/active_support/inflector/inflections.rb4
-rw-r--r--activesupport/lib/active_support/testing/isolation.rb2
-rw-r--r--activesupport/lib/active_support/time_with_zone.rb2
-rw-r--r--activesupport/test/callbacks_test.rb2
-rw-r--r--activesupport/test/concern_test.rb2
-rw-r--r--activesupport/test/core_ext/module/remove_method_test.rb16
-rw-r--r--railties/lib/rails/application/finisher.rb4
-rw-r--r--railties/lib/rails/code_statistics_calculator.rb2
-rw-r--r--railties/lib/rails/engine.rb2
-rw-r--r--railties/lib/rails/generators/base.rb4
-rw-r--r--railties/lib/rails/generators/generated_attribute.rb4
-rw-r--r--railties/lib/rails/generators/named_base.rb2
-rw-r--r--railties/lib/rails/generators/rails/app/app_generator.rb2
-rw-r--r--railties/lib/rails/generators/rails/plugin/plugin_generator.rb2
-rw-r--r--railties/lib/rails/generators/resource_helpers.rb2
-rw-r--r--railties/lib/rails/generators/testing/behaviour.rb8
-rw-r--r--railties/lib/rails/railtie/configurable.rb2
-rw-r--r--railties/lib/rails/test_unit/reporter.rb2
-rw-r--r--railties/test/path_generation_test.rb2
-rwxr-xr-xtools/profile2
74 files changed, 121 insertions, 122 deletions
diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb
index 9594cccc4d..8152f28663 100644
--- a/actionmailer/test/base_test.rb
+++ b/actionmailer/test/base_test.rb
@@ -772,8 +772,8 @@ class BaseTest < ActiveSupport::TestCase
test "action methods should be refreshed after defining new method" do
class FooMailer < ActionMailer::Base
- # this triggers action_methods
- self.respond_to?(:foo)
+ # This triggers action_methods.
+ respond_to?(:foo)
def notify
end
diff --git a/actionpack/lib/abstract_controller/collector.rb b/actionpack/lib/abstract_controller/collector.rb
index 55654be224..57714b0588 100644
--- a/actionpack/lib/abstract_controller/collector.rb
+++ b/actionpack/lib/abstract_controller/collector.rb
@@ -16,7 +16,7 @@ module AbstractController
end
Mime::Type.register_callback do |mime|
- generate_method_for_mime(mime) unless self.instance_methods.include?(mime.to_sym)
+ generate_method_for_mime(mime) unless instance_methods.include?(mime.to_sym)
end
protected
diff --git a/actionpack/lib/action_controller/metal/head.rb b/actionpack/lib/action_controller/metal/head.rb
index 97306b5265..86b5eb20d7 100644
--- a/actionpack/lib/action_controller/metal/head.rb
+++ b/actionpack/lib/action_controller/metal/head.rb
@@ -41,7 +41,7 @@ module ActionController
self.response_body = ""
- if include_content?(self.response_code)
+ if include_content?(response_code)
self.content_type = content_type || (Mime[formats.first] if formats)
self.response.charset = false
end
diff --git a/actionpack/lib/action_controller/metal/instrumentation.rb b/actionpack/lib/action_controller/metal/instrumentation.rb
index 6a8129e88b..2ede96c667 100644
--- a/actionpack/lib/action_controller/metal/instrumentation.rb
+++ b/actionpack/lib/action_controller/metal/instrumentation.rb
@@ -17,7 +17,7 @@ module ActionController
def process_action(*args)
raw_payload = {
controller: self.class.name,
- action: self.action_name,
+ action: action_name,
params: request.filtered_parameters,
headers: request.headers,
format: request.format.ref,
diff --git a/actionpack/lib/action_controller/metal/rendering.rb b/actionpack/lib/action_controller/metal/rendering.rb
index 41b166b346..ac17d61b96 100644
--- a/actionpack/lib/action_controller/metal/rendering.rb
+++ b/actionpack/lib/action_controller/metal/rendering.rb
@@ -32,7 +32,7 @@ module ActionController
# Check for double render errors and set the content_type after rendering.
def render(*args) #:nodoc:
- raise ::AbstractController::DoubleRenderError if self.response_body
+ raise ::AbstractController::DoubleRenderError if response_body
super
end
diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb
index 32ab8ca2ac..7f5144bc49 100644
--- a/actionpack/lib/action_controller/metal/strong_parameters.rb
+++ b/actionpack/lib/action_controller/metal/strong_parameters.rb
@@ -719,7 +719,7 @@ module ActionController
end
def unpermitted_keys(params)
- self.keys - params.keys - self.always_permitted_parameters
+ keys - params.keys - always_permitted_parameters
end
#
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb
index 19bd18e110..ccedecd6f4 100644
--- a/actionpack/lib/action_controller/test_case.rb
+++ b/actionpack/lib/action_controller/test_case.rb
@@ -83,7 +83,7 @@ module ActionController
end
if get?
- if self.query_string.blank?
+ if query_string.blank?
self.query_string = non_path_parameters.to_query
end
else
@@ -492,8 +492,8 @@ module ActionController
@html_document = nil
- self.cookies.update @request.cookies
- self.cookies.update_cookies_from_jar
+ cookies.update(@request.cookies)
+ cookies.update_cookies_from_jar
@request.set_header "HTTP_COOKIE", cookies.to_header
@request.delete_header "action_dispatch.cookies"
@@ -538,7 +538,7 @@ module ActionController
if @request.have_cookie_jar?
unless @request.cookie_jar.committed?
@request.cookie_jar.write(@response)
- self.cookies.update(@request.cookie_jar.instance_variable_get(:@cookies))
+ cookies.update(@request.cookie_jar.instance_variable_get(:@cookies))
end
end
@response.prepare!
diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb
index 1c7f6b4e41..0c77de3c16 100644
--- a/actionpack/test/abstract_unit.rb
+++ b/actionpack/test/abstract_unit.rb
@@ -159,7 +159,7 @@ class ActionDispatch::IntegrationTest < ActiveSupport::TestCase
yield temporary_routes
ensure
self.class.app = old_app
- self.remove!
+ remove!
silence_warnings { Object.const_set(:SharedTestRoutes, old_routes) }
end
diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb
index 210757fb76..4abbccfbe5 100644
--- a/actionpack/test/controller/integration_test.rb
+++ b/actionpack/test/controller/integration_test.rb
@@ -765,7 +765,7 @@ class IntegrationProcessTest < ActionDispatch::IntegrationTest
end
end
- self.singleton_class.include(set.url_helpers)
+ singleton_class.include(set.url_helpers)
yield
end
diff --git a/actionpack/test/controller/new_base/content_negotiation_test.rb b/actionpack/test/controller/new_base/content_negotiation_test.rb
index 8e83e1966a..b870745031 100644
--- a/actionpack/test/controller/new_base/content_negotiation_test.rb
+++ b/actionpack/test/controller/new_base/content_negotiation_test.rb
@@ -8,7 +8,7 @@ module ContentNegotiation
)]
def all
- render plain: self.formats.inspect
+ render plain: formats.inspect
end
end
diff --git a/actionview/lib/action_view/lookup_context.rb b/actionview/lib/action_view/lookup_context.rb
index 969bc48bdc..9d6c762cc4 100644
--- a/actionview/lib/action_view/lookup_context.rb
+++ b/actionview/lib/action_view/lookup_context.rb
@@ -21,7 +21,7 @@ module ActionView
self.registered_details = []
def self.register_detail(name, &block)
- self.registered_details << name
+ registered_details << name
Accessors::DEFAULT_PROCS[name] = block
Accessors.send :define_method, :"default_#{name}", &block
diff --git a/actionview/lib/action_view/template.rb b/actionview/lib/action_view/template.rb
index 1f90cae75b..5480501988 100644
--- a/actionview/lib/action_view/template.rb
+++ b/actionview/lib/action_view/template.rb
@@ -65,8 +65,7 @@ module ActionView
# If you want to provide an alternate mechanism for
# specifying encodings (like ERB does via <%# encoding: ... %>),
# you may indicate that you will handle encodings yourself
- # by implementing <tt>self.handles_encoding?</tt>
- # on your handler.
+ # by implementing <tt>handles_encoding?</tt> on your handler.
#
# If you do, Rails will not try to encode the String
# into the default_internal, passing you the unaltered
diff --git a/actionview/test/actionpack/abstract/abstract_controller_test.rb b/actionview/test/actionpack/abstract/abstract_controller_test.rb
index c92467c15f..b3dbf921b5 100644
--- a/actionview/test/actionpack/abstract/abstract_controller_test.rb
+++ b/actionview/test/actionpack/abstract/abstract_controller_test.rb
@@ -275,7 +275,7 @@ module AbstractController
end
class Me6 < AbstractController::Base
- self.action_methods
+ action_methods
def index
end
diff --git a/actionview/test/active_record_unit.rb b/actionview/test/active_record_unit.rb
index 62ca2779fa..c62d300830 100644
--- a/actionview/test/active_record_unit.rb
+++ b/actionview/test/active_record_unit.rb
@@ -28,7 +28,7 @@ $stderr.flush
class ActiveRecordTestConnector
class << self
def setup
- unless self.connected || !self.able_to_connect
+ unless connected || !able_to_connect
setup_connection
load_schema
require_fixture_models
diff --git a/actionview/test/template/controller_helper_test.rb b/actionview/test/template/controller_helper_test.rb
index c8ea8bd453..8dd0cedb75 100644
--- a/actionview/test/template/controller_helper_test.rb
+++ b/actionview/test/template/controller_helper_test.rb
@@ -9,13 +9,13 @@ class ControllerHelperTest < ActionView::TestCase
@controller = OpenStruct.new(default_form_builder: SpecializedFormBuilder)
assign_controller(@controller)
- assert_equal SpecializedFormBuilder, self.default_form_builder
+ assert_equal SpecializedFormBuilder, default_form_builder
end
def test_assign_controller_skips_default_form_builder
@controller = OpenStruct.new
assign_controller(@controller)
- assert_nil self.default_form_builder
+ assert_nil default_form_builder
end
end
diff --git a/actionview/test/template/test_case_test.rb b/actionview/test/template/test_case_test.rb
index 40a5bfca53..0b9d78d668 100644
--- a/actionview/test/template/test_case_test.rb
+++ b/actionview/test/template/test_case_test.rb
@@ -85,7 +85,7 @@ module ActionView
end
test "uses controller lookup context" do
- assert_equal self.lookup_context, @controller.lookup_context
+ assert_equal lookup_context, @controller.lookup_context
end
end
diff --git a/actionview/test/template/url_helper_test.rb b/actionview/test/template/url_helper_test.rb
index bbbeb39f3f..49ada352e0 100644
--- a/actionview/test/template/url_helper_test.rb
+++ b/actionview/test/template/url_helper_test.rb
@@ -626,7 +626,7 @@ class UrlHelperTest < ActiveSupport::TestCase
end
def protect_against_forgery?
- self.request_forgery
+ request_forgery
end
def form_authenticity_token(*args)
diff --git a/activejob/lib/active_job/enqueuing.rb b/activejob/lib/active_job/enqueuing.rb
index e69f76021b..18051a7d65 100644
--- a/activejob/lib/active_job/enqueuing.rb
+++ b/activejob/lib/active_job/enqueuing.rb
@@ -45,8 +45,8 @@ module ActiveJob
self.queue_name = self.class.queue_name_from_part(options[:queue]) if options[:queue]
self.priority = options[:priority].to_i if options[:priority]
run_callbacks :enqueue do
- if self.scheduled_at
- self.class.queue_adapter.enqueue_at self, self.scheduled_at
+ if scheduled_at
+ self.class.queue_adapter.enqueue_at self, scheduled_at
else
self.class.queue_adapter.enqueue self
end
diff --git a/activejob/test/cases/test_case_test.rb b/activejob/test/cases/test_case_test.rb
index 23fffd4235..3db2d9dec7 100644
--- a/activejob/test/cases/test_case_test.rb
+++ b/activejob/test/cases/test_case_test.rb
@@ -18,6 +18,6 @@ class ActiveJobTestCaseTest < ActiveJob::TestCase
end
def test_set_test_adapter
- assert_kind_of ActiveJob::QueueAdapters::TestAdapter, self.queue_adapter
+ assert_kind_of ActiveJob::QueueAdapters::TestAdapter, queue_adapter
end
end
diff --git a/activejob/test/support/que/inline.rb b/activejob/test/support/que/inline.rb
index ea9999b473..55eb0d01ef 100644
--- a/activejob/test/support/que/inline.rb
+++ b/activejob/test/support/que/inline.rb
@@ -9,6 +9,6 @@ Que::Job.class_eval do
options.delete(:priority)
args << options unless options.empty?
end
- self.run(*args)
+ run(*args)
end
end
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb
index 0cdb0e8525..b6ab7ab6b0 100644
--- a/activemodel/lib/active_model/errors.rb
+++ b/activemodel/lib/active_model/errors.rb
@@ -276,11 +276,11 @@ module ActiveModel
# person.errors.to_hash(true) # => {:name=>["name cannot be nil"]}
def to_hash(full_messages = false)
if full_messages
- self.messages.each_with_object({}) do |(attribute, array), messages|
+ messages.each_with_object({}) do |(attribute, array), messages|
messages[attribute] = array.map { |message| full_message(attribute, message) }
end
else
- self.messages.dup
+ messages.dup
end
end
diff --git a/activemodel/lib/active_model/translation.rb b/activemodel/lib/active_model/translation.rb
index 75509b0588..b8cf43cc10 100644
--- a/activemodel/lib/active_model/translation.rb
+++ b/activemodel/lib/active_model/translation.rb
@@ -30,7 +30,7 @@ module ActiveModel
# ActiveModel::Errors#full_messages and
# ActiveModel::Translation#human_attribute_name.
def lookup_ancestors
- self.ancestors.select { |x| x.respond_to?(:model_name) }
+ ancestors.select { |x| x.respond_to?(:model_name) }
end
# Transforms attribute names into a more human format, such as "First name"
diff --git a/activemodel/lib/active_model/type/integer.rb b/activemodel/lib/active_model/type/integer.rb
index b76e9d96f6..41dd655a5c 100644
--- a/activemodel/lib/active_model/type/integer.rb
+++ b/activemodel/lib/active_model/type/integer.rb
@@ -59,7 +59,7 @@ module ActiveModel
end
def _limit
- self.limit || DEFAULT_LIMIT
+ limit || DEFAULT_LIMIT
end
end
end
diff --git a/activemodel/test/cases/callbacks_test.rb b/activemodel/test/cases/callbacks_test.rb
index 2b1c8d0eb7..63b6c56f8c 100644
--- a/activemodel/test/cases/callbacks_test.rb
+++ b/activemodel/test/cases/callbacks_test.rb
@@ -109,8 +109,8 @@ class CallbacksTest < ActiveModel::TestCase
end
extend ActiveModel::Callbacks
define_model_callbacks :create
- def callback1; self.history << "callback1"; end
- def callback2; self.history << "callback2"; end
+ def callback1; history << "callback1"; end
+ def callback2; history << "callback2"; end
def create
run_callbacks(:create) {}
self
diff --git a/activemodel/test/cases/validations/callbacks_test.rb b/activemodel/test/cases/validations/callbacks_test.rb
index 3a25ffa46f..83e8ac9522 100644
--- a/activemodel/test/cases/validations/callbacks_test.rb
+++ b/activemodel/test/cases/validations/callbacks_test.rb
@@ -15,37 +15,37 @@ class DogWithMethodCallbacks < Dog
before_validation :set_before_validation_marker
after_validation :set_after_validation_marker
- def set_before_validation_marker; self.history << "before_validation_marker"; end
- def set_after_validation_marker; self.history << "after_validation_marker" ; end
+ def set_before_validation_marker; history << "before_validation_marker"; end
+ def set_after_validation_marker; history << "after_validation_marker" ; end
end
class DogValidatorsAreProc < Dog
- before_validation { self.history << "before_validation_marker" }
- after_validation { self.history << "after_validation_marker" }
+ before_validation { history << "before_validation_marker" }
+ after_validation { history << "after_validation_marker" }
end
class DogWithTwoValidators < Dog
- before_validation { self.history << "before_validation_marker1" }
- before_validation { self.history << "before_validation_marker2" }
+ before_validation { history << "before_validation_marker1" }
+ before_validation { history << "before_validation_marker2" }
end
class DogDeprecatedBeforeValidatorReturningFalse < Dog
before_validation { false }
- before_validation { self.history << "before_validation_marker2" }
+ before_validation { history << "before_validation_marker2" }
end
class DogBeforeValidatorThrowingAbort < Dog
before_validation { throw :abort }
- before_validation { self.history << "before_validation_marker2" }
+ before_validation { history << "before_validation_marker2" }
end
class DogAfterValidatorReturningFalse < Dog
after_validation { false }
- after_validation { self.history << "after_validation_marker" }
+ after_validation { history << "after_validation_marker" }
end
class DogWithMissingName < Dog
- before_validation { self.history << "before_validation_marker" }
+ before_validation { history << "before_validation_marker" }
validates_presence_of :name
end
@@ -53,8 +53,8 @@ class DogValidatorWithOnCondition < Dog
before_validation :set_before_validation_marker, on: :create
after_validation :set_after_validation_marker, on: :create
- def set_before_validation_marker; self.history << "before_validation_marker"; end
- def set_after_validation_marker; self.history << "after_validation_marker" ; end
+ def set_before_validation_marker; history << "before_validation_marker"; end
+ def set_after_validation_marker; history << "after_validation_marker" ; end
end
class DogValidatorWithIfCondition < Dog
@@ -64,11 +64,11 @@ class DogValidatorWithIfCondition < Dog
after_validation :set_after_validation_marker1, if: -> { true }
after_validation :set_after_validation_marker2, if: -> { false }
- def set_before_validation_marker1; self.history << "before_validation_marker1"; end
- def set_before_validation_marker2; self.history << "before_validation_marker2" ; end
+ def set_before_validation_marker1; history << "before_validation_marker1"; end
+ def set_before_validation_marker2; history << "before_validation_marker2" ; end
- def set_after_validation_marker1; self.history << "after_validation_marker1"; end
- def set_after_validation_marker2; self.history << "after_validation_marker2" ; end
+ def set_after_validation_marker1; history << "after_validation_marker1"; end
+ def set_after_validation_marker2; history << "after_validation_marker2" ; end
end
class CallbacksWithMethodNamesShouldBeCalled < ActiveModel::TestCase
diff --git a/activerecord/lib/active_record/associations/has_one_association.rb b/activerecord/lib/active_record/associations/has_one_association.rb
index 08a4611013..5ea9577301 100644
--- a/activerecord/lib/active_record/associations/has_one_association.rb
+++ b/activerecord/lib/active_record/associations/has_one_association.rb
@@ -32,7 +32,7 @@ module ActiveRecord
raise_on_type_mismatch!(record) if record
load_target
- return self.target if !(target || record)
+ return target unless target || record
assigning_another_record = target != record
if assigning_another_record || record.changed?
diff --git a/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb b/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb
index ff9fd206c0..2c8e86fbb2 100644
--- a/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb
+++ b/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb
@@ -85,7 +85,7 @@ module ActiveRecord
def create_time_zone_conversion_attribute?(name, cast_type)
enabled_for_column = time_zone_aware_attributes &&
- !self.skip_time_zone_conversion_for_attributes.include?(name.to_sym)
+ !skip_time_zone_conversion_for_attributes.include?(name.to_sym)
result = enabled_for_column &&
time_zone_aware_types.include?(cast_type.type)
diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb
index 5b21e01dcc..d3fe962802 100644
--- a/activerecord/lib/active_record/core.rb
+++ b/activerecord/lib/active_record/core.rb
@@ -83,7 +83,7 @@ module ActiveRecord
The flag error_on_ignored_order_or_limit is deprecated. Limits are
now supported. Please use error_on_ignored_order instead.
MSG
- self.error_on_ignored_order
+ error_on_ignored_order
end
def error_on_ignored_order_or_limit
@@ -268,7 +268,7 @@ module ActiveRecord
# Returns an instance of <tt>Arel::Table</tt> loaded with the current table name.
#
# class Post < ActiveRecord::Base
- # scope :published_and_commented, -> { published.and(self.arel_table[:comments_count].gt(0)) }
+ # scope :published_and_commented, -> { published.and(arel_table[:comments_count].gt(0)) }
# end
def arel_table # :nodoc:
@arel_table ||= Arel::Table.new(table_name, type_caster: type_caster)
diff --git a/activerecord/lib/active_record/counter_cache.rb b/activerecord/lib/active_record/counter_cache.rb
index 0edb4b8a34..e2da512813 100644
--- a/activerecord/lib/active_record/counter_cache.rb
+++ b/activerecord/lib/active_record/counter_cache.rb
@@ -26,7 +26,7 @@ module ActiveRecord
has_many_association = has_many.find { |association| association.counter_cache_column && association.counter_cache_column.to_sym == counter_association.to_sym }
counter_association = has_many_association.plural_name if has_many_association
end
- raise ArgumentError, "'#{self.name}' has no association called '#{counter_association}'" unless has_many_association
+ raise ArgumentError, "'#{name}' has no association called '#{counter_association}'" unless has_many_association
if has_many_association.is_a? ActiveRecord::Reflection::ThroughReflection
has_many_association = has_many_association.through_reflection
diff --git a/activerecord/lib/active_record/enum.rb b/activerecord/lib/active_record/enum.rb
index 73f122cfd7..0a94ab58dd 100644
--- a/activerecord/lib/active_record/enum.rb
+++ b/activerecord/lib/active_record/enum.rb
@@ -227,7 +227,7 @@ module ActiveRecord
def raise_conflict_error(enum_name, method_name, type: "instance", source: "Active Record")
raise ArgumentError, ENUM_CONFLICT_MESSAGE % {
enum: enum_name,
- klass: self.name,
+ klass: name,
type: type,
method: method_name,
source: source
diff --git a/activerecord/lib/active_record/model_schema.rb b/activerecord/lib/active_record/model_schema.rb
index 1537fffc22..480734669d 100644
--- a/activerecord/lib/active_record/model_schema.rb
+++ b/activerecord/lib/active_record/model_schema.rb
@@ -433,7 +433,7 @@ module ActiveRecord
ActiveSupport::Deprecation.warn(<<-WARNING.strip_heredoc)
The behavior of the `:point` type will be changing in Rails 5.1 to
return a `Point` object, rather than an `Array`. If you'd like to
- keep the old behavior, you can add this line to #{self.name}:
+ keep the old behavior, you can add this line to #{name}:
attribute :#{column.name}, :legacy_point#{array_arguments}
diff --git a/activerecord/lib/active_record/nested_attributes.rb b/activerecord/lib/active_record/nested_attributes.rb
index 2cbef2425b..4873db7270 100644
--- a/activerecord/lib/active_record/nested_attributes.rb
+++ b/activerecord/lib/active_record/nested_attributes.rb
@@ -575,7 +575,7 @@ module ActiveRecord
end
def allow_destroy?(association_name)
- self.nested_attributes_options[association_name][:allow_destroy]
+ nested_attributes_options[association_name][:allow_destroy]
end
def raise_nested_attributes_record_not_found!(association_name, record_id)
diff --git a/activerecord/lib/active_record/readonly_attributes.rb b/activerecord/lib/active_record/readonly_attributes.rb
index ce78f1756d..8ff265bdfa 100644
--- a/activerecord/lib/active_record/readonly_attributes.rb
+++ b/activerecord/lib/active_record/readonly_attributes.rb
@@ -16,7 +16,7 @@ module ActiveRecord
# Returns an array of all the attributes that have been specified as readonly.
def readonly_attributes
- self._attr_readonly
+ _attr_readonly
end
end
end
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index 60ccb73d50..3983065d7a 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -657,7 +657,7 @@ module ActiveRecord
end
def pretty_print(q)
- q.pp(self.records)
+ q.pp(records)
end
# Returns true if relation is blank.
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb
index 619b947f57..1a59b3a146 100644
--- a/activerecord/lib/active_record/relation/query_methods.rb
+++ b/activerecord/lib/active_record/relation/query_methods.rb
@@ -1006,7 +1006,7 @@ module ActiveRecord
result = [] if multi_val_method
end
- self.send(unscope_code, result)
+ send(unscope_code, result)
end
def build_from
diff --git a/activerecord/lib/active_record/scoping/default.rb b/activerecord/lib/active_record/scoping/default.rb
index 572a45aac9..7409706851 100644
--- a/activerecord/lib/active_record/scoping/default.rb
+++ b/activerecord/lib/active_record/scoping/default.rb
@@ -104,11 +104,11 @@ module ActiveRecord
def build_default_scope(base_rel = nil) # :nodoc:
return if abstract_class?
- if self.default_scope_override.nil?
+ if default_scope_override.nil?
self.default_scope_override = !Base.is_a?(method(:default_scope).owner)
end
- if self.default_scope_override
+ if default_scope_override
# The user has defined their own default scope method, so call that
evaluate_default_scope { default_scope }
elsif default_scopes.any?
diff --git a/activerecord/lib/active_record/store.rb b/activerecord/lib/active_record/store.rb
index f6bf2c7e48..066573192e 100644
--- a/activerecord/lib/active_record/store.rb
+++ b/activerecord/lib/active_record/store.rb
@@ -114,8 +114,8 @@ module ActiveRecord
def stored_attributes
parent = superclass.respond_to?(:stored_attributes) ? superclass.stored_attributes : {}
- if self.local_stored_attributes
- parent.merge!(self.local_stored_attributes) { |k, a, b| a | b }
+ if local_stored_attributes
+ parent.merge!(local_stored_attributes) { |k, a, b| a | b }
end
parent
end
diff --git a/activerecord/lib/active_record/timestamp.rb b/activerecord/lib/active_record/timestamp.rb
index d9c18a5e38..6641ab5df1 100644
--- a/activerecord/lib/active_record/timestamp.rb
+++ b/activerecord/lib/active_record/timestamp.rb
@@ -54,7 +54,7 @@ module ActiveRecord
private
def _create_record
- if self.record_timestamps
+ if record_timestamps
current_time = current_time_from_proper_timezone
all_timestamp_attributes.each do |column|
@@ -82,7 +82,7 @@ module ActiveRecord
end
def should_record_timestamps?
- self.record_timestamps && (!partial_writes? || changed?)
+ record_timestamps && (!partial_writes? || changed?)
end
def timestamp_attributes_for_create_in_model
diff --git a/activerecord/test/cases/callbacks_test.rb b/activerecord/test/cases/callbacks_test.rb
index 51bf51b28d..e2352bd9f9 100644
--- a/activerecord/test/cases/callbacks_test.rb
+++ b/activerecord/test/cases/callbacks_test.rb
@@ -16,7 +16,7 @@ class CallbackDeveloper < ActiveRecord::Base
def define_callback_method(callback_method)
define_method(callback_method) do
- self.history << [callback_method, :method]
+ history << [callback_method, :method]
end
send(callback_method, :"#{callback_method}")
end
diff --git a/activerecord/test/cases/fixtures_test.rb b/activerecord/test/cases/fixtures_test.rb
index 6f4b6ddbc0..f799f1e1fa 100644
--- a/activerecord/test/cases/fixtures_test.rb
+++ b/activerecord/test/cases/fixtures_test.rb
@@ -1004,10 +1004,10 @@ class FixtureClassNamesTest < ActiveRecord::TestCase
end
def teardown
- self.fixture_class_names.replace(@saved_cache)
+ fixture_class_names.replace(@saved_cache)
end
test "fixture_class_names returns nil for unregistered identifier" do
- assert_nil self.fixture_class_names["unregistered_identifier"]
+ assert_nil fixture_class_names["unregistered_identifier"]
end
end
diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb
index 50d39d942e..5d96569d38 100644
--- a/activerecord/test/cases/migration_test.rb
+++ b/activerecord/test/cases/migration_test.rb
@@ -313,7 +313,7 @@ class MigrationTest < ActiveRecord::TestCase
assert_no_column Person, :last_name
migration = Class.new(ActiveRecord::Migration::Current) {
- self.disable_ddl_transaction!
+ disable_ddl_transaction!
def version; 101 end
def migrate(x)
diff --git a/activerecord/test/cases/test_case.rb b/activerecord/test/cases/test_case.rb
index b0f5b5ca4a..b4f5226f2b 100644
--- a/activerecord/test/cases/test_case.rb
+++ b/activerecord/test/cases/test_case.rb
@@ -86,7 +86,7 @@ module ActiveRecord
def clear_log; self.log = []; self.log_all = []; end
end
- self.clear_log
+ clear_log
self.ignored_sql = [/^PRAGMA/, /^SELECT currval/, /^SELECT CAST/, /^SELECT @@IDENTITY/, /^SELECT @@ROWCOUNT/, /^SAVEPOINT/, /^ROLLBACK TO SAVEPOINT/, /^RELEASE SAVEPOINT/, /^SHOW max_identifier_length/, /^BEGIN/, /^COMMIT/]
diff --git a/activerecord/test/cases/transaction_callbacks_test.rb b/activerecord/test/cases/transaction_callbacks_test.rb
index be23fb8a4a..6a7d48871c 100644
--- a/activerecord/test/cases/transaction_callbacks_test.rb
+++ b/activerecord/test/cases/transaction_callbacks_test.rb
@@ -17,7 +17,7 @@ class TransactionCallbacksTest < ActiveRecord::TestCase
attr_accessor :save_on_after_create
after_create do
- self.save! if save_on_after_create
+ save! if save_on_after_create
end
def history
diff --git a/activerecord/test/models/subject.rb b/activerecord/test/models/subject.rb
index f31a33ec7e..29e290825e 100644
--- a/activerecord/test/models/subject.rb
+++ b/activerecord/test/models/subject.rb
@@ -7,7 +7,7 @@ class Subject < ActiveRecord::Base
protected
def set_email_address
- unless self.persisted?
+ unless persisted?
self.author_email_address = "test@test.com"
end
end
diff --git a/activerecord/test/models/topic.rb b/activerecord/test/models/topic.rb
index 00f89a5364..db04735d01 100644
--- a/activerecord/test/models/topic.rb
+++ b/activerecord/test/models/topic.rb
@@ -84,7 +84,7 @@ class Topic < ActiveRecord::Base
end
def set_email_address
- unless self.persisted?
+ unless persisted?
self.author_email_address = "test@test.com"
end
end
diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb
index a450b0e6d4..d6687ae937 100644
--- a/activesupport/lib/active_support/callbacks.rb
+++ b/activesupport/lib/active_support/callbacks.rb
@@ -445,7 +445,7 @@ module ActiveSupport
def around(&around)
CallbackSequence.new do |arg|
around.call(arg) {
- self.call(arg)
+ call(arg)
}
end
end
@@ -624,7 +624,7 @@ module ActiveSupport
# callback is skipped.
#
# class Writer < Person
- # skip_callback :validate, :before, :check_membership, if: -> { self.age > 18 }
+ # skip_callback :validate, :before, :check_membership, if: -> { age > 18 }
# end
#
# An <tt>ArgumentError</tt> will be raised if the callback has not
@@ -662,7 +662,7 @@ module ActiveSupport
target.set_callbacks name, chain
end
- self.set_callbacks name, callbacks.dup.clear
+ set_callbacks(name, callbacks.dup.clear)
end
# Define sets of events in the object life cycle that support callbacks.
diff --git a/activesupport/lib/active_support/core_ext/date_and_time/zones.rb b/activesupport/lib/active_support/core_ext/date_and_time/zones.rb
index c5b46c598c..edd724f1d0 100644
--- a/activesupport/lib/active_support/core_ext/date_and_time/zones.rb
+++ b/activesupport/lib/active_support/core_ext/date_and_time/zones.rb
@@ -22,7 +22,7 @@ module DateAndTime
if time_zone
time_with_zone(time, time_zone)
else
- time || self.to_time
+ time || to_time
end
end
diff --git a/activesupport/lib/active_support/core_ext/digest/uuid.rb b/activesupport/lib/active_support/core_ext/digest/uuid.rb
index 23cb105f7c..e6d60e3267 100644
--- a/activesupport/lib/active_support/core_ext/digest/uuid.rb
+++ b/activesupport/lib/active_support/core_ext/digest/uuid.rb
@@ -35,12 +35,12 @@ module Digest
# Convenience method for uuid_from_hash using Digest::MD5.
def self.uuid_v3(uuid_namespace, name)
- self.uuid_from_hash(Digest::MD5, uuid_namespace, name)
+ uuid_from_hash(Digest::MD5, uuid_namespace, name)
end
# Convenience method for uuid_from_hash using Digest::SHA1.
def self.uuid_v5(uuid_namespace, name)
- self.uuid_from_hash(Digest::SHA1, uuid_namespace, name)
+ uuid_from_hash(Digest::SHA1, uuid_namespace, name)
end
# Convenience method for SecureRandom.uuid.
diff --git a/activesupport/lib/active_support/core_ext/hash/compact.rb b/activesupport/lib/active_support/core_ext/hash/compact.rb
index f072530e04..78b3387c3b 100644
--- a/activesupport/lib/active_support/core_ext/hash/compact.rb
+++ b/activesupport/lib/active_support/core_ext/hash/compact.rb
@@ -7,7 +7,7 @@ class Hash
# { c: nil }.compact # => {}
# { c: true }.compact # => { c: true }
def compact
- self.select { |_, value| !value.nil? }
+ select { |_, value| !value.nil? }
end
# Replaces current hash with non +nil+ values.
@@ -18,6 +18,6 @@ class Hash
# hash # => { a: true, b: false }
# { c: true }.compact! # => nil
def compact!
- self.reject! { |_, value| value.nil? }
+ reject! { |_, value| value.nil? }
end
end
diff --git a/activesupport/lib/active_support/core_ext/object/inclusion.rb b/activesupport/lib/active_support/core_ext/object/inclusion.rb
index d4c17dfb07..98bf820d36 100644
--- a/activesupport/lib/active_support/core_ext/object/inclusion.rb
+++ b/activesupport/lib/active_support/core_ext/object/inclusion.rb
@@ -22,6 +22,6 @@ class Object
#
# @return [Object]
def presence_in(another_object)
- self.in?(another_object) ? self : nil
+ in?(another_object) ? self : nil
end
end
diff --git a/activesupport/lib/active_support/core_ext/string/access.rb b/activesupport/lib/active_support/core_ext/string/access.rb
index b6afd32fb0..caa48e34c5 100644
--- a/activesupport/lib/active_support/core_ext/string/access.rb
+++ b/activesupport/lib/active_support/core_ext/string/access.rb
@@ -76,7 +76,7 @@ class String
if limit == 0
""
elsif limit >= size
- self.dup
+ dup
else
to(limit - 1)
end
@@ -96,7 +96,7 @@ class String
if limit == 0
""
elsif limit >= size
- self.dup
+ dup
else
from(-limit)
end
diff --git a/activesupport/lib/active_support/core_ext/string/inflections.rb b/activesupport/lib/active_support/core_ext/string/inflections.rb
index bf94b97ceb..7e12700c8c 100644
--- a/activesupport/lib/active_support/core_ext/string/inflections.rb
+++ b/activesupport/lib/active_support/core_ext/string/inflections.rb
@@ -31,7 +31,7 @@ class String
def pluralize(count = nil, locale = :en)
locale = count if count.is_a?(Symbol)
if count == 1
- self.dup
+ dup
else
ActiveSupport::Inflector.pluralize(self, locale)
end
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb
index 622f637675..e585e89563 100644
--- a/activesupport/lib/active_support/dependencies.rb
+++ b/activesupport/lib/active_support/dependencies.rb
@@ -697,7 +697,7 @@ module ActiveSupport #:nodoc:
if file_path
expanded = File.expand_path(file_path)
expanded.sub!(/\.rb\z/, "")
- self.loaded.delete(expanded)
+ loaded.delete(expanded)
end
if constants.empty?
diff --git a/activesupport/lib/active_support/hash_with_indifferent_access.rb b/activesupport/lib/active_support/hash_with_indifferent_access.rb
index ad6c4f8e8c..74a603c05d 100644
--- a/activesupport/lib/active_support/hash_with_indifferent_access.rb
+++ b/activesupport/lib/active_support/hash_with_indifferent_access.rb
@@ -216,7 +216,7 @@ module ActiveSupport
# modify the receiver but rather returns a new hash with indifferent
# access with the result of the merge.
def merge(hash, &block)
- self.dup.update(hash, &block)
+ dup.update(hash, &block)
end
# Like +merge+ but the other way around: Merges the receiver into the
diff --git a/activesupport/lib/active_support/inflector/inflections.rb b/activesupport/lib/active_support/inflector/inflections.rb
index b1be84a096..7b1cbba7fa 100644
--- a/activesupport/lib/active_support/inflector/inflections.rb
+++ b/activesupport/lib/active_support/inflector/inflections.rb
@@ -43,8 +43,8 @@ module ActiveSupport
end
def add(words)
- self.concat(words.flatten.map(&:downcase))
- @regex_array += self.map {|word| to_regex(word) }
+ concat(words.flatten.map(&:downcase))
+ @regex_array += map {|word| to_regex(word) }
self
end
diff --git a/activesupport/lib/active_support/testing/isolation.rb b/activesupport/lib/active_support/testing/isolation.rb
index 23fe47a039..af9ee93600 100644
--- a/activesupport/lib/active_support/testing/isolation.rb
+++ b/activesupport/lib/active_support/testing/isolation.rb
@@ -68,7 +68,7 @@ module ActiveSupport
if ENV["ISOLATION_TEST"]
yield
File.open(ENV["ISOLATION_OUTPUT"], "w") do |file|
- file.puts [Marshal.dump(self.dup)].pack("m")
+ file.puts [Marshal.dump(dup)].pack("m")
end
exit!
else
diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb
index 439d2b86aa..9cc82e9187 100644
--- a/activesupport/lib/active_support/time_with_zone.rb
+++ b/activesupport/lib/active_support/time_with_zone.rb
@@ -458,7 +458,7 @@ module ActiveSupport
def method_missing(sym, *args, &block)
wrap_with_time_zone time.__send__(sym, *args, &block)
rescue NoMethodError => e
- raise e, e.message.sub(time.inspect, self.inspect), e.backtrace
+ raise e, e.message.sub(time.inspect, inspect), e.backtrace
end
private
diff --git a/activesupport/test/callbacks_test.rb b/activesupport/test/callbacks_test.rb
index 69b15b0086..913b7c8cfc 100644
--- a/activesupport/test/callbacks_test.rb
+++ b/activesupport/test/callbacks_test.rb
@@ -804,7 +804,7 @@ module CallbacksTest
class WriterSkipper < Person
attr_accessor :age
- skip_callback :save, :before, :before_save_method, if: lambda {self.age > 21}
+ skip_callback :save, :before, :before_save_method, if: -> { age > 21 }
end
class WriterCallbacksTest < ActiveSupport::TestCase
diff --git a/activesupport/test/concern_test.rb b/activesupport/test/concern_test.rb
index 4e74a69f97..4af9ce8163 100644
--- a/activesupport/test/concern_test.rb
+++ b/activesupport/test/concern_test.rb
@@ -72,7 +72,7 @@ class ConcernTest < ActiveSupport::TestCase
def test_class_methods_are_extended
@klass.include(Baz)
assert_equal "baz", @klass.baz
- assert_equal ConcernTest::Baz::ClassMethods, (class << @klass; self.included_modules; end)[0]
+ assert_equal ConcernTest::Baz::ClassMethods, (class << @klass; included_modules; end)[0]
end
def test_class_methods_are_extended_only_on_expected_objects
diff --git a/activesupport/test/core_ext/module/remove_method_test.rb b/activesupport/test/core_ext/module/remove_method_test.rb
index 6579b2754f..0c627f1e74 100644
--- a/activesupport/test/core_ext/module/remove_method_test.rb
+++ b/activesupport/test/core_ext/module/remove_method_test.rb
@@ -27,24 +27,24 @@ end
class RemoveMethodTest < ActiveSupport::TestCase
def test_remove_method_from_an_object
- RemoveMethodTests::A.class_eval{
- self.remove_possible_method(:do_something)
+ RemoveMethodTests::A.class_eval {
+ remove_possible_method(:do_something)
}
assert !RemoveMethodTests::A.new.respond_to?(:do_something)
end
def test_remove_singleton_method_from_an_object
- RemoveMethodTests::A.class_eval{
- self.remove_possible_singleton_method(:do_something_else)
+ RemoveMethodTests::A.class_eval {
+ remove_possible_singleton_method(:do_something_else)
}
assert !RemoveMethodTests::A.respond_to?(:do_something_else)
end
def test_redefine_method_in_an_object
- RemoveMethodTests::A.class_eval{
- self.redefine_method(:do_something) { return 100 }
- self.redefine_method(:do_something_protected) { return 100 }
- self.redefine_method(:do_something_private) { return 100 }
+ RemoveMethodTests::A.class_eval {
+ redefine_method(:do_something) { return 100 }
+ redefine_method(:do_something_protected) { return 100 }
+ redefine_method(:do_something_private) { return 100 }
}
assert_equal 100, RemoveMethodTests::A.new.do_something
assert_equal 100, RemoveMethodTests::A.new.send(:do_something_protected)
diff --git a/railties/lib/rails/application/finisher.rb b/railties/lib/rails/application/finisher.rb
index 9f07f8fa02..a855e8fab0 100644
--- a/railties/lib/rails/application/finisher.rb
+++ b/railties/lib/rails/application/finisher.rb
@@ -125,7 +125,7 @@ module Rails
initializer :set_routes_reloader_hook do |app|
reloader = routes_reloader
reloader.execute_if_updated
- self.reloaders << reloader
+ reloaders << reloader
app.reloader.to_run do
# We configure #execute rather than #execute_if_updated because if
# autoloaded constants are cleared we need to reload routes also in
@@ -161,7 +161,7 @@ module Rails
if config.reload_classes_only_on_change
reloader = config.file_watcher.new(*watchable_args, &callback)
- self.reloaders << reloader
+ reloaders << reloader
# Prepend this callback to have autoloaded constants cleared before
# any other possible reloading, in case they need to autoload fresh
diff --git a/railties/lib/rails/code_statistics_calculator.rb b/railties/lib/rails/code_statistics_calculator.rb
index 63e40b631c..d0194af197 100644
--- a/railties/lib/rails/code_statistics_calculator.rb
+++ b/railties/lib/rails/code_statistics_calculator.rb
@@ -43,7 +43,7 @@ class CodeStatisticsCalculator #:nodoc:
def add_by_file_path(file_path)
File.open(file_path) do |f|
- self.add_by_io(f, file_type(file_path))
+ add_by_io(f, file_type(file_path))
end
end
diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb
index bcd1a66921..363c65b186 100644
--- a/railties/lib/rails/engine.rb
+++ b/railties/lib/rails/engine.rb
@@ -619,7 +619,7 @@ module Rails
end
rake_tasks do
- next if self.is_a?(Rails::Application)
+ next if is_a?(Rails::Application)
next unless has_migrations?
namespace railtie_name do
diff --git a/railties/lib/rails/generators/base.rb b/railties/lib/rails/generators/base.rb
index 60ef2d50ef..5b4cde30c0 100644
--- a/railties/lib/rails/generators/base.rb
+++ b/railties/lib/rails/generators/base.rb
@@ -48,7 +48,7 @@ module Rails
# Convenience method to hide this generator from the available ones when
# running rails generator command.
def self.hide!
- Rails::Generators.hide_namespace self.namespace
+ Rails::Generators.hide_namespace(namespace)
end
# Invoke a generator based on the value supplied by the user to the
@@ -273,7 +273,7 @@ module Rails
# Use Rails default banner.
def self.banner
- "rails generate #{namespace.sub(/^rails:/,'')} #{self.arguments.map(&:usage).join(' ')} [options]".gsub(/\s+/, " ")
+ "rails generate #{namespace.sub(/^rails:/,'')} #{arguments.map(&:usage).join(' ')} [options]".gsub(/\s+/, " ")
end
# Sets the base_name taking into account the current class namespace.
diff --git a/railties/lib/rails/generators/generated_attribute.rb b/railties/lib/rails/generators/generated_attribute.rb
index 58ffdcc464..61181b7b97 100644
--- a/railties/lib/rails/generators/generated_attribute.rb
+++ b/railties/lib/rails/generators/generated_attribute.rb
@@ -127,11 +127,11 @@ module Rails
end
def polymorphic?
- self.attr_options[:polymorphic]
+ attr_options[:polymorphic]
end
def required?
- self.attr_options[:required]
+ attr_options[:required]
end
def has_index?
diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb
index c799365ac8..6b1e4125cb 100644
--- a/railties/lib/rails/generators/named_base.rb
+++ b/railties/lib/rails/generators/named_base.rb
@@ -14,7 +14,7 @@ module Rails
# Unfreeze name in case it's given as a frozen string
args[0] = args[0].dup if args[0].is_a?(String) && args[0].frozen?
super
- assign_names!(self.name)
+ assign_names!(name)
parse_attributes! if respond_to?(:attributes)
end
diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb
index 2614bd85cf..bc666b9812 100644
--- a/railties/lib/rails/generators/rails/app/app_generator.rb
+++ b/railties/lib/rails/generators/rails/app/app_generator.rb
@@ -361,7 +361,7 @@ module Rails
protected
def self.banner
- "rails new #{self.arguments.map(&:usage).join(' ')} [options]"
+ "rails new #{arguments.map(&:usage).join(' ')} [options]"
end
# Define file as an alias to create_file for backwards compatibility.
diff --git a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb
index e24ece57ca..9ffeab4fbe 100644
--- a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb
+++ b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb
@@ -328,7 +328,7 @@ task default: :test
end
def self.banner
- "rails plugin new #{self.arguments.map(&:usage).join(' ')} [options]"
+ "rails plugin new #{arguments.map(&:usage).join(' ')} [options]"
end
def original_name
diff --git a/railties/lib/rails/generators/resource_helpers.rb b/railties/lib/rails/generators/resource_helpers.rb
index c7829869ef..6d80003271 100644
--- a/railties/lib/rails/generators/resource_helpers.rb
+++ b/railties/lib/rails/generators/resource_helpers.rb
@@ -17,7 +17,7 @@ module Rails
controller_name = name
if options[:model_name]
self.name = options[:model_name]
- assign_names!(self.name)
+ assign_names!(name)
end
assign_controller_names!(controller_name.pluralize)
diff --git a/railties/lib/rails/generators/testing/behaviour.rb b/railties/lib/rails/generators/testing/behaviour.rb
index fc91482d3b..a1e5a233b9 100644
--- a/railties/lib/rails/generators/testing/behaviour.rb
+++ b/railties/lib/rails/generators/testing/behaviour.rb
@@ -62,16 +62,16 @@ module Rails
#
# You can provide a configuration hash as second argument. This method returns the output
# printed by the generator.
- def run_generator(args=self.default_arguments, config={})
+ def run_generator(args = default_arguments, config = {})
capture(:stdout) do
args += ["--skip-bundle"] unless args.include? "--dev"
- self.generator_class.start(args, config.reverse_merge(destination_root: destination_root))
+ generator_class.start(args, config.reverse_merge(destination_root: destination_root))
end
end
# Instantiate the generator.
- def generator(args=self.default_arguments, options={}, config={})
- @generator ||= self.generator_class.new(args, options, config.reverse_merge(destination_root: destination_root))
+ def generator(args = default_arguments, options = {}, config = {})
+ @generator ||= generator_class.new(args, options, config.reverse_merge(destination_root: destination_root))
end
# Create a Rails::Generators::GeneratedAttribute by supplying the
diff --git a/railties/lib/rails/railtie/configurable.rb b/railties/lib/rails/railtie/configurable.rb
index d6040785a0..39f1f87575 100644
--- a/railties/lib/rails/railtie/configurable.rb
+++ b/railties/lib/rails/railtie/configurable.rb
@@ -9,7 +9,7 @@ module Rails
delegate :config, to: :instance
def inherited(base)
- raise "You cannot inherit from a #{self.superclass.name} child"
+ raise "You cannot inherit from a #{superclass.name} child"
end
def instance
diff --git a/railties/lib/rails/test_unit/reporter.rb b/railties/lib/rails/test_unit/reporter.rb
index afcdd2e9fd..fe11664d5e 100644
--- a/railties/lib/rails/test_unit/reporter.rb
+++ b/railties/lib/rails/test_unit/reporter.rb
@@ -68,7 +68,7 @@ module Rails
def format_rerun_snippet(result)
location, line = result.method(result.name).source_location
- "#{self.executable} #{relative_path_for(location)}:#{line}"
+ "#{executable} #{relative_path_for(location)}:#{line}"
end
def app_root
diff --git a/railties/test/path_generation_test.rb b/railties/test/path_generation_test.rb
index 71aab479e5..4d2dba0e2b 100644
--- a/railties/test/path_generation_test.rb
+++ b/railties/test/path_generation_test.rb
@@ -30,7 +30,7 @@ class PathGenerationTest < ActiveSupport::TestCase
end
def make_request(env)
- Request.new super, self.url_helpers, @block
+ Request.new(super, url_helpers, @block)
end
end
diff --git a/tools/profile b/tools/profile
index 0fec570875..f7c3b11f3e 100755
--- a/tools/profile
+++ b/tools/profile
@@ -111,7 +111,7 @@ rescue LoadError
# File activesupport/lib/active_support/inflector/methods.rb, line 150
def classify
# strip out any leading schema name
- camelize(self.sub(/.*\./, ""))
+ camelize(sub(/.*\./, ""))
end
# File activesupport/lib/active_support/inflector/methods.rb, line 68
def camelize(uppercase_first_letter = true)