Skip to content

Commit

Permalink
Raise minimum prism version and fix deprecations
Browse files Browse the repository at this point in the history
Prism 0.28.0 introduced a few breaking changes. In order to keep our code
simple, we've raised the minimum dependency version for prism.
  • Loading branch information
egiurleo committed May 14, 2024
1 parent b16c222 commit 3ce6045
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ PATH
specs:
spoom (1.3.2)
erubi (>= 1.10.0)
prism (>= 0.19.0)
prism (>= 0.28.0)
sorbet-static-and-runtime (>= 0.5.10187)
thor (>= 0.19.2)

Expand Down
13 changes: 11 additions & 2 deletions lib/spoom/deadcode/indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,19 @@ def visit_constant_or_write_node(node)
visit(node.value)
end

sig { override.params(node: Prism::ConstantPathNode).void }
def visit_constant_path_node(node)
parent = node.parent

visit(parent) if parent
reference_constant(node.name.to_s, node)
end

sig { override.params(node: Prism::ConstantPathWriteNode).void }
def visit_constant_path_write_node(node)
parent = node.target.parent
name = node.target.child.slice
const_path_node = node.target
parent = const_path_node.parent
name = const_path_node.name.to_s

if parent
visit(parent)
Expand Down
2 changes: 1 addition & 1 deletion spoom.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency("rake", "~> 13.2.1")

spec.add_dependency("erubi", ">= 1.10.0")
spec.add_dependency("prism", ">= 0.19.0")
spec.add_dependency("prism", ">= 0.28.0")
spec.add_dependency("sorbet-static-and-runtime", ">= 0.5.10187")
spec.add_dependency("thor", ">= 0.19.2")

Expand Down
2 changes: 1 addition & 1 deletion test/spoom/deadcode/index_definitions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def foo(
puts exception.message
assert_equal(<<~ERRORS, exception.message)
Error while parsing foo.rb:
- expected a `)` to close the parameters (at 1:8)
- unexpected end of file; expected a `)` to close the parameters (at 2:0)
- unexpected end of file, assuming it is closing the parent top level context (at 2:0)
- expected an `end` to close the `def` statement (at 1:8)
ERRORS
Expand Down

0 comments on commit 3ce6045

Please sign in to comment.