Class: Reek::SmellWarning
- Inherits:
-
Object
- Object
- Reek::SmellWarning
- Extended by:
- Forwardable
- Includes:
- Comparable
- Defined in:
- lib/reek/smell_warning.rb
Overview
Reports a warning that a smell has been found.
Instance Attribute Summary collapse
- #context ⇒ Object readonly
- #lines ⇒ Object readonly
- #message ⇒ Object readonly
- #parameters ⇒ Object readonly
- #smell_type ⇒ Object readonly
- #source ⇒ Object readonly
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #base_hash ⇒ Object private
- #base_message ⇒ Object
- #eql?(other) ⇒ Boolean
- #explanatory_link ⇒ Object
- #hash ⇒ Object
-
#initialize(smell_type, lines:, message:, source:, context: '', parameters: {}) ⇒ SmellWarning
constructor
A new instance of SmellWarning.
- #to_hash ⇒ Object
- #yaml_hash ⇒ Object
Constructor Details
#initialize(smell_type, lines:, message:, source:, context: '', parameters: {}) ⇒ SmellWarning
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.
Returns a new instance of SmellWarning.
34 35 36 37 38 39 40 41 42 43 |
# 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 = @parameters = parameters freeze end |
Instance Attribute Details
#context ⇒ Object (readonly)
18 19 20 |
# File 'lib/reek/smell_warning.rb', line 18 def context @context end |
#lines ⇒ Object (readonly)
18 19 20 |
# File 'lib/reek/smell_warning.rb', line 18 def lines @lines end |
#message ⇒ Object (readonly)
18 19 20 |
# File 'lib/reek/smell_warning.rb', line 18 def @message end |
#parameters ⇒ Object (readonly)
18 19 20 |
# File 'lib/reek/smell_warning.rb', line 18 def parameters @parameters end |
#smell_type ⇒ Object (readonly)
18 19 20 |
# File 'lib/reek/smell_warning.rb', line 18 def smell_type @smell_type end |
#source ⇒ Object (readonly)
18 19 20 |
# File 'lib/reek/smell_warning.rb', line 18 def source @source end |
Instance Method Details
#<=>(other) ⇒ Object
51 52 53 |
# File 'lib/reek/smell_warning.rb', line 51 def <=>(other) <=> other. end |
#base_hash ⇒ Object (private)
86 87 88 89 90 91 92 93 94 |
# File 'lib/reek/smell_warning.rb', line 86 def base_hash { 'context' => context, 'lines' => lines, 'message' => , 'smell_type' => smell_type, 'source' => source } end |
#base_message ⇒ Object
70 71 72 |
# File 'lib/reek/smell_warning.rb', line 70 def "#{smell_type}: #{context} #{}" end |
#eql?(other) ⇒ Boolean
56 57 58 |
# File 'lib/reek/smell_warning.rb', line 56 def eql?(other) (self <=> other).zero? end |
#explanatory_link ⇒ Object
74 75 76 |
# File 'lib/reek/smell_warning.rb', line 74 def explanatory_link DocumentationLink.build(smell_type) end |
#hash ⇒ Object
46 47 48 |
# File 'lib/reek/smell_warning.rb', line 46 def hash .hash end |
#to_hash ⇒ Object
61 62 63 64 |
# File 'lib/reek/smell_warning.rb', line 61 def to_hash stringified_params = parameters.transform_keys(&:to_s) base_hash.merge(stringified_params) end |
#yaml_hash ⇒ Object
66 67 68 |
# File 'lib/reek/smell_warning.rb', line 66 def yaml_hash to_hash.merge('documentation_link' => explanatory_link) end |