lib/reek/context/method_context.rb in reek-4.7.1 vs lib/reek/context/method_context.rb in reek-4.7.2

- old
+ new

@@ -10,13 +10,14 @@ # :reek:Attribute class MethodContext < CodeContext attr_accessor :visibility attr_reader :refs - def initialize(context, exp) + def initialize(exp, parent_exp) + @parent_exp = parent_exp @visibility = :public - super + super exp end def references_self? exp.depends_on_instance? end @@ -34,19 +35,19 @@ # 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.to_sym } + (local_nodes(:lvar) + local_nodes(:lvasgn)).find { |node| node.var_name == param.name } end # :reek:FeatureEnvy def unused_params exp.arguments.reject do |param| param.anonymous_splat? || param.marked_unused? || - uses_param?(param.plain_name) + uses_param?(param) end end def uses_super_with_implicit_arguments? (body = exp.body) && body.contains_nested_node?(:zsuper) @@ -78,8 +79,19 @@ end def non_public_visibility? visibility != :public end + + def full_comment + own = super + return own unless own.empty? + return parent_exp.full_comment if parent_exp + '' + end + + private + + attr_reader :parent_exp end end end