lib/reek/context/method_context.rb in reek-4.7.3 vs lib/reek/context/method_context.rb in reek-4.8.0

- old
+ new

@@ -21,24 +21,19 @@ def references_self? exp.depends_on_instance? end def uses_param?(param) - # local_nodes(:lvasgn) catches: + # :lvasgn catches: + # # def foo(bar); bar += 1; end - # In this example there is no `lvar` node present. # - # local_nodes(:lvar) catches: + # :lvar catches: + # # def foo(bar); other(bar); end # def foo(bar); tmp = other(bar); tmp[0]; end # - # Note that in the last example the `lvar` node for `bar` is part of an `lvasgn` node for `tmp`. - # This means that if we would just search for [:lvar, :lvasgn] - # (e.g. via Reek::AST::Node#find_nodes) this would fail for this example since we would - # stop at the `lvasgn` and not detect the contained `lvar`. - # Hence we first get all `lvar` nodes followed by all `lvasgn` nodes. - # - (local_nodes(:lvar) + local_nodes(:lvasgn)).find { |node| node.var_name == param.name } + local_nodes([:lvar, :lvasgn]).find { |node| node.var_name == param.name } end # :reek:FeatureEnvy def unused_params exp.arguments.reject do |param|