spoom 1.2.4 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +54 -55
  3. data/lib/spoom/cli/deadcode.rb +172 -0
  4. data/lib/spoom/cli/helper.rb +20 -0
  5. data/lib/spoom/cli/srb/bump.rb +200 -0
  6. data/lib/spoom/cli/srb/coverage.rb +224 -0
  7. data/lib/spoom/cli/srb/lsp.rb +159 -0
  8. data/lib/spoom/cli/srb/tc.rb +150 -0
  9. data/lib/spoom/cli/srb.rb +27 -0
  10. data/lib/spoom/cli.rb +72 -32
  11. data/lib/spoom/context/git.rb +2 -2
  12. data/lib/spoom/context/sorbet.rb +2 -2
  13. data/lib/spoom/deadcode/definition.rb +11 -0
  14. data/lib/spoom/deadcode/indexer.rb +222 -224
  15. data/lib/spoom/deadcode/location.rb +2 -2
  16. data/lib/spoom/deadcode/plugins/action_mailer.rb +2 -2
  17. data/lib/spoom/deadcode/plugins/action_mailer_preview.rb +19 -0
  18. data/lib/spoom/deadcode/plugins/actionpack.rb +4 -6
  19. data/lib/spoom/deadcode/plugins/active_model.rb +8 -8
  20. data/lib/spoom/deadcode/plugins/active_record.rb +9 -12
  21. data/lib/spoom/deadcode/plugins/active_support.rb +11 -0
  22. data/lib/spoom/deadcode/plugins/base.rb +1 -1
  23. data/lib/spoom/deadcode/plugins/graphql.rb +4 -4
  24. data/lib/spoom/deadcode/plugins/namespaces.rb +2 -4
  25. data/lib/spoom/deadcode/plugins/ruby.rb +8 -17
  26. data/lib/spoom/deadcode/plugins/sorbet.rb +4 -10
  27. data/lib/spoom/deadcode/plugins.rb +1 -0
  28. data/lib/spoom/deadcode/remover.rb +209 -174
  29. data/lib/spoom/deadcode/send.rb +9 -10
  30. data/lib/spoom/deadcode/visitor.rb +755 -0
  31. data/lib/spoom/deadcode.rb +40 -10
  32. data/lib/spoom/file_tree.rb +0 -16
  33. data/lib/spoom/sorbet/errors.rb +1 -1
  34. data/lib/spoom/sorbet/lsp/structures.rb +2 -2
  35. data/lib/spoom/version.rb +1 -1
  36. metadata +19 -15
  37. data/lib/spoom/cli/bump.rb +0 -198
  38. data/lib/spoom/cli/coverage.rb +0 -222
  39. data/lib/spoom/cli/lsp.rb +0 -168
  40. data/lib/spoom/cli/run.rb +0 -148
@@ -3,16 +3,15 @@
3
3
 
4
4
  module Spoom
5
5
  module Deadcode
6
- # An abstraction to simplify handling of SyntaxTree::CallNode, SyntaxTree::Command, SyntaxTree::CommandCall and
7
- # SyntaxTree::VCall nodes.
6
+ # An abstraction to simplify handling of Prism::CallNode nodes.
8
7
  class Send < T::Struct
9
8
  extend T::Sig
10
9
 
11
- const :node, SyntaxTree::Node
10
+ const :node, Prism::CallNode
12
11
  const :name, String
13
- const :recv, T.nilable(SyntaxTree::Node), default: nil
14
- const :args, T::Array[SyntaxTree::Node], default: []
15
- const :block, T.nilable(SyntaxTree::Node), default: nil
12
+ const :recv, T.nilable(Prism::Node), default: nil
13
+ const :args, T::Array[Prism::Node], default: []
14
+ const :block, T.nilable(Prism::Node), default: nil
16
15
 
17
16
  sig do
18
17
  type_parameters(:T)
@@ -25,13 +24,13 @@ module Spoom
25
24
  end
26
25
  end
27
26
 
28
- sig { params(block: T.proc.params(key: SyntaxTree::Node, value: T.nilable(SyntaxTree::Node)).void).void }
27
+ sig { params(block: T.proc.params(key: Prism::Node, value: T.nilable(Prism::Node)).void).void }
29
28
  def each_arg_assoc(&block)
30
29
  args.each do |arg|
31
- next unless arg.is_a?(SyntaxTree::BareAssocHash) || arg.is_a?(SyntaxTree::HashLiteral)
30
+ next unless arg.is_a?(Prism::KeywordHashNode) || arg.is_a?(Prism::HashNode)
32
31
 
33
- arg.assocs.each do |assoc|
34
- yield(assoc.key, assoc.value) if assoc.is_a?(SyntaxTree::Assoc)
32
+ arg.elements.each do |assoc|
33
+ yield(assoc.key, assoc.value) if assoc.is_a?(Prism::AssocNode)
35
34
  end
36
35
  end
37
36
  end