Skip to content

Commit

Permalink
Explicitly display handled errors in Output pane
Browse files Browse the repository at this point in the history
  • Loading branch information
paracycle committed Aug 31, 2022
1 parent 26b787f commit d604ef0
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/ruby_lsp/requests/support/rubocop_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class RuboCopRunner < RuboCop::Runner
def initialize(*args)
@options = T.let({}, T::Hash[Symbol, T.untyped])
@offenses = T.let([], T::Array[RuboCop::Cop::Offense])
@errors = T.let([], T::Array[String])
@warnings = T.let([], T::Array[String])

args += DEFAULT_ARGS
rubocop_options = ::RuboCop::Options.new.parse(args).first
Expand All @@ -36,9 +38,12 @@ def initialize(*args)

sig { params(path: String, contents: String).void }
def run(path, contents)
@errors = []
@warnings = []
@offenses = []
@options[:stdin] = contents
capture_output { super([path]) }
display_handled_errors
end

sig { returns(String) }
Expand All @@ -48,6 +53,16 @@ def formatted_source

private

sig { void }
def display_handled_errors
return if errors.empty?

$stderr.puts "[RuboCop] Encountered and handled errors:"
errors.uniq.each do |error|
$stderr.puts "[RuboCop] - #{error}"
end
end

sig { params(_file: String, offenses: T::Array[RuboCop::Cop::Offense]).void }
def file_finished(_file, offenses)
@offenses = offenses
Expand Down

0 comments on commit d604ef0

Please sign in to comment.