Class: Rubycritic::Smell

Inherits:
Object
  • Object
show all
Defined in:
lib/rubycritic/core/smell.rb

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



24
25
26
# File 'lib/rubycritic/core/smell.rb', line 24

def ==(other)
  state == other.state
end

#at_location?(other_location) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/rubycritic/core/smell.rb', line 16

def at_location?(other_location)
  locations.any? { |location| location == other_location }
end

#hashObject



49
50
51
# File 'lib/rubycritic/core/smell.rb', line 49

def hash
  state.hash
end

#multiple_locations?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/rubycritic/core/smell.rb', line 20

def multiple_locations?
  locations.length > 1
end

#to_hObject



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/rubycritic/core/smell.rb', line 33

def to_h
  {
    context: context,
    cost: cost,
    locations: locations,
    message: message,
    score: score,
    status: status,
    type: type
  }
end

#to_json(*a) ⇒ Object



45
46
47
# File 'lib/rubycritic/core/smell.rb', line 45

def to_json(*a)
  to_h.to_json(*a)
end

#to_sObject



29
30
31
# File 'lib/rubycritic/core/smell.rb', line 29

def to_s
  "(#{type}) #{context} #{message}"
end