Class: Reek::CodeClimate::CodeClimateFingerprint
- Inherits:
-
Object
- Object
- Reek::CodeClimate::CodeClimateFingerprint
- Defined in:
- lib/reek/code_climate/code_climate_fingerprint.rb
Overview
Generates a string to uniquely identify a smell
Constant Summary collapse
- NON_IDENTIFYING_PARAMETERS =
[:count, :depth].freeze
Instance Attribute Summary collapse
-
#warning ⇒ Object
readonly
private
Returns the value of attribute warning.
Instance Method Summary collapse
- #compute ⇒ Object
- #identify_warning ⇒ Object private
- #identifying_aspects ⇒ Object private
-
#initialize(warning) ⇒ CodeClimateFingerprint
constructor
A new instance of CodeClimateFingerprint.
- #parameters ⇒ Object private
- #warning_uniquely_identifiable? ⇒ Boolean private
Constructor Details
#initialize(warning) ⇒ CodeClimateFingerprint
Returns a new instance of CodeClimateFingerprint.
11 12 13 |
# File 'lib/reek/code_climate/code_climate_fingerprint.rb', line 11 def initialize(warning) @warning = warning end |
Instance Attribute Details
#warning ⇒ Object (readonly, private)
Returns the value of attribute warning.
25 26 27 |
# File 'lib/reek/code_climate/code_climate_fingerprint.rb', line 25 def warning @warning end |
Instance Method Details
#compute ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/reek/code_climate/code_climate_fingerprint.rb', line 15 def compute return unless warning_uniquely_identifiable? identify_warning .hexdigest.freeze end |
#identify_warning ⇒ Object (private)
27 28 29 30 31 32 |
# File 'lib/reek/code_climate/code_climate_fingerprint.rb', line 27 def identify_warning << warning.source << warning.smell_type << warning.context << parameters end |
#identifying_aspects ⇒ Object (private)
34 35 36 |
# File 'lib/reek/code_climate/code_climate_fingerprint.rb', line 34 def @identifying_aspects ||= Digest::MD5.new end |
#parameters ⇒ Object (private)
38 39 40 |
# File 'lib/reek/code_climate/code_climate_fingerprint.rb', line 38 def parameters warning.parameters.except(*NON_IDENTIFYING_PARAMETERS).sort.to_s end |
#warning_uniquely_identifiable? ⇒ Boolean (private)
42 43 44 45 46 47 48 |
# File 'lib/reek/code_climate/code_climate_fingerprint.rb', line 42 def warning_uniquely_identifiable? # These could be identifiable if they had parameters ![ 'ManualDispatch', 'NilCheck' ].include?(warning.smell_type) end |