Skip to content

Commit

Permalink
Merge pull request #12235 from aboutsource/feature/auto_parallel_with…
Browse files Browse the repository at this point in the history
…_explicit_config

Enable auto parallel inspection when config file is specified
  • Loading branch information
koic committed Oct 1, 2023
2 parents 80de379 + 948d641 commit 2ec14ca
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#12235](https://github.com/rubocop/rubocop/pull/12235): Enable auto parallel inspection when config file is specified. ([@aboutNisblee][])
2 changes: 1 addition & 1 deletion lib/rubocop/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class CLI
STATUS_ERROR = 2
STATUS_INTERRUPTED = Signal.list['INT'] + 128
DEFAULT_PARALLEL_OPTIONS = %i[
color debug display_style_guide display_time display_only_fail_level_offenses
color config debug display_style_guide display_time display_only_fail_level_offenses
display_only_failed except extra_details fail_level fix_layout format
ignore_disable_comments lint only only_guide_cops require safe
autocorrect safe_autocorrect autocorrect_all
Expand Down
19 changes: 16 additions & 3 deletions spec/rubocop/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def and_with_args
# In other words, even if no option is specified, it will be parallelized by default.
describe 'when parallel static by default' do
context 'when specifying `--debug` option only`' do
it 'fails with an error message' do
it 'uses parallel inspection' do
create_file('example1.rb', <<~RUBY)
# frozen_string_literal: true
Expand All @@ -231,6 +231,19 @@ def and_with_args
end
end

context 'when specifying configuration file' do
it 'uses parallel inspection' do
create_file('example1.rb', <<~RUBY)
# frozen_string_literal: true
puts 'hello'
RUBY
create_empty_file('.rubocop.yml')
expect(cli.run(['--debug', '--config', '.rubocop.yml'])).to eq(0)
expect($stdout.string.include?('Use parallel by default.')).to be(true)
end
end

context 'when specifying `--debug` and `-a` options`' do
it 'uses parallel inspection when correcting the file' do
create_file('example1.rb', <<~RUBY)
Expand All @@ -249,7 +262,7 @@ def and_with_args
end

context 'when setting `UseCache: true`' do
it 'fails with an error message' do
it 'uses parallel inspection' do
create_file('example.rb', <<~RUBY)
# frozen_string_literal: true
Expand All @@ -265,7 +278,7 @@ def and_with_args
end

context 'when setting `UseCache: false`' do
it 'fails with an error message' do
it 'does not use parallel inspection' do
create_file('example.rb', <<~RUBY)
# frozen_string_literal: true
Expand Down

0 comments on commit 2ec14ca

Please sign in to comment.