Skip to content

Commit

Permalink
Resolve to the right ERB
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandre Terrasa <[email protected]>
  • Loading branch information
Morriar committed Jun 13, 2024
1 parent 2a588a7 commit 237234c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/spoom/cli/deadcode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def deadcode(*paths)
$stderr.puts "Indexing #{blue(files.size.to_s)} files..."
files.each do |file|
content = File.read(file)
content = ERB.new(content).src if file.end_with?(".erb")
content = Spoom::Deadcode::ERB.new(content).src if file.end_with?(".erb")

tree = Spoom::Deadcode.parse_ruby(content, file: file)
Spoom::Deadcode.index_node(index, tree, content, file: file, plugins: plugins)
Expand Down
18 changes: 18 additions & 0 deletions test/spoom/cli/deadcode_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,24 @@ def test_deadcode_show_plugins_default
assert(result.status)
end

def test_deadcode_parse_erb
@project.write!("view.erb", <<~ERB)
<%= foo do %>
<% end %>
ERB

result = @project.spoom("deadcode --no-color")
assert_equal(<<~ERR, result.err)
Collecting files...
Indexing 1 files...
Analyzing 0 definitions against 5 references...
No dead code found!
ERR
assert_empty(result.out)
assert(result.status)
end

def test_remove
@project.write!("lib/foo.rb", <<~RUBY)
def foo; end
Expand Down

0 comments on commit 237234c

Please sign in to comment.