class Reek::SmellWarning
Reports a warning that a smell has been found.
@public
@quality :reek:TooManyInstanceVariables { max_instance_variables: 6 }
Attributes
@public
@public
@public
@public
@public
@public
Public Class Methods
Source
# File lib/reek/smell_warning.rb, line 34 def initialize(smell_type, lines:, message:, source:, context: '', parameters: {}) @smell_type = smell_type @source = source @context = context.to_s @lines = lines @message = message @parameters = parameters freeze end
@param smell_type
[String] type of detected smell; corresponds to
detector#smell_type
@param context [String] name of the context in which the smell occured @param lines [Array<Integer>] list of lines on which the smell occured @param message [String] text describing the smell in more detail @param source [String] name of the source (e.g., the file name) in which
the smell occured
@param parameters [Hash] smell-specific parameters
@note When using Reek’s public API, you should not create SmellWarning
objects yourself. This is why the initializer is not part of the public API.
@quality :reek:LongParameterList { max_params: 6 }
Public Instance Methods
Source
# File lib/reek/smell_warning.rb, line 51 def <=>(other) identifying_values <=> other.identifying_values end
@public
Source
# File lib/reek/smell_warning.rb, line 70 def base_message "#{smell_type}: #{context} #{message}" end
Source
# File lib/reek/smell_warning.rb, line 56 def eql?(other) (self <=> other).zero? end
@public
Source
# File lib/reek/smell_warning.rb, line 74 def explanatory_link DocumentationLink.build(smell_type) end
Source
# File lib/reek/smell_warning.rb, line 46 def hash identifying_values.hash end
@public
Source
# File lib/reek/smell_warning.rb, line 61 def to_hash stringified_params = parameters.transform_keys(&:to_s) base_hash.merge(stringified_params) end
@public
Source
# File lib/reek/smell_warning.rb, line 66 def yaml_hash to_hash.merge('documentation_link' => explanatory_link) end
Protected Instance Methods
Source
# File lib/reek/smell_warning.rb, line 80 def identifying_values [smell_type, context, message, lines] end
Private Instance Methods
Source
# File lib/reek/smell_warning.rb, line 86 def base_hash { 'context' => context, 'lines' => lines, 'message' => message, 'smell_type' => smell_type, 'source' => source } end