Sha256: 6d1238f36349c0aff65ddd69fd547b80160f21a0034ef2643b9462e3b83ef719
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
require File.join( File.dirname( File.expand_path(__FILE__)), 'smell_detector') require File.join(File.dirname(File.dirname(File.expand_path(__FILE__))), 'smell_warning') module Reek module Smells # # Methods should use their parameters. # class UnusedParameters < SmellDetector SMELL_CLASS = 'ControlCouple' SMELL_SUBCLASS = name.split(/::/)[-1] PARAMETER_KEY = 'parameter' # # Checks whether the given method has any unused parameters. # # @return [Array<SmellWarning>] # def examine_context(method_ctx) params = method_ctx.exp.arg_names || [] params.select do |param| param = param.to_s.sub(/^\*/, '') !["", "_"].include?(param) && !method_ctx.local_nodes(:lvar).include?(Sexp.new(:lvar, param.to_sym)) end.map do |param| SmellWarning.new(SMELL_CLASS, method_ctx.full_name, [method_ctx.exp.line], "has unused parameter '#{param.to_s}'", @source, SMELL_SUBCLASS, {PARAMETER_KEY => param.to_s}) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
reek-1.3.1 | lib/reek/smells/unused_parameters.rb |
reek-1.3 | lib/reek/smells/unused_parameters.rb |