Sha256: 4fd215a656eb5faa5fd5e724e511b8648cb48466086ad83a0302d9738abfa647
Contents?: true
Size: 1.73 KB
Versions: 17
Compression:
Stored size: 1.73 KB
Contents
module Inch module Language module JavaScript module Evaluation # Proxy class for functions class FunctionObject < Base def evaluate super evaluate_parameters end protected def relevant_roles relevant_base_roles.merge(relevant_function_roles) end private def evaluate_parameters params = object.parameters per_param = score_for_single_parameter params.each do |param| role_classes = relevant_parameter_roles(param, per_param) __evaluate(param, role_classes) end end def relevant_function_roles { Role::Function::Getter => nil, Role::Function::Setter => nil, Role::Function::Overridden => if object.overridden? object.overridden_method.score else nil end } end def relevant_parameter_roles(_param, per_param) { Role::FunctionParameter::WithWrongMention => -score_for(:parameters), Role::FunctionParameter::WithMention => per_param * 0.5, Role::FunctionParameter::WithoutMention => per_param * 0.5, Role::FunctionParameter::WithType => per_param * 0.5, Role::FunctionParameter::WithoutType => per_param * 0.5, Role::FunctionParameter::WithBadName => nil, } end def score_for_single_parameter @param_score ||= score_for(:parameters) / object.parameters.size end end end end end end
Version data entries
17 entries across 17 versions & 1 rubygems