Skip to content

Commit e919a6e

Browse files
dduuggKaanOzkan
authored andcommitted
Tighten comments to match repo style
1 parent 3b1750d commit e919a6e

1 file changed

Lines changed: 11 additions & 16 deletions

File tree

lib/spoom/deadcode/remover.rb

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,15 @@ def apply_edit
6767

6868
private
6969

70-
# When a method is defined as the argument of a modifier call (e.g. `private def foo; end`,
71-
# `private_class_method def self.foo; end`, or `abstract def foo; end`), the `def` node's
72-
# parent is the modifier call rather than the enclosing class or module body. The sigs and
73-
# comments attached to the method are siblings of the outermost such call, so return a
74-
# context targeting that call to remove them together with the method.
70+
# When a method is defined as the argument of a modifier call (e.g. `private def foo; end` or
71+
# `private_class_method def self.foo; end`), the `def` node's parent is the call rather than the
72+
# enclosing class or module body, so its sigs and comments are siblings of the call. Return a
73+
# context targeting the outermost such call so they are removed together with the method.
7574
#
76-
# Any modifier is matched structurally (rather than from a fixed list) so user-defined and
77-
# future modifiers are handled too. To stay safe, a call only counts as a modifier when the
78-
# wrapped node is its *sole* argument: such a call exists only to wrap that one method, so
79-
# removing it whole is correct regardless of the modifier's name. A call that takes other
80-
# arguments (e.g. `register(:thing, def foo; end)`) has its own purpose, so we leave it in
81-
# place and remove only the `def`. The remaining ambiguous case — a single-argument
82-
# user-defined macro with a side effect — is structurally indistinguishable from a real
83-
# modifier and vanishingly rare, so we treat it like one.
75+
# Modifiers are matched structurally rather than from a fixed list, so user-defined ones are
76+
# handled too. A call only counts as a modifier when the `def` is its sole argument and it takes
77+
# no block, so we never remove a call that does more than wrap the method (e.g.
78+
# `register(:thing, def foo; end)`).
8479
#: (Prism::DefNode def_node) -> NodeContext?
8580
def modifier_call_context(def_node)
8681
wrapped = def_node #: Prism::Node
@@ -91,11 +86,11 @@ def modifier_call_context(def_node)
9186
while (ancestor = nesting.pop)
9287
case ancestor
9388
when Prism::ArgumentsNode
94-
# An arguments node sits between a call and its arguments, keep climbing.
89+
# An arguments node sits between a call and its arguments, keep climbing
9590
next
9691
when Prism::CallNode
97-
# Stop unless this call wraps the node as its sole argument (and takes no block), so we
98-
# never delete sibling arguments or a call doing more than wrapping the method.
92+
# Stop unless the call wraps the node as its sole argument and takes no block, otherwise
93+
# it does more than wrap the method and we must not remove it
9994
args = ancestor.arguments&.arguments
10095
break if ancestor.block
10196
break unless args && args.size == 1 && args.first.equal?(wrapped)

0 commit comments

Comments
 (0)