diff --git a/lib/factory_girl/fix_deprecations.rb b/lib/factory_girl/fix_deprecations.rb index d12d0ee0..81223b09 100644 --- a/lib/factory_girl/fix_deprecations.rb +++ b/lib/factory_girl/fix_deprecations.rb @@ -83,7 +83,7 @@ # Factory.define :user do |user| # after(:create) { |instance| create_list(:post, 5, user: instance) } # end - %w(after_build after_create).each do |message| + %w[after_build after_create].each do |message| within_node type: 'block', caller: { type: 'send', message: message } do goto_node :caller do new_message = message.sub('after_', '') @@ -158,7 +158,7 @@ # Factory.create(:user) => create(:user) # Factory.build(:use) => build(:user) # Factory.attributes_for(:user) => attributes_for(:user) - %w(create build attributes_for).each do |message| + %w[create build attributes_for].each do |message| with_node type: 'send', receiver: 'Factory', message: message do replace_with "#{message}({{arguments}})" end diff --git a/lib/factory_girl/use_short_syntax.rb b/lib/factory_girl/use_short_syntax.rb index df7badb2..010d6cb6 100644 --- a/lib/factory_girl/use_short_syntax.rb +++ b/lib/factory_girl/use_short_syntax.rb @@ -64,7 +64,7 @@ class MiniTest::Rails::ActiveSupport::TestCase # insert include FactoryGirl::Syntax::Methods within_file 'test/test_helper.rb' do - %w(Test::Unit::TestCase ActiveSupport::TestCase MiniTest::Unit::TestCase MiniTest::Spec MiniTest::Rails::ActiveSupport::TestCase).each do |class_name| + %w[Test::Unit::TestCase ActiveSupport::TestCase MiniTest::Unit::TestCase MiniTest::Spec MiniTest::Rails::ActiveSupport::TestCase].each do |class_name| within_node type: 'class', name: class_name do unless_exist_node type: 'send', message: 'include', arguments: ['FactoryGirl::Syntax::Methods'] do insert 'include FactoryGirl::Syntax::Methods' @@ -89,7 +89,7 @@ class MiniTest::Rails::ActiveSupport::TestCase # FactoryGirl.create_pair(...) => create_pair(...) # FactoryGirl.build_pair(...) => build_pair(...) within_files '{test,spec,features}/**/*.rb' do - %w(create build attributes_for build_stubbed create_list build_list create_pair build_pair).each do |message| + %w[create build attributes_for build_stubbed create_list build_list create_pair build_pair].each do |message| with_node type: 'send', receiver: 'FactoryGirl', message: message do replace_with "#{message}({{arguments}})" end diff --git a/lib/rails/convert_mailers_2_3_to_3_0.rb b/lib/rails/convert_mailers_2_3_to_3_0.rb index 8ccac10f..ab0e5571 100644 --- a/lib/rails/convert_mailers_2_3_to_3_0.rb +++ b/lib/rails/convert_mailers_2_3_to_3_0.rb @@ -63,7 +63,7 @@ def signup_notification(recipient) args[:to] = node.arguments.first.to_source remove end - %w(subject from cc bcc).each do |message| + %w[subject from cc bcc].each do |message| with_node type: 'send', receiver: nil, message: message do args[message.to_sym] = node.arguments.first.to_source remove diff --git a/lib/rails/convert_models_2_3_to_3_0.rb b/lib/rails/convert_models_2_3_to_3_0.rb index 3e25be3e..8e2761d5 100644 --- a/lib/rails/convert_models_2_3_to_3_0.rb +++ b/lib/rails/convert_models_2_3_to_3_0.rb @@ -127,7 +127,7 @@ # default_scope :conditions => {:active => true} # => # default_scope where(:active => true) - %w(named_scope default_scope).each do |message| + %w[named_scope default_scope].each do |message| within_node type: 'send', message: message, arguments: { last: { type: 'hash' } } do with_node type: 'hash' do if keys.any? { |key| node.has_key? key } @@ -183,7 +183,7 @@ end end - %w(first last).each do |message| + %w[first last].each do |message| # Post.first(:conditions => {:title => "test"}) # => # Post.where(:title => "test").first @@ -195,7 +195,7 @@ end end - %w(count average min max sum).each do |message| + %w[count average min max sum].each do |message| # Client.count("age", :conditions => {:active => true}) # Client.average("orders_count", :conditions => {:active => true}) # Client.min("age", :conditions => {:active => true}) @@ -282,14 +282,14 @@ # => # Post.where("title = \'test\'").destroy_all # Post.where("title = ?", title).destroy_all - %w(delete_all destroy_all).each do |message| + %w[delete_all destroy_all].each do |message| within_node type: 'send', message: message, arguments: { size: 1 } do conditions_node = node.arguments.first replace_with add_receiver_if_necessary("where(#{strip_brackets(conditions_node.to_source)}).#{message}") end end - %w(find_each find_in_batches).each do |message| + %w[find_each find_in_batches].each do |message| # Post.find_each(:conditions => {:title => "test"}, :batch_size => 100) do |post| # end # => @@ -314,7 +314,7 @@ end end - %w(with_scope with_exclusive_scope).each do |message| + %w[with_scope with_exclusive_scope].each do |message| # with_scope(:find => {:conditions => {:active => true}}) { Post.first } # => # with_scope(where(:active => true)) { Post.first } diff --git a/lib/rails/convert_rails_test_request_methods_4_2_to_5_0.rb b/lib/rails/convert_rails_test_request_methods_4_2_to_5_0.rb index 4fa44b48..00b31898 100644 --- a/lib/rails/convert_rails_test_request_methods_4_2_to_5_0.rb +++ b/lib/rails/convert_rails_test_request_methods_4_2_to_5_0.rb @@ -31,7 +31,7 @@ # => # get :show, params: { id: user.id }, flash: { notice: 'Welcome' }, session: { admin: user.admin? }. within_files '{test,spec}/{functional,controllers}/**/*.rb' do - %w(get post put patch delete).each do |message| + %w[get post put patch delete].each do |message| with_node type: 'send', message: message do next unless node.arguments.size > 1 next unless node.arguments[1].type == :hash @@ -50,7 +50,7 @@ # => # get '/posts/1', params: { user_id: user.id }, headers: { 'HTTP_AUTHORIZATION' => 'fake' } within_files '{test,spec}/{integration}/**/*.rb' do - %w(get post put patch delete).each do |message| + %w[get post put patch delete].each do |message| with_node type: 'send', message: message do next unless node.arguments.size > 1 next if node.arguments[1].type == :hash && (node.arguments[1].has_key?(:params) || node.arguments[1].has_key?(:headers)) diff --git a/lib/rails/convert_routes_2_3_to_3_0.rb b/lib/rails/convert_routes_2_3_to_3_0.rb index eedaa48c..4f6a95e5 100644 --- a/lib/rails/convert_routes_2_3_to_3_0.rb +++ b/lib/rails/convert_routes_2_3_to_3_0.rb @@ -169,7 +169,7 @@ # end # map.resources :comments # end - %w(resource resources).each do |message| + %w[resource resources].each do |message| within_node type: 'block', caller: { type: 'send', receiver: { not: nil }, message: message } do block_argument = node.arguments.first.to_source hash_argument = node.caller.arguments.last @@ -238,7 +238,7 @@ # post :activate # edn # end - %w(resource resources).each do |message| + %w[resource resources].each do |message| with_node type: 'send', receiver: 'map', message: message do hash_argument = node.arguments.last if hash_argument.type == :hash && (hash_argument.has_key?(:collection) || hash_argument.has_key?(:member)) @@ -263,13 +263,13 @@ # map.connect "/:controller/:action/:id" # => match "/:controller(/:action(/:id))(.:format)" - with_node type: 'send', receiver: 'map', message: 'connect', arguments: { first: %r|:controller/:action/:id| } do + with_node type: 'send', receiver: 'map', message: 'connect', arguments: { first: %r{:controller/:action/:id} } do replace_with 'match "/:controller(/:action(/:id))(.:format)"' end # map.connect "audio/:action/:id", :controller => "audio" # => match "audio(/:action(/:id))(.:format)", :controller => "audio" - with_node type: 'send', receiver: 'map', message: 'connect', arguments: { first: %r|(.*?)/:action/:id| } do + with_node type: 'send', receiver: 'map', message: 'connect', arguments: { first: %r{(.*?)/:action/:id} } do options_node = node.arguments.last if options_node.type == :hash && options_node.has_key?(:controller) controller_name = options_node.hash_value(:controller).to_value @@ -279,7 +279,7 @@ # map.connect "video/:action", :controller => "video" # => match "video(/:action)(.:format)", :controller => "video" - with_node type: 'send', receiver: 'map', message: 'connect', arguments: { first: %r|(.*?)/:action['"]$| } do + with_node type: 'send', receiver: 'map', message: 'connect', arguments: { first: %r{(.*?)/:action['"]$} } do options_node = node.arguments.last if options_node.type == :hash && options_node.has_key?(:controller) controller_name = options_node.hash_value(:controller).children.last diff --git a/lib/rails/convert_views_2_3_to_3_0.rb b/lib/rails/convert_views_2_3_to_3_0.rb index b7808926..561052a7 100644 --- a/lib/rails/convert_views_2_3_to_3_0.rb +++ b/lib/rails/convert_views_2_3_to_3_0.rb @@ -15,7 +15,7 @@ <% end %> EOF - %w(app/views/**/*.html.erb app/helpers/**/*.rb).each do |file_pattern| + %w[app/views/**/*.html.erb app/helpers/**/*.rb].each do |file_pattern| # <%= h user.login %> => <%= user.login %> within_files file_pattern do with_node type: 'send', receiver: nil, message: 'h' do @@ -23,7 +23,7 @@ end end - %w(form_for form_tag fields_for div_for content_tag_for).each do |message| + %w[form_for form_tag fields_for div_for content_tag_for].each do |message| # <% form_for post do |f| %> # <% end %> # => diff --git a/lib/rails/upgrade_3_0_to_3_1.rb b/lib/rails/upgrade_3_0_to_3_1.rb index f70c775f..9a33b5fd 100644 --- a/lib/rails/upgrade_3_0_to_3_1.rb +++ b/lib/rails/upgrade_3_0_to_3_1.rb @@ -141,7 +141,7 @@ def down within_files 'db/migrate/*.rb' do # def self.up => def up # def self.down => def down - %w(up down).each do |name| + %w[up down].each do |name| with_node type: 'defs', name: name do replace_with "def #{name} {{body}} diff --git a/lib/rails/upgrade_3_1_to_3_2.rb b/lib/rails/upgrade_3_1_to_3_2.rb index 9746de0b..60a0b0ae 100644 --- a/lib/rails/upgrade_3_1_to_3_2.rb +++ b/lib/rails/upgrade_3_1_to_3_2.rb @@ -47,7 +47,7 @@ # set_sequence_name = "seq" => self.sequence_name = "seq" # set_primary_key = "id" => self.primary_key = "id" # set_locking_column = "lock" => self.locking_column = "lock" - %w(set_table_name set_inheritance_column set_sequence_name set_primary_key set_locking_column).each do |message| + %w[set_table_name set_inheritance_column set_sequence_name set_primary_key set_locking_column].each do |message| with_node type: 'send', message: message do new_message = message.sub('set_', '') replace_with "self.#{new_message} = {{arguments}}" diff --git a/lib/rails/upgrade_3_2_to_4_0.rb b/lib/rails/upgrade_3_2_to_4_0.rb index 564005ba..3bd80ed3 100644 --- a/lib/rails/upgrade_3_2_to_4_0.rb +++ b/lib/rails/upgrade_3_2_to_4_0.rb @@ -246,7 +246,7 @@ within_files 'app/models/**/*.rb' do # has_many :comments, dependent: :restrict => has_many :comments, dependent: restrict_with_exception - %w(has_one has_many).each do |message| + %w[has_one has_many].each do |message| within_node type: 'send', receiver: nil, message: message do with_node type: 'pair', key: 'dependent', value: :restrict do replace_with 'dependent: :restrict_with_exception' diff --git a/lib/rspec/new_hook_scope.rb b/lib/rspec/new_hook_scope.rb index d5d0a00e..4b5c6e27 100644 --- a/lib/rspec/new_hook_scope.rb +++ b/lib/rspec/new_hook_scope.rb @@ -23,7 +23,7 @@ # before(:all) { do_something } # => # before(:context) { do_something } - %w(before after around).each do |scope| + %w[before after around].each do |scope| with_node type: 'send', message: scope, arguments: [:all] do replace_with add_receiver_if_necessary("#{scope}(:context)") end diff --git a/lib/rspec/pending_to_skip.rb b/lib/rspec/pending_to_skip.rb index 51bfa4ac..1b692d45 100644 --- a/lib/rspec/pending_to_skip.rb +++ b/lib/rspec/pending_to_skip.rb @@ -83,7 +83,7 @@ replace_with 'skip {{arguments}}' end - %w(it describe context).each do |message| + %w[it describe context].each do |message| # it 'is skipped', :pending => true do # do_something_possibly_fail # end diff --git a/lib/rspec/remove_monkey_patches.rb b/lib/rspec/remove_monkey_patches.rb index d37de5c1..a2e2dd65 100644 --- a/lib/rspec/remove_monkey_patches.rb +++ b/lib/rspec/remove_monkey_patches.rb @@ -24,7 +24,7 @@ if_gem 'rspec', { gte: '3.0.0' } - monkey_patches_methods = %w(describe shared_examples shared_examples_for shared_context) + monkey_patches_methods = %w[describe shared_examples shared_examples_for shared_context] within_files 'spec/**/*.rb' do top_level = true diff --git a/lib/ruby/merge_to_square_brackets.rb b/lib/ruby/merge_to_square_brackets.rb index 5609cb84..b8823ccd 100644 --- a/lib/ruby/merge_to_square_brackets.rb +++ b/lib/ruby/merge_to_square_brackets.rb @@ -52,7 +52,7 @@ within_node type: 'block', caller: { type: 'send', message: 'inject' }, arguments: { size: 2 }, body: { size: 1 } do hash_name = node.arguments.first.name.to_s block_start_line = node.line - %w(merge merge!).each do |message| + %w[merge merge!].each do |message| with_node type: 'send', receiver: hash_name, message: message, arguments: { size: 1, first: { type: 'hash' } } do merge_line = node.line splitter = block_start_line == merge_line ? '; ' : "\n" @@ -76,7 +76,7 @@ within_node type: 'block', caller: { type: 'send', message: 'each_with_object' }, arguments: { size: 2 }, body: { size: 1 } do hash_name = node.arguments.last.name.to_s block_start_line = node.line - %w(merge merge!).each do |message| + %w[merge merge!].each do |message| with_node type: 'send', receiver: hash_name, message: message, arguments: { size: 1, first: { type: 'hash' } } do merge_line = node.line splitter = block_start_line == merge_line ? '; ' : "\n" diff --git a/lib/ruby/new_safe_navigation_operator.rb b/lib/ruby/new_safe_navigation_operator.rb index 5eef2b1e..c1ef4366 100644 --- a/lib/ruby/new_safe_navigation_operator.rb +++ b/lib/ruby/new_safe_navigation_operator.rb @@ -18,7 +18,7 @@ # => # u.?profile.?thumbnails.?large(100, format: 'jpg') # u.?profile.?thumbnails.?large(100, format: 'jpg') - %w(try! try).each do |message| + %w[try! try].each do |message| within_node type: 'send', message: message do if node.arguments.size == 0 # Do nothing diff --git a/lib/ruby/remove_debug_code.rb b/lib/ruby/remove_debug_code.rb index f6f65187..a301555e 100644 --- a/lib/ruby/remove_debug_code.rb +++ b/lib/ruby/remove_debug_code.rb @@ -7,7 +7,7 @@ within_files '**/*.rb' do # removes puts and p methods - %w(puts p).each do |message| + %w[puts p].each do |message| with_node type: 'send', message: message do remove end diff --git a/lib/ruby/use_symbol_to_proc.rb b/lib/ruby/use_symbol_to_proc.rb index d9faf578..e13cddeb 100644 --- a/lib/ruby/use_symbol_to_proc.rb +++ b/lib/ruby/use_symbol_to_proc.rb @@ -21,7 +21,7 @@ # (1..100).map { |i| i.to_s } # => # (1..100).map(&:to_s) - %w(each map).each do |message| + %w[each map].each do |message| with_node type: 'block', caller: { message: message }, arguments: { size: 1 } do argument_name = node.arguments.first.name.to_s if_only_exist_node type: 'send', receiver: argument_name, arguments: { size: 0 } do diff --git a/lib/shoulda/fix_deprecations.rb b/lib/shoulda/fix_deprecations.rb index e043cd4f..c185b16b 100644 --- a/lib/shoulda/fix_deprecations.rb +++ b/lib/shoulda/fix_deprecations.rb @@ -45,8 +45,8 @@ if_gem 'shoulda-matchers', { gte: '1.5.0' } - unit_test_file_patterns = %w(test/unit/**/*_test.rb spec/models/**/*_spec.rb) - function_test_file_patterns = %w(test/functional/**/*_test.rb spec/controllers/**/*_spec.rb) + unit_test_file_patterns = %w[test/unit/**/*_test.rb spec/models/**/*_spec.rb] + function_test_file_patterns = %w[test/functional/**/*_test.rb spec/controllers/**/*_spec.rb] unit_test_file_patterns.each do |file_pattern| within_files file_pattern do diff --git a/lib/shoulda/use_matcher_syntax.rb b/lib/shoulda/use_matcher_syntax.rb index 9a764f67..bbb7ff5c 100644 --- a/lib/shoulda/use_matcher_syntax.rb +++ b/lib/shoulda/use_matcher_syntax.rb @@ -140,8 +140,8 @@ end end - unit_test_file_patterns = %w(test/unit/**/*_test.rb spec/models/**/*_spec.rb) - functional_test_file_patterns = %w(test/functional/**/*_test.rb spec/controllers/**/*_spec.rb) + unit_test_file_patterns = %w[test/unit/**/*_test.rb spec/models/**/*_spec.rb] + functional_test_file_patterns = %w[test/functional/**/*_test.rb spec/controllers/**/*_spec.rb] unit_test_file_patterns.each do |file_pattern| within_files file_pattern do @@ -156,10 +156,10 @@ # should_allow_mass_assignment_of :first_name # => # should allow_mass_assignment_of(:first_name) - %w(should_belong_to should_have_one should_have_many should_have_and_belong_to_many + %w[should_belong_to should_have_one should_have_many should_have_and_belong_to_many should_validate_presence_of should_validate_uniqueness_of should_validate_numericality_of should_validate_acceptance_of should_allow_mass_assignment_of should_not_allow_mass_assignment_of - should_have_readonly_attributes should_not_have_readonly_attributes).each do |message| + should_have_readonly_attributes should_not_have_readonly_attributes].each do |message| with_node type: 'send', message: message do new_message = message.start_with?('should_not') ? message.sub('should_not_', 'should_not ') : message.sub('_', ' ') if node.arguments.size == 1 @@ -218,7 +218,7 @@ # => # should allow_value('isbn 1 2345 6789 0').for(:isbn) # should allow_value('ISBN 1-2345-6789-0').for(:isbn) - %w(should_allow_values_for should_not_allow_values_for).each do |message| + %w[should_allow_values_for should_not_allow_values_for].each do |message| with_node type: 'send', message: message do should_or_should_not = message.include?('_not') ? 'should_not' : 'should' field = node.arguments.first.to_source @@ -313,7 +313,7 @@ # should_render_template :new => should render_template(:new) # # should_render_with_layout "special" => should render_with_layout("special") - %w(should_respond_with should_respond_with_content_type should_render_template should_render_with_layout).each do |message| + %w[should_respond_with should_respond_with_content_type should_render_template should_render_with_layout].each do |message| with_node type: 'send', message: message do new_message = message.sub('_', ' ') replace_with "#{new_message}({{arguments}})"