Skip to content

Commit

Permalink
Start capturing stdout during all RuboCop runs
Browse files Browse the repository at this point in the history
  • Loading branch information
paracycle committed Aug 31, 2022
1 parent 248db71 commit d9edf5a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/ruby_lsp/requests/support/rubocop_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def initialize(*args)
def run(path, contents)
@offenses = []
@options[:stdin] = contents
super([path])
capture_stdout { super([path]) }
end

sig { returns(String) }
Expand All @@ -55,6 +55,16 @@ def formatted_source
def file_finished(_file, offenses)
@offenses = offenses
end

sig { params(block: T.proc.void).void }
def capture_stdout(&block)
orig_stdout = $stdout
$stdout = StringIO.new

block.call
ensure
$stdout = orig_stdout
end
end
end
end
Expand Down

0 comments on commit d9edf5a

Please sign in to comment.