Skip to content

Commit

Permalink
Add --no-parallel command-line option (#9640)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwerle committed Apr 19, 2021
1 parent fe934c2 commit bc6f98b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
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

0 comments on commit bc6f98b

Please sign in to comment.