From a77447f4da15dd3c2b02563fa6f5769c1d91e1bd Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Mon, 21 May 2018 21:04:01 +0900 Subject: [PATCH] Enable `Lint/StringConversionInInterpolation` rubocop rule To prevent redundant `to_s` like https://github.com/rails/rails/pull/32923#discussion_r189460008 automatically in the future. --- .rubocop.yml | 3 +++ activerecord/lib/active_record/log_subscriber.rb | 2 +- activerecord/test/cases/arel/support/fake_record.rb | 4 ++-- railties/test/application/server_test.rb | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 954ab3b1cb..7327f1e631 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -162,6 +162,9 @@ Style/UnneededPercentQ: Lint/RequireParentheses: Enabled: true +Lint/StringConversionInInterpolation: + Enabled: true + Style/RedundantReturn: Enabled: true AllowMultipleReturnValues: true diff --git a/activerecord/lib/active_record/log_subscriber.rb b/activerecord/lib/active_record/log_subscriber.rb index 013c3765b2..cf884bc6da 100644 --- a/activerecord/lib/active_record/log_subscriber.rb +++ b/activerecord/lib/active_record/log_subscriber.rb @@ -104,7 +104,7 @@ module ActiveRecord if source_line if defined?(::Rails.root) - app_root = "#{::Rails.root.to_s}/".freeze + app_root = "#{::Rails.root}/" source_line = source_line.sub(app_root, "") end diff --git a/activerecord/test/cases/arel/support/fake_record.rb b/activerecord/test/cases/arel/support/fake_record.rb index 8620d6fd34..559ff5d4e6 100644 --- a/activerecord/test/cases/arel/support/fake_record.rb +++ b/activerecord/test/cases/arel/support/fake_record.rb @@ -51,11 +51,11 @@ module FakeRecord end def quote_table_name(name) - "\"#{name.to_s}\"" + "\"#{name}\"" end def quote_column_name(name) - "\"#{name.to_s}\"" + "\"#{name}\"" end def schema_cache diff --git a/railties/test/application/server_test.rb b/railties/test/application/server_test.rb index f3a7e00a4d..92b991dd05 100644 --- a/railties/test/application/server_test.rb +++ b/railties/test/application/server_test.rb @@ -36,7 +36,7 @@ module ApplicationTests skip "PTY unavailable" unless available_pty? File.open("#{app_path}/config/boot.rb", "w") do |f| - f.puts "ENV['BUNDLE_GEMFILE'] = '#{Bundler.default_gemfile.to_s}'" + f.puts "ENV['BUNDLE_GEMFILE'] = '#{Bundler.default_gemfile}'" f.puts "require 'bundler/setup'" end