Class: RubyCritic::Smell

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

Constant Summary collapse

FLAY_DOCS_URL =
'http://docs.seattlerb.org/flay/'.freeze
FLOG_DOCS_URL =
'http://docs.seattlerb.org/flog/'.freeze

Instance Method Summary collapse

Instance Method Details

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



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

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

#at_location?(other_location) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#doc_urlObject



55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/rubycritic/core/smell.rb', line 55

def doc_url
  case analyser
  when 'reek'
    "https://github.com/troessner/reek/blob/master/docs/#{dasherized_type}.md"
  when 'flay'
    FLAY_DOCS_URL
  when 'flog'
    FLOG_DOCS_URL
  else
    raise "No documentation URL set for analyser '#{analyser}' smells"
  end
end

#hashObject



68
69
70
# File 'lib/rubycritic/core/smell.rb', line 68

def hash
  state.hash
end

#multiple_locations?Boolean

Returns:

  • (Boolean)


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

def multiple_locations?
  locations.length > 1
end

#to_hObject



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/rubycritic/core/smell.rb', line 39

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

#to_json(*options) ⇒ Object



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

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

#to_sObject



35
36
37
# File 'lib/rubycritic/core/smell.rb', line 35

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