Reports a warning that a smell has been found. This object is essentially a DTO, and therefore contains a :reek:attribute or two.
Details of the smell’s location, including its context ({CONTEXT_KEY}), the line numbers on which it occurs ({LINES_KEY}) and the source file ({SOURCE_KEY})
Details of the smell found, including its class ({CLASS_KEY}), subclass ({SUBCLASS_KEY}) and summary message ({MESSAGE_KEY})
@return [Hash{String => String}]
Details of the smell’s status, including whether it is active ({ACTIVE_KEY}) (as opposed to being masked by a config file)
@return [Hash{String => Boolean}]
# File lib/reek/smell_warning.rb, line 22 def initialize(class_name, context, lines, message, source = '', subclass_name = '', parameters = {}) @smell = { CLASS_KEY => class_name, SUBCLASS_KEY => subclass_name, MESSAGE_KEY => message, } @smell.merge!(parameters) @status = { ACTIVE_KEY => true } @location = { CONTEXT_KEY => context.to_s, LINES_KEY => lines, SOURCE_KEY => source } end
# File lib/reek/smell_warning.rb, line 79 def <=>(other) sort_key <=> other.sort_key end
# File lib/reek/smell_warning.rb, line 87 def contains_all?(patterns) rpt = sort_key.to_s return patterns.all? {|pattern| pattern === rpt} end
# File lib/reek/smell_warning.rb, line 61 def context() @location[CONTEXT_KEY] end
# File lib/reek/smell_warning.rb, line 83 def eql?(other) (self <=> other) == 0 end
# File lib/reek/smell_warning.rb, line 73 def is_active() @status[ACTIVE_KEY] end
# File lib/reek/smell_warning.rb, line 62 def lines() @location[LINES_KEY] end
# File lib/reek/smell_warning.rb, line 92 def matches?(klass, patterns) @smell.values.include?(klass.to_s) and contains_all?(patterns) end
# File lib/reek/smell_warning.rb, line 50 def message() @smell[MESSAGE_KEY] end
# File lib/reek/smell_warning.rb, line 96 def report_on(listener) listener.found_smell(self) end
# File lib/reek/smell_warning.rb, line 48 def smell_class() @smell[CLASS_KEY] end
Generated with the Darkfish Rdoc Generator 2.