diff --git a/CHANGELOG.md b/CHANGELOG.md index 578fb39..887d328 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## HEAD (unreleased) +- Expand explanations coming from additional Ripper errors (https://github.com/zombocom/dead_end/pull/117) - Fix explanation involving shorthand syntax for literals like `%w[]` and `%Q{}` (https://github.com/zombocom/dead_end/pull/116) ## 3.0.2 diff --git a/lib/dead_end/ripper_errors.rb b/lib/dead_end/ripper_errors.rb index c8d7c42..78fd2ea 100644 --- a/lib/dead_end/ripper_errors.rb +++ b/lib/dead_end/ripper_errors.rb @@ -18,6 +18,12 @@ def on_parse_error(msg) @errors << msg end + alias_method :on_alias_error, :on_parse_error + alias_method :on_assign_error, :on_parse_error + alias_method :on_class_name_error, :on_parse_error + alias_method :on_param_error, :on_parse_error + alias_method :compile_error, :on_parse_error + def call @run_once ||= begin @errors = [] diff --git a/spec/unit/explain_syntax_spec.rb b/spec/unit/explain_syntax_spec.rb index 5d0905b..277bab5 100644 --- a/spec/unit/explain_syntax_spec.rb +++ b/spec/unit/explain_syntax_spec.rb @@ -4,6 +4,19 @@ module DeadEnd RSpec.describe "ExplainSyntax" do + it "handles shorthand syntaxes with non-bracket characters" do + source = <<~EOM + %Q* lol + EOM + + explain = ExplainSyntax.new( + code_lines: CodeLine.from_source(source) + ).call + + expect(explain.missing).to eq([]) + expect(explain.errors.join).to include("unterminated string") + end + it "handles %w[]" do source = <<~EOM node.is_a?(Op) && %w[| ||].include?(node.value) &&