class Reek::Context::MethodContext
A context wrapper for any method definition found in a syntax tree.
@quality :reek:Attribute
Attributes
Public Class Methods
Source
# File lib/reek/context/method_context.rb, line 15 def initialize(exp, parent_exp) @parent_exp = parent_exp @visibility = :public super(exp) end
Calls superclass method
Reek::Context::CodeContext::new
Public Instance Methods
Source
# File lib/reek/context/method_context.rb, line 68 def apply_current_visibility(current_visibility) self.visibility = current_visibility end
Source
# File lib/reek/context/method_context.rb, line 51 def default_assignments @default_assignments ||= exp.parameters.select(&:optional_argument?).map(&:children) end
Source
# File lib/reek/context/method_context.rb, line 80 def full_comment own = super return own unless own.empty? return parent_exp.full_comment if parent_exp '' end
Calls superclass method
Reek::Context::CodeContext#full_comment
Source
# File lib/reek/context/method_context.rb, line 64 def instance_method? true end
Source
# File lib/reek/context/method_context.rb, line 56 def method_context_class self.class end
Source
# File lib/reek/context/method_context.rb, line 72 def module_function? visibility == :module_function end
Source
# File lib/reek/context/method_context.rb, line 76 def non_public_visibility? visibility != :public end
Source
# File lib/reek/context/method_context.rb, line 21 def references_self? exp.depends_on_instance? end
Source
# File lib/reek/context/method_context.rb, line 60 def singleton_method? false end
Source
# File lib/reek/context/method_context.rb, line 39 def unused_params exp.arguments.reject do |param| param.anonymous_splat? || param.marked_unused? || uses_param?(param) end end
@quality :reek:FeatureEnvy
Source
# File lib/reek/context/method_context.rb, line 25 def uses_param?(param) # :lvasgn catches: # # def foo(bar); bar += 1; end # # :lvar catches: # # def foo(bar); other(bar); end # def foo(bar); tmp = other(bar); tmp[0]; end # local_nodes([:lvar, :lvasgn]).find { |node| node.var_name == param.name } end
Source
# File lib/reek/context/method_context.rb, line 47 def uses_super_with_implicit_arguments? (body = exp.body) && body.contains_nested_node?(:zsuper) end