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?



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

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

#at_location?(other_location) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#hashObject



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

def hash
  state.hash
end

#multiple_locations?Boolean

Returns:

  • (Boolean)


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

def multiple_locations?
  locations.length > 1
end

#to_hObject



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

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

#to_json(*a) ⇒ Object



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

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

#to_sObject



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

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