Skip to content

Commit

Permalink
Merge pull request rails#46969 from skipkayhil/eval-location-followup
Browse files Browse the repository at this point in the history
Enable Style/EvalWithLocation
  • Loading branch information
rafaelfranca committed Jan 12, 2023
2 parents e2f35db + 978993e commit da73378
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ Lint/UselessAssignment:
Lint/DeprecatedClassMethods:
Enabled: true

Style/EvalWithLocation:
Enabled: true
Exclude:
- '**/test/**/*'

Style/ParenthesesAroundCondition:
Enabled: true

Expand Down
2 changes: 1 addition & 1 deletion actionview/lib/action_view/helpers/atom_feed_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def atom_feed(options = {}, &block)
options[:schema_date] = "2005" # The Atom spec copyright date
end

xml = options.delete(:xml) || eval("xml", block.binding)
xml = options.delete(:xml) || block.binding.local_variable_get(:xml)
xml.instruct!
if options[:instruct]
options[:instruct].each do |target, attrs|
Expand Down
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/association_relation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def ==(other)
end

%w(insert insert_all insert! insert_all! upsert upsert_all).each do |method|
class_eval <<~RUBY
class_eval <<~RUBY, __FILE__, __LINE__ + 1
def #{method}(attributes, **kwargs)
if @association.reflection.through_reflection?
raise ArgumentError, "Bulk insert or upsert is currently not supported for has_many through association"
Expand Down
2 changes: 1 addition & 1 deletion activesupport/lib/active_support/testing/stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def quietly(&block)
def capture(stream)
stream = stream.to_s
captured_stream = Tempfile.new(stream)
stream_io = eval("$#{stream}")
stream_io = eval("$#{stream}", binding, __FILE__, __LINE__)
origin_stream = stream_io.dup
stream_io.reopen(captured_stream)

Expand Down
3 changes: 1 addition & 2 deletions railties/lib/rails/generators/migration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,12 @@ def migration_template(source, destination, config = {})
source = File.expand_path(find_in_source_paths(source.to_s))

set_migration_assigns!(destination)
context = instance_eval("binding")

dir, base = File.split(destination)
numbered_destination = File.join(dir, ["%migration_number%", base].join("_"))

file = create_migration numbered_destination, nil, config do
ERB.new(::File.binread(source), trim_mode: "-", eoutvar: "@output_buffer").result(context)
ERB.new(::File.binread(source), trim_mode: "-", eoutvar: "@output_buffer").result(binding)
end
Rails::Generators.add_generated_file(file)
end
Expand Down

0 comments on commit da73378

Please sign in to comment.