Skip to content

Commit

Permalink
Merge pull request #7015 from hoshinotsuyoshi/fix_6880
Browse files Browse the repository at this point in the history
[Fix #6880] Fix RuboCop::Options#parse for `.rubocop` file parsing
  • Loading branch information
koic committed May 3, 2019
2 parents d13e83b + 7f45d69 commit 2a4f4f0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -10,6 +10,7 @@
* [#6900](https://github.com/rubocop-hq/rubocop/issues/6900): Fix `Rails/TimeZone` autocorrect `Time.current` to `Time.zone.now`. ([@vfonic][])
* [#6900](https://github.com/rubocop-hq/rubocop/issues/6900): Fix `Rails/TimeZone` to prefer `Time.zone.#{method}` over other acceptable corrections. ([@vfonic][])
* [#7007](https://github.com/rubocop-hq/rubocop/pull/7007): Fix `Style/BlockDelimiters` with `braces_for_chaining` style false positive, when chaining using safe navigation. ([@Darhazer][])
* [#6880](https://github.com/rubocop-hq/rubocop/issues/6880): Fix `.rubocop` file parsing. ([@hoshinotsuyoshi][])

## 0.68.1 (2019-04-30)

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/options.rb
Expand Up @@ -45,7 +45,7 @@ def parse(command_line_args)

def args_from_file
if File.exist?('.rubocop') && !File.directory?('.rubocop')
IO.readlines('.rubocop').map(&:strip)
File.read('.rubocop').shellsplit
else
[]
end
Expand Down
4 changes: 2 additions & 2 deletions spec/rubocop/options_spec.rb
Expand Up @@ -346,7 +346,7 @@ def with_env_options(options)

context '.rubocop file' do
before do
create_file('.rubocop', %w[--color --fail-level C])
create_file('.rubocop', '--color --fail-level C')
end

it 'has lower precedence then command line options' do
Expand Down Expand Up @@ -378,7 +378,7 @@ def with_env_options(options)
end

it 'has higher precedence then options from .rubocop file' do
create_file('.rubocop', %w[--color --fail-level C])
create_file('.rubocop', '--color --fail-level C')

with_env_options '--fail-level W' do
expect(parsed_options).to eq(color: false, fail_level: :warning)
Expand Down

0 comments on commit 2a4f4f0

Please sign in to comment.