Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable auto parallel inspection when config file is specified #12235

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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