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

--no-parallel (-P/--parallel can not be combined with --auto-correct) #9640

Merged
merged 7 commits into from Apr 19, 2021
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
1 change: 1 addition & 0 deletions changelog/change_add_no_parallel_option.md
@@ -0,0 +1 @@
* [#7544](https://github.com/rubocop/rubocop/pull/7544): Add --no-parallel (-P/--parallel can not be combined with --auto-correct). ([@kwerle][])
4 changes: 2 additions & 2 deletions lib/rubocop/options.rb
Expand Up @@ -186,7 +186,7 @@ def add_boolean_flags(opts)

option(opts, '-v', '--version')
option(opts, '-V', '--verbose-version')
option(opts, '-P', '--parallel')
option(opts, '-P', '--[no-]parallel')
end
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize

Expand Down Expand Up @@ -498,7 +498,7 @@ module OptionsHelp
version: 'Display version.',
verbose_version: 'Display verbose version.',
parallel: ['Use available CPUs to execute inspection in',
'parallel.'],
'parallel. Default is false.'],
stdin: ['Pipe source from STDIN, using FILE in offense',
'reports. This is useful for editor integration.'],
init: 'Generate a .rubocop.yml file in the current directory.'
Expand Down
25 changes: 16 additions & 9 deletions spec/rubocop/options_spec.rb
Expand Up @@ -137,8 +137,8 @@ def abs(path)
--[no-]color Force color output on or off.
-v, --version Display version.
-V, --verbose-version Display verbose version.
-P, --parallel Use available CPUs to execute inspection in
parallel.
-P, --[no-]parallel Use available CPUs to execute inspection in
parallel. Default is false.
-l, --lint Run only lint cops.
-x, --fix-layout Run only layout cops, with auto-correct on.
-s, --stdin FILE Pipe source from STDIN, using FILE in offense
Expand Down Expand Up @@ -233,14 +233,21 @@ def abs(path)
expect(options.instance_variable_get('@options').keys).not_to include(:parallel)
end
end
end

context 'combined with --auto-correct and --fail-fast' do
it 'ignores parallel' do
msg = '-P/--parallel is being ignored because it is not compatible with -F/--fail-fast'
options.parse %w[--parallel --fail-fast --auto-correct]
expect($stdout.string).to include(msg)
expect(options.instance_variable_get('@options').keys).not_to include(:parallel)
end
context 'combined with --auto-correct and --fail-fast' do
it 'ignores parallel' do
msg = '-P/--parallel is being ignored because it is not compatible with -F/--fail-fast'
options.parse %w[--parallel --fail-fast --auto-correct]
expect($stdout.string).to include(msg)
expect(options.instance_variable_get('@options').keys).not_to include(:parallel)
end
end

describe '--no-parallel' do
it 'disables parallel from file' do
results = options.parse %w[--no-parallel]
expect(results).to eq([{ parallel: false }, []])
end
end

Expand Down