Enable `Lint/ErbNewArguments` cop to avoid the deprecated arguments warning

Related 5754a29a97.

And follows Ruby standard library style https://github.com/ruby/ruby/commit/3406c5d.
This commit is contained in:
Ryuta Kamizono 2019-02-01 14:16:55 +09:00
parent 6127b8d920
commit 7ebfb319ff
3 changed files with 5 additions and 4 deletions

View File

@ -179,6 +179,9 @@ Layout/TrailingWhitespace:
Style/UnneededPercentQ:
Enabled: true
Lint/ErbNewArguments:
Enabled: true
# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
Lint/RequireParentheses:
Enabled: true

View File

@ -63,8 +63,7 @@ module Rails
numbered_destination = File.join(dir, ["%migration_number%", base].join("_"))
create_migration numbered_destination, nil, config do
match = ERB.version.match(/\Aerb\.rb \[(?<version>[^ ]+) /)
if match && match[:version] >= "2.2.0" # Ruby 2.6+
if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
ERB.new(::File.binread(source), trim_mode: "-", eoutvar: "@output_buffer").result(context)
else
ERB.new(::File.binread(source), nil, "-", "@output_buffer").result(context)

View File

@ -314,8 +314,7 @@ task :announce do
require "erb"
template = File.read("../tasks/release_announcement_draft.erb")
match = ERB.version.match(/\Aerb\.rb \[(?<version>[^ ]+) /)
if match && match[:version] >= "2.2.0" # Ruby 2.6+
if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
puts ERB.new(template, trim_mode: "<>").result(binding)
else
puts ERB.new(template, nil, "<>").result(binding)