New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate safe_level of ERB.new in Ruby 2.6 #1220

Merged
merged 1 commit into from May 30, 2018

Conversation

Projects
None yet
2 participants
@koic
Contributor

koic commented May 27, 2018

This PR suppresses the following warnings when using Ruby 2.6.0-dev.

% ruby -v
ruby 2.6.0dev (2018-05-22 trunk 63488) [x86_64-darwin17]
%RUBYOPT='-w' bundle exec rake
(snip)
/Users/koic/src/github.com/presidentbeef/brakeman/lib/brakeman/parsers/template_parser.rb:61:
warning: Passing safe_level with the 2nd argument of ERB.new is deprecated.
Do not use it, and specify other arguments as keyword arguments.
/Users/koic/src/github.com/presidentbeef/brakeman/lib/brakeman/parsers/template_parser.rb:61:
warning: Passing trim_mode with the 3rd argument of ERB.new is deprecated.
Use keyword argument like ERB.new(str, trim_mode: ...) instead.

The interface of ERB.new will change from Ruby 2.6.

Add :trim_mode and :eoutvar keyword arguments to ERB.new.
Now non-keyword arguments other than first one are softly deprecated
and will be removed when Ruby 2.5 becomes EOL. [Feature #14256]

https://github.com/ruby/ruby/blob/2311087/NEWS#stdlib-updates-outstanding-ones-only

This PR uses ERB.instance_method(:initialize).parameters.assoc(:key) to switch ERB.new interface. Because Brakeman supports multiple Ruby versions, it need to use the appropriate interface. This approach is built into Ruby.
ruby/ruby@3406c5d

Deprecate safe_level of ERB.new in Ruby 2.6
This PR suppresses the following warnings when using Ruby 2.6.0-dev.

```console
% ruby -v
ruby 2.6.0dev (2018-05-22 trunk 63488) [x86_64-darwin17]
%RUBYOPT='-w' bundle exec rake
(snip)
/Users/koic/src/github.com/presidentbeef/brakeman/lib/brakeman/parsers/template_parser.rb:61:
warning: Passing safe_level with the 2nd argument of ERB.new is deprecated.
Do not use it, and specify other arguments as keyword arguments.
/Users/koic/src/github.com/presidentbeef/brakeman/lib/brakeman/parsers/template_parser.rb:61:
warning: Passing trim_mode with the 3rd argument of ERB.new is deprecated.
Use keyword argument like ERB.new(str, trim_mode: ...) instead.
```

The interface of `ERB.new` will change from Ruby 2.6.

> Add :trim_mode and :eoutvar keyword arguments to ERB.new.
> Now non-keyword arguments other than first one are softly deprecated
> and will be removed when Ruby 2.5 becomes EOL. [Feature #14256]

https://github.com/ruby/ruby/blob/2311087/NEWS#stdlib-updates-outstanding-ones-only

This PR uses `ERB.instance_method(:initialize).parameters.assoc(:key)`
to switch `ERB.new` interface. Because Brakeman supports multiple Ruby
versions, it need to use the appropriate interface. This approach is
built into Ruby.
ruby/ruby@3406c5d

@presidentbeef presidentbeef merged commit c1ae473 into presidentbeef:master May 30, 2018

4 of 5 checks passed

codeclimate/diff-coverage 66% (90% threshold)
Details
ci/circleci Your tests passed on CircleCI!
Details
codeclimate All good!
Details
codeclimate/total-coverage 94% (0.0% change)
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@presidentbeef

This comment has been minimized.

Owner

presidentbeef commented May 30, 2018

Thank you @koic 🙇

Repository owner locked and limited conversation to collaborators Jul 14, 2018

@koic koic deleted the koic:deprecate_safe_level_of_erb_new_in_ruby_2_6 branch Aug 8, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.