Skip to content

Commit

Permalink
[Fix rubocop#515] Fix an error for Rails/BulkChangeTable
Browse files Browse the repository at this point in the history
Fixes rubocop#515
Follow up ruby/psych#487 and rails/rails@255b5ff

This PR fixes an error for `Rails/BulkChangeTable` when using Psych 4.0.
  • Loading branch information
koic committed Jul 1, 2021
1 parent 7485ea7 commit 32d7443
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## master (unreleased)

### Bug fixes

* [#515](https://github.com/rubocop/rubocop-rails/issues/515): Fix an error for `Rails/BulkChangeTable` when using Psych 4.0. ([@koic][])

## 2.11.1 (2021-06-25)

### Bug fixes
Expand Down
6 changes: 5 additions & 1 deletion lib/rubocop/cop/rails/bulk_change_table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,11 @@ def database_from_yaml
def database_yaml
return nil unless File.exist?('config/database.yml')

yaml = YAML.load_file('config/database.yml')
yaml = if YAML.respond_to?(:unsafe_load_file)
YAML.unsafe_load_file('config/database.yml')
else
YAML.load_file('config/database.yml')
end
return nil unless yaml.is_a? Hash

config = yaml['development']
Expand Down

0 comments on commit 32d7443

Please sign in to comment.