Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix rubocop#8590] Fix an error when auto-correcting encoding mismatc…
…h file Fixes rubocop#8590. This PR fixes the following error when auto-correcting encoding mismatch file. ```ruby % cat example.rb # encoding: Shift_JIS puts 'This file encoding is UTF-8.' ``` ## Before ```console % bundle exec rubocop --cache false -a (snip) Cannot extract source from uninitialized Source::Buffer /Users/koic/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/parser-2.7.1.4/lib/ parser/source/buffer.rb:148:in `source' /Users/koic/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/parser-2.7.1.4/lib/ parser/source/buffer.rb:297:in `source_range' /Users/koic/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/parser-2.7.1.4/lib/ parser/source/tree_rewriter.rb:116:in `initialize' /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/cop/corrector.rb:18:in `initialize' /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/cop/team.rb:182:in `new' /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/cop/team.rb:182:in `collate_corrections' /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/cop/team.rb:176:in `autocorrect_report' /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/cop/team.rb:121:in `autocorrect' /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/cop/team.rb:79:in `investigate' /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/runner.rb:295:in `inspect_file' ``` ## After ```console % bundle exec rubocop --cache false -a (snip) Inspecting 1 file F Offenses: example.rb:1:1: F: Lint/Syntax: "\xef\xbc" from shift_jis to utf-8. 1 file inspected, 1 offense detected ```
- Loading branch information