Parent

Included Modules

Class/Module Index [+]

Quicksearch

Reek::SmellWarning

Reports a warning that a smell has been found. This object is essentially a DTO, and therefore contains a :reek:attribute or two.

Attributes

location[R]

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})

@return [Hash{String => String, Array<Number>}]

smell[R]

Details of the smell found, including its class ({CLASS_KEY}), subclass ({SUBCLASS_KEY}) and summary message ({MESSAGE_KEY})

@return [Hash{String => String}]

status[R]

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}]

Public Class Methods

new(class_name, context, lines, message, source = '', subclass_name = '', parameters = {}) click to toggle source
# 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

Public Instance Methods

<=>(other) click to toggle source
# File lib/reek/smell_warning.rb, line 79
def <=>(other)
  sort_key <=> other.sort_key
end
contains_all?(patterns) click to toggle source
# File lib/reek/smell_warning.rb, line 87
def contains_all?(patterns)
  rpt = sort_key.to_s
  return patterns.all? {|pattern| pattern === rpt}
end
context() click to toggle source
# File lib/reek/smell_warning.rb, line 61
def context() @location[CONTEXT_KEY] end
eql?(other) click to toggle source
# File lib/reek/smell_warning.rb, line 83
def eql?(other)
  (self <=> other) == 0
end
hash() click to toggle source
# File lib/reek/smell_warning.rb, line 75
def hash
  sort_key.hash
end
is_active() click to toggle source
# File lib/reek/smell_warning.rb, line 73
def is_active() @status[ACTIVE_KEY] end
lines() click to toggle source
# File lib/reek/smell_warning.rb, line 62
def lines() @location[LINES_KEY] end
matches?(klass, patterns) click to toggle source
# File lib/reek/smell_warning.rb, line 92
def matches?(klass, patterns)
  @smell.values.include?(klass.to_s) and contains_all?(patterns)
end
message() click to toggle source
# File lib/reek/smell_warning.rb, line 50
def message() @smell[MESSAGE_KEY] end
report_on(listener) click to toggle source
# File lib/reek/smell_warning.rb, line 96
def report_on(listener)
  listener.found_smell(self)
end
smell_class() click to toggle source
# File lib/reek/smell_warning.rb, line 48
def smell_class() @smell[CLASS_KEY] end
source() click to toggle source
# File lib/reek/smell_warning.rb, line 63
def source() @location[SOURCE_KEY] end
subclass() click to toggle source
# File lib/reek/smell_warning.rb, line 49
def subclass() @smell[SUBCLASS_KEY] end

Protected Instance Methods

sort_key() click to toggle source
# File lib/reek/smell_warning.rb, line 102
def sort_key
  [@location[CONTEXT_KEY], @smell[MESSAGE_KEY], @smell[CLASS_KEY]]
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.