Skip to content

Commit

Permalink
Don't run Rubocop in parallel mode when running in stdin mode
Browse files Browse the repository at this point in the history
Fixes #536. Fixes #530

Since stdin mode only operates on one file, there's no benefit trying to run in parallel mode anyway.
  • Loading branch information
searls committed Mar 18, 2023
1 parent 4219a89 commit facc8ed
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/standard/runners/rubocop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,27 @@ class Rubocop
def call(config)
rubocop_runner = RuboCop::CLI::Command::ExecuteRunner.new(
RuboCop::CLI::Environment.new(
config.rubocop_options,
without_parallelizing_in_stdin_mode(config.rubocop_options),
config.rubocop_config_store,
config.paths
)
)

rubocop_runner.run
end

private

# This is a workaround for an issue with how `parallel` and `stdin`
# interact when invoked in this way. See:
# https://github.com/testdouble/standard/issues/536
def without_parallelizing_in_stdin_mode(options)
if options[:stdin]
options.delete(:parallel)
end

options
end
end
end
end
1 change: 1 addition & 0 deletions test/standard/runners/rubocop_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def test_print_corrected_output_on_stdin
def test_print_corrected_output_on_stdin_with_corrections_on_stderr
fake_out, fake_err = do_with_fake_io do
@subject.call(create_config(
parallel: true, # should be removed dynamically by us to prevent RuboCop from breaking
autocorrect: true,
stderr: true,
stdin: "def Foo;'hi'end\n"
Expand Down

0 comments on commit facc8ed

Please sign in to comment.