Skip to content

Commit 2771dca

Browse files
committed
Update standardrb to Ruby 3.0 standards
1 parent 5051fde commit 2771dca

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

.standard.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ruby_version: 2.5.9
1+
ruby_version: 3.0.0

lib/syntax_suggest/clean_document.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def join_heredoc!
224224
#
225225
def join_consecutive!
226226
consecutive_groups = @document.select(&:ignore_newline_not_beg?).map do |code_line|
227-
take_while_including(code_line.index..-1) do |line|
227+
take_while_including(code_line.index..) do |line|
228228
line.ignore_newline_not_beg?
229229
end
230230
end
@@ -245,7 +245,7 @@ def join_consecutive!
245245
# expect(lines[1].to_s).to eq("")
246246
def join_trailing_slash!
247247
trailing_groups = @document.select(&:trailing_slash?).map do |code_line|
248-
take_while_including(code_line.index..-1) { |x| x.trailing_slash? }
248+
take_while_including(code_line.index..) { |x| x.trailing_slash? }
249249
end
250250
join_groups(trailing_groups)
251251
self
@@ -279,7 +279,7 @@ def join_groups(groups)
279279
)
280280

281281
# Hide the rest of the lines
282-
lines[1..-1].each do |line|
282+
lines[1..].each do |line|
283283
# The above lines already have newlines in them, if add more
284284
# then there will be double newline, use an empty line instead
285285
@document[line.index] = CodeLine.new(line: "", index: line.index, lex: [])
@@ -293,7 +293,7 @@ def join_groups(groups)
293293
# Like `take_while` except when it stops
294294
# iterating, it also returns the line
295295
# that caused it to stop
296-
def take_while_including(range = 0..-1)
296+
def take_while_including(range = 0..)
297297
take_next_and_stop = false
298298
@document[range].take_while do |line|
299299
next if take_next_and_stop

lib/syntax_suggest/lex_all.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def initialize(source:, source_lines: nil)
1717
last_lineno = source_lines.length
1818

1919
until lineno >= last_lineno
20-
lines = source_lines[lineno..-1]
20+
lines = source_lines[lineno..]
2121

2222
@lex.concat(
2323
Ripper::Lexer.new(lines.join, "-", lineno + 1).parse.sort_by(&:pos)

lib/syntax_suggest/scan_history.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def lines
118118
# Returns an array of all the CodeLines that exist after
119119
# the currently scanned block
120120
private def after_lines
121-
@code_lines[@after_index.next..-1] || []
121+
@code_lines[@after_index.next..] || []
122122
end
123123

124124
private def current

spec/unit/capture_code_context_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def call # 0
9494
code_lines = CleanDocument.new(source: source).call.lines
9595

9696
code_lines[0..75].each(&:mark_invisible)
97-
code_lines[77..-1].each(&:mark_invisible)
97+
code_lines[77..].each(&:mark_invisible)
9898
expect(code_lines.join.strip).to eq("class Lookups")
9999

100100
block = CodeBlock.new(lines: code_lines[76..149])
@@ -123,7 +123,7 @@ def bark
123123

124124
code_lines = CleanDocument.new(source: source).call.lines
125125
block = CodeBlock.new(lines: code_lines)
126-
code_lines[1..-1].each(&:mark_invisible)
126+
code_lines[1..].each(&:mark_invisible)
127127

128128
expect(block.to_s.strip).to eq("class Dog")
129129

spec/unit/clean_document_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ module SyntaxSuggest
8585
code_lines = doc.lines
8686

8787
expect(code_lines[0].to_s.count($/)).to eq(5)
88-
code_lines[1..-1].each do |line|
88+
code_lines[1..].each do |line|
8989
expect(line.to_s.strip.length).to eq(0)
9090
end
9191
end

0 commit comments

Comments
 (0)