1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Add cop for preferring 'Foo.method' over 'Foo::method'

This commit is contained in:
Andrew White 2018-02-22 06:26:48 +00:00
parent a5e81342af
commit 9c0c90979a
4 changed files with 7 additions and 3 deletions

View file

@ -156,3 +156,7 @@ Style/RedundantReturn:
Style/Semicolon: Style/Semicolon:
Enabled: true Enabled: true
AllowAsExpressionSeparator: true AllowAsExpressionSeparator: true
# Prefer Foo.method over Foo::method
Style/ColonMethodCall:
Enabled: true

View file

@ -1186,7 +1186,7 @@ class CustomNameForFixtureOrModelTest < ActiveRecord::TestCase
end end
def test_table_name_is_defined_in_the_model def test_table_name_is_defined_in_the_model
assert_equal "randomly_named_table2", ActiveRecord::FixtureSet::all_loaded_fixtures["admin/randomly_named_a9"].table_name assert_equal "randomly_named_table2", ActiveRecord::FixtureSet.all_loaded_fixtures["admin/randomly_named_a9"].table_name
assert_equal "randomly_named_table2", Admin::ClassNameThatDoesNotFollowCONVENTIONS1.table_name assert_equal "randomly_named_table2", Admin::ClassNameThatDoesNotFollowCONVENTIONS1.table_name
end end
end end

View file

@ -13,7 +13,7 @@ class ApiAppGeneratorTest < Rails::Generators::TestCase
Rails.application = TestApp::Application Rails.application = TestApp::Application
super super
Kernel::silence_warnings do Kernel.silence_warnings do
Thor::Base.shell.send(:attr_accessor, :always_force) Thor::Base.shell.send(:attr_accessor, :always_force)
@shell = Thor::Base.shell.new @shell = Thor::Base.shell.new
@shell.send(:always_force=, true) @shell.send(:always_force=, true)

View file

@ -9,7 +9,7 @@ module SharedGeneratorTests
super super
Rails::Generators::AppGenerator.instance_variable_set("@desc", nil) Rails::Generators::AppGenerator.instance_variable_set("@desc", nil)
Kernel::silence_warnings do Kernel.silence_warnings do
Thor::Base.shell.send(:attr_accessor, :always_force) Thor::Base.shell.send(:attr_accessor, :always_force)
@shell = Thor::Base.shell.new @shell = Thor::Base.shell.new
@shell.send(:always_force=, true) @shell.send(:always_force=, true)