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?



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

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

#at_location?(other_location) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#doc_urlObject



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

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



66
67
68
# File 'lib/rubycritic/core/smell.rb', line 66

def hash
  state.hash
end

#multiple_locations?Boolean

Returns:

  • (Boolean)


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

def multiple_locations?
  locations.length > 1
end

#to_hObject



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

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

#to_json(*a) ⇒ Object



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

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

#to_sObject



33
34
35
# File 'lib/rubycritic/core/smell.rb', line 33

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