Skip to content

Commit

Permalink
Change kwarg names of Psych in Ruby 2.6
Browse files Browse the repository at this point in the history
This PR fixes the follwoing error.

```console
% ruby -v
ruby 2.6.0dev (2018-11-11 trunk 65667) [x86_64-darwin17]
% bundle exec rake
Files:         514
Modules:        80 (   11 undocumented)
Classes:       485 (    3 undocumented)
Constants:     751 (  738 undocumented)
Attributes:     26 (    0 undocumented)
Methods:      1163 ( 1037 undocumented)
 28.58% documented
 rake aborted!
 ArgumentError: unknown keywords: whitelist_classes, whitelist_symbols
 /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/config_loader.rb:189:in `yaml_safe_load'
 /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/config_loader.rb:162:in `load_yaml_configuration'
 /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/config_loader.rb:41:in `load_file'
 /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/config_loader.rb:107:in `default_configuration'
 tasks/cops_documentation.rake:247:in `main'
 tasks/cops_documentation.rake:262:in `block in <top (required)>'
 /Users/koic/.rbenv/versions/2.6.0-dev/bin/bundle:30:in `block in <main>'
 /Users/koic/.rbenv/versions/2.6.0-dev/bin/bundle:22:in `<main>'
 Tasks: TOP => default => generate_cops_documentation
 (See full trace by running task with --trace)
 ```

These kwarg names has been changed by the following links.

- ruby/psych#378
- ruby/ruby@6268098

For these kwarg names change, This PR will not add the new conditional branch
using `Gem::Version.new(Psych::VERSION)`. It is the same as for the following reasons.

> Because the kwargs API was not included in the latest stable psych gemrelease, 3.0.3:
https://github.com/ruby/psych/blob/v3.0.3/lib/psych.rb#L318
> It's only been a part of beta releases of the next minor.
> No real user will be affected by the API change.

ruby/psych#378 (comment)
  • Loading branch information
koic committed Nov 12, 2018
1 parent 8f918d2 commit 6360983
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/rubocop/config_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ def yaml_safe_load(yaml_code, filename)
elsif Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0.pre1')
YAML.safe_load(
yaml_code,
whitelist_classes: [Regexp, Symbol],
whitelist_symbols: [],
permitted_classes: [Regexp, Symbol],
permitted_symbols: [],
aliases: false,
filename: filename
)
Expand Down

0 comments on commit 6360983

Please sign in to comment.