Sha256: a53bc9d3822f06f88451562c69753e41732bbeabbae45df437ead571f7f45e8f
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 KB
Contents
require 'simplabs/excellent/checks/base' module Simplabs module Excellent module Checks # This check reports duplicated code. It currently finds repeated identical method calls such as: # # def method # other_method + other_method # end # # ==== Applies to # # * methods class MethodDuplicationCheck < Base DEFAULT_THRESHOLD = 1 def initialize(options = {}) #:nodoc: super() @threshold = options[:threshold] || DEFAULT_THRESHOLD @interesting_nodes = [:defn, :defs] end def evaluate(context) #:nodoc: context.calls.each do |call, number| if number > @threshold && call.method != 'new' add_warning( context, '{{method}} calls {{statement}} {{duplication_number}} times.', { :method => context.full_name, :statement => call.full_name, :duplication_number => number } ) end end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
simplabs-excellent-1.5.0 | lib/simplabs/excellent/checks/method_duplication_check.rb |