Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ references:
command: bundle exec standardrb

jobs:
"ruby-2-5":
docker:
- image: circleci/ruby:2.5
steps:
- checkout
- ruby/install-deps
- <<: *unit

"ruby-2-6":
docker:
- image: circleci/ruby:2.6
Expand Down Expand Up @@ -49,6 +57,7 @@ workflows:
version: 2
build:
jobs:
- "ruby-2-5"
- "ruby-2-6"
- "ruby-2-7"
- "ruby-3-0"
Expand Down
2 changes: 1 addition & 1 deletion .standard.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby_version: 2.6.6
ruby_version: 2.5.9
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## HEAD (unreleased)

- Reintroduce Ruby 2.5 support (https://github.com/zombocom/dead_end/pull/90)
- Support naked braces/brackets/parens, invert labels on banner (https://github.com/zombocom/dead_end/pull/89)
- Handle mismatched end when using rescue without begin (https://github.com/zombocom/dead_end/pull/83)
- CLI returns non-zero exit code when syntax error is found (https://github.com/zombocom/dead_end/pull/86)
Expand Down
2 changes: 1 addition & 1 deletion lib/dead_end/around_block_scan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def after_index
end

private def after_lines
@code_lines[after_index.next..] || []
@code_lines[after_index.next..-1] || []
end
end
end
8 changes: 4 additions & 4 deletions lib/dead_end/clean_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def join_heredoc!
#
def join_consecutive!
consecutive_groups = @document.select(&:ignore_newline_not_beg?).map do |code_line|
take_while_including(code_line.index..) do |line|
take_while_including(code_line.index..-1) do |line|
line.ignore_newline_not_beg?
end
end
Expand All @@ -252,7 +252,7 @@ def join_consecutive!
# expect(lines[1].to_s).to eq("")
def join_trailing_slash!
trailing_groups = @document.select(&:trailing_slash?).map do |code_line|
take_while_including(code_line.index..) { |x| x.trailing_slash? }
take_while_including(code_line.index..-1) { |x| x.trailing_slash? }
end
join_groups(trailing_groups)
self
Expand Down Expand Up @@ -286,7 +286,7 @@ def join_groups(groups)
)

# Hide the rest of the lines
lines[1..].each do |line|
lines[1..-1].each do |line|
# The above lines already have newlines in them, if add more
# then there will be double newline, use an empty line instead
@document[line.index] = CodeLine.new(line: "", index: line.index, lex: [])
Expand All @@ -300,7 +300,7 @@ def join_groups(groups)
# Like `take_while` except when it stops
# iterating, it also returns the line
# that caused it to stop
def take_while_including(range = 0..)
def take_while_including(range = 0..-1)
take_next_and_stop = false
@document[range].take_while do |line|
next if take_next_and_stop
Expand Down
2 changes: 1 addition & 1 deletion lib/dead_end/lex_all.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def initialize(source:)
last_lineno = source_lines.count

until lineno >= last_lineno
lines = source_lines[lineno..]
lines = source_lines[lineno..-1]

@lex.concat(Ripper.lex(lines.join, "-", lineno + 1))
lineno = @lex.last.first.first + 1
Expand Down
4 changes: 3 additions & 1 deletion lib/dead_end/who_dis_syntax_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ def on_parse_error(msg)
if $1
character = $1.to_sym
@unmatched_symbol = CHARACTERS[character] || character
@unmatched_symbol = :end if @unmatched_symbol == :keyword_end
end
@error_symbol = :unmatched_syntax
when /unexpected '(?<unmatched_symbol>.*)'/
@unmatched_symbol = $1.to_sym if $1
@unmatched_symbol = $1.to_sym
@unmatched_symbol = :end if @unmatched_symbol == :keyword_end
@error_symbol = :unmatched_syntax
when /unexpected `end'/, # Ruby 2.7 and 3.0
/unexpected end/, # Ruby 2.6
Expand Down