Skip to content
Closed
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
8 changes: 0 additions & 8 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,3 @@ source "https://rubygems.org"

# Specify your gem's dependencies in dead_end.gemspec
gemspec

gem "rake", "~> 12.0"
gem "rspec", "~> 3.0"
gem "stackprof"
gem "standard"
gem "ruby-prof"

gem "benchmark-ips"
72 changes: 38 additions & 34 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,52 +7,56 @@ GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
benchmark-ips (2.9.2)
diff-lcs (1.4.4)
parallel (1.21.0)
parser (3.0.2.0)
benchmark-ips (2.12.0)
diff-lcs (1.5.0)
json (2.6.3)
language_server-protocol (3.17.0.3)
parallel (1.22.1)
parser (3.2.1.1)
ast (~> 2.4.1)
rainbow (3.0.0)
rainbow (3.1.1)
rake (12.3.3)
regexp_parser (2.1.1)
regexp_parser (2.7.0)
rexml (3.2.5)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.10.0)
rspec-core (3.10.0)
rspec-support (~> 3.10.0)
rspec-expectations (3.10.0)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
rspec-mocks (~> 3.12.0)
rspec-core (3.12.1)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-mocks (3.10.0)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.4)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-support (3.10.0)
rubocop (1.20.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.0)
rubocop (1.48.1)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 3.0.0.0)
parser (>= 3.2.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.9.1, < 2.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.26.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.12.0)
parser (>= 3.0.1.1)
rubocop-performance (1.11.5)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.27.0)
parser (>= 3.2.1.0)
rubocop-performance (1.16.0)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
ruby-prof (1.4.3)
ruby-progressbar (1.11.0)
stackprof (0.2.16)
standard (1.3.0)
rubocop (= 1.20.0)
rubocop-performance (= 1.11.5)
unicode-display_width (2.1.0)
ruby-prof (1.6.1)
ruby-progressbar (1.13.0)
stackprof (0.2.23)
standard (1.25.0)
language_server-protocol (~> 3.17.0.2)
rubocop (= 1.48.1)
rubocop-performance (= 1.16.0)
unicode-display_width (2.4.2)

PLATFORMS
ruby
x86_64-darwin-20

DEPENDENCIES
benchmark-ips
Expand All @@ -64,4 +68,4 @@ DEPENDENCIES
syntax_suggest!

BUNDLED WITH
2.3.14
2.4.8
2 changes: 1 addition & 1 deletion lib/syntax_suggest/code_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class CodeSearch

def initialize(source, record_dir: DEFAULT_VALUE)
record_dir = if record_dir == DEFAULT_VALUE
ENV["SYNTAX_SUGGEST_RECORD_DIR"] || ENV["SYNTAX_SUGGEST_DEBUG"] ? "tmp" : nil
(ENV["SYNTAX_SUGGEST_RECORD_DIR"] || ENV["SYNTAX_SUGGEST_DEBUG"]) ? "tmp" : nil
else
record_dir
end
Expand Down
2 changes: 1 addition & 1 deletion lib/syntax_suggest/display_invalid_blocks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def initialize(code_lines:, blocks:, io: $stderr, filename: nil, terminal: DEFAU
@filename = filename
@code_lines = code_lines

@terminal = terminal == DEFAULT_VALUE ? io.isatty : terminal
@terminal = (terminal == DEFAULT_VALUE) ? io.isatty : terminal
end

def document_ok?
Expand Down
6 changes: 3 additions & 3 deletions spec/integration/ruby_command_line_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module SyntaxSuggest
Dir.mktmpdir do |dir|
tmpdir = Pathname(dir)
script = tmpdir.join("script.rb")
script.write <<~'EOM'
script.write <<~EOM
puts Kernel.private_methods
EOM

Expand Down Expand Up @@ -159,7 +159,7 @@ class Dog
Dir.mktmpdir do |dir|
tmpdir = Pathname(dir)
script = tmpdir.join("script.rb")
script.write <<~'EOM'
script.write <<~EOM
$stderr = STDOUT
eval("def lol")
EOM
Expand All @@ -178,7 +178,7 @@ class Dog
Dir.mktmpdir do |dir|
tmpdir = Pathname(dir)
script = tmpdir.join("script.rb")
script.write <<~'EOM'
script.write <<~EOM
break
EOM

Expand Down
14 changes: 7 additions & 7 deletions spec/integration/syntax_suggest_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module SyntaxSuggest
debug_display(benchmark)
end

expect(io.string).to include(<<~'EOM')
expect(io.string).to include(<<~EOM)
6 class SyntaxTree < Ripper
170 def self.parse(source)
174 end
Expand Down Expand Up @@ -53,7 +53,7 @@ module SyntaxSuggest
end

expect(io.string).to_not include("def ruby_install_binstub_path")
expect(io.string).to include(<<~'EOM')
expect(io.string).to include(<<~EOM)
> 1067 def add_yarn_binary
> 1068 return [] if yarn_preinstalled?
> 1069 |
Expand All @@ -71,7 +71,7 @@ module SyntaxSuggest
)
debug_display(io.string)

expect(io.string).to include(<<~'EOM')
expect(io.string).to include(<<~EOM)
1 Rails.application.routes.draw do
> 113 namespace :admin do
> 116 match "/foobar(*path)", via: :all, to: redirect { |_params, req|
Expand All @@ -90,7 +90,7 @@ module SyntaxSuggest
)
debug_display(io.string)

expect(io.string).to include(<<~'EOM')
expect(io.string).to include(<<~EOM)
1 describe "webmock tests" do
22 it "body" do
27 query = Cutlass::FunctionQuery.new(
Expand All @@ -112,7 +112,7 @@ module SyntaxSuggest
)
debug_display(io.string)

expect(io.string).to include(<<~'EOM')
expect(io.string).to include(<<~EOM)
5 module DerailedBenchmarks
6 class RequireTree
7 REQUIRED_BY = {}
Expand Down Expand Up @@ -169,7 +169,7 @@ module SyntaxSuggest
end

it "ambiguous end" do
source = <<~'EOM'
source = <<~EOM
def call # 0
print "lol" # 1
end # one # 2
Expand All @@ -189,7 +189,7 @@ def call # 0
end

it "simple regression" do
source = <<~'EOM'
source = <<~EOM
class Dog
def bark
puts "woof"
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/around_block_scan_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
module SyntaxSuggest
RSpec.describe AroundBlockScan do
it "continues scan from last location even if scan is false" do
source = <<~'EOM'
source = <<~EOM
print 'omg'
print 'lol'
print 'haha'
Expand Down
24 changes: 12 additions & 12 deletions spec/unit/capture_code_context_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
module SyntaxSuggest
RSpec.describe CaptureCodeContext do
it "capture_before_after_kws" do
source = <<~'EOM'
source = <<~EOM
def sit
end

Expand All @@ -23,7 +23,7 @@ def eat
code_lines: code_lines
)
lines = display.call
expect(lines.join).to eq(<<~'EOM')
expect(lines.join).to eq(<<~EOM)
def sit
end
def bark
Expand All @@ -33,7 +33,7 @@ def eat
end

it "handles ambiguous end" do
source = <<~'EOM'
source = <<~EOM
def call # 0
print "lol" # 1
end # one # 2
Expand All @@ -52,7 +52,7 @@ def call # 0

lines = lines.sort.map(&:original)

expect(lines.join).to eq(<<~'EOM')
expect(lines.join).to eq(<<~EOM)
def call # 0
end # one # 2
end # two # 3
Expand All @@ -79,15 +79,15 @@ def call # 0
lines = display.call

lines = lines.sort.map(&:original)
expect(lines.join).to include(<<~'EOM'.indent(2))
expect(lines.join).to include(<<~EOM.indent(2))
class Lookups
def format_requires
end
EOM
end

it "shows ends of captured block" do
source = <<~'EOM'
source = <<~EOM
class Dog
def bark
puts "woof"
Expand All @@ -105,15 +105,15 @@ def bark
code_lines: code_lines
)
lines = display.call.sort.map(&:original)
expect(lines.join).to eq(<<~'EOM')
expect(lines.join).to eq(<<~EOM)
class Dog
def bark
end
EOM
end

it "captures surrounding context on falling indent" do
source = <<~'EOM'
source = <<~EOM
class Blerg
end

Expand All @@ -137,7 +137,7 @@ class Zerg
code_lines: code_lines
)
lines = display.call.sort.map(&:original)
expect(lines.join).to eq(<<~'EOM')
expect(lines.join).to eq(<<~EOM)
class OH
def hello
it "foo" do
Expand All @@ -147,7 +147,7 @@ def hello
end

it "captures surrounding context on same indent" do
source = <<~'EOM'
source = <<~EOM
class Blerg
end
class OH
Expand All @@ -173,7 +173,7 @@ class Zerg

code_lines = CleanDocument.new(source: source).call.lines
block = CodeBlock.new(lines: code_lines[7..10])
expect(block.to_s).to eq(<<~'EOM'.indent(2))
expect(block.to_s).to eq(<<~EOM.indent(2))
def lol
end

Expand All @@ -190,7 +190,7 @@ def lol
lines: lines
).call

expect(out).to eq(<<~'EOM'.indent(2))
expect(out).to eq(<<~EOM.indent(2))
3 class OH
8 def lol
9 end
Expand Down
6 changes: 3 additions & 3 deletions spec/unit/clean_document_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module SyntaxSuggest
source = fixtures_dir.join("this_project_extra_def.rb.txt").read
code_lines = CleanDocument.new(source: source).call.lines

expect(code_lines[18 - 1].to_s).to eq(<<-'EOL')
expect(code_lines[18 - 1].to_s).to eq(<<-EOL)
@io.puts <<~EOM

SyntaxSuggest: A syntax error was detected
Expand Down Expand Up @@ -54,7 +54,7 @@ module SyntaxSuggest
DisplayCodeWithLineNumbers.new(
lines: lines
).call
).to eq(<<~'EOM'.indent(2))
).to eq(<<~EOM.indent(2))
1 User
2 .where(name: 'schneems')
3 .first
Expand All @@ -65,7 +65,7 @@ module SyntaxSuggest
lines: lines,
highlight_lines: lines[0]
).call
).to eq(<<~'EOM')
).to eq(<<~EOM)
> 1 User
> 2 .where(name: 'schneems')
> 3 .first
Expand Down
Loading