Sha256: 4e62e4f01a2f7716a6786bcdaf5ec42b619015a1619f66c842e626d5157a8269
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 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 # # * blocks class BlockDuplicationCheck < Base DEFAULT_THRESHOLD = 1 def initialize(options = {}) #:nodoc: super() @threshold = options[:threshold] || DEFAULT_THRESHOLD @interesting_nodes = [:iter] end def evaluate(context) #:nodoc: context.calls.each do |call, number| if number > @threshold && call.method != 'new' add_warning( context, '{{block}} calls {{statement}} {{duplication_number}} times.', { :block => 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/block_duplication_check.rb |