Skip to content

Commit d7f8d58

Browse files
authored
Merge pull request #117 from zombocom/schneems/more-ripper-errors
Handle more ripper errors
2 parents c4d3f78 + 1e526e0 commit d7f8d58

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## HEAD (unreleased)
22

3+
- Expand explanations coming from additional Ripper errors (https://github.com/zombocom/dead_end/pull/117)
34
- Fix explanation involving shorthand syntax for literals like `%w[]` and `%Q{}` (https://github.com/zombocom/dead_end/pull/116)
45

56
## 3.0.2

lib/dead_end/ripper_errors.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ def on_parse_error(msg)
1818
@errors << msg
1919
end
2020

21+
alias_method :on_alias_error, :on_parse_error
22+
alias_method :on_assign_error, :on_parse_error
23+
alias_method :on_class_name_error, :on_parse_error
24+
alias_method :on_param_error, :on_parse_error
25+
alias_method :compile_error, :on_parse_error
26+
2127
def call
2228
@run_once ||= begin
2329
@errors = []

spec/unit/explain_syntax_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@
44

55
module DeadEnd
66
RSpec.describe "ExplainSyntax" do
7+
it "handles shorthand syntaxes with non-bracket characters" do
8+
source = <<~EOM
9+
%Q* lol
10+
EOM
11+
12+
explain = ExplainSyntax.new(
13+
code_lines: CodeLine.from_source(source)
14+
).call
15+
16+
expect(explain.missing).to eq([])
17+
expect(explain.errors.join).to include("unterminated string")
18+
end
19+
720
it "handles %w[]" do
821
source = <<~EOM
922
node.is_a?(Op) && %w[| ||].include?(node.value) &&

0 commit comments

Comments
 (0)