Class: Spoom::Sorbet::Errors::Parser
- Inherits:
-
Object
- Object
- Spoom::Sorbet::Errors::Parser
- Defined in:
- lib/spoom/sorbet/errors.rb
Overview
Parse errors from Sorbet output
Defined Under Namespace
Classes: ParseError
Constant Summary collapse
- HEADER =
T.let( [ "👋 Hey there! Heads up that this is not a release build of sorbet.", "Release builds are faster and more well-supported by the Sorbet team.", "Check out the README to learn how to build Sorbet in release mode.", "To forcibly silence this error, either pass --silence-dev-message,", "or set SORBET_SILENCE_DEV_MESSAGE=1 in your shell environment.", ], T::Array[String], )
Class Method Summary collapse
-
.parse_string(output, error_url_base: DEFAULT_ERROR_URL_BASE) ⇒ Object
: (String output, ?error_url_base: String) -> Array.
Instance Method Summary collapse
-
#initialize(error_url_base: DEFAULT_ERROR_URL_BASE) ⇒ Parser
constructor
: (?error_url_base: String) -> void.
-
#parse(output) ⇒ Object
: (String output) -> Array.
Constructor Details
#initialize(error_url_base: DEFAULT_ERROR_URL_BASE) ⇒ Parser
: (?error_url_base: String) -> void
39 40 41 42 43 |
# File 'lib/spoom/sorbet/errors.rb', line 39 def initialize(error_url_base: DEFAULT_ERROR_URL_BASE) @errors = T.let([], T::Array[Error]) @error_line_match_regex = T.let(error_line_match_regexp(error_url_base), Regexp) @current_error = T.let(nil, T.nilable(Error)) end |
Class Method Details
.parse_string(output, error_url_base: DEFAULT_ERROR_URL_BASE) ⇒ Object
: (String output, ?error_url_base: String) -> Array
32 33 34 35 |
# File 'lib/spoom/sorbet/errors.rb', line 32 def parse_string(output, error_url_base: DEFAULT_ERROR_URL_BASE) parser = Spoom::Sorbet::Errors::Parser.new(error_url_base: error_url_base) parser.parse(output) end |
Instance Method Details
#parse(output) ⇒ Object
: (String output) -> Array
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/spoom/sorbet/errors.rb', line 46 def parse(output) output.each_line do |line| break if /^No errors! Great job\./.match?(line) break if /^Errors: /.match?(line) next if HEADER.include?(line.strip) next if line == "\n" if (error = match_error_line(line)) close_error if @current_error open_error(error) next end append_error(line) if @current_error end close_error if @current_error @errors end |