Class: CodeHunter::Warning

Inherits:
Object
  • Object
show all
Defined in:
lib/code_hunter/warning.rb

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Warning

Returns a new instance of Warning.



3
4
5
# File 'lib/code_hunter/warning.rb', line 3

def initialize(attributes)
  @attributes = attributes
end

Instance Method Details

#authorObject



45
46
47
# File 'lib/code_hunter/warning.rb', line 45

def author
  @git_metadata[:author]
end

#emailObject



49
50
51
# File 'lib/code_hunter/warning.rb', line 49

def email
  @git_metadata[:email]
end

#git_metadataObject

Fetch @git_metadata only once.



58
59
60
61
62
63
64
65
66
67
# File 'lib/code_hunter/warning.rb', line 58

def 
  case @git_metadata
  when nil
    @git_metadata = GitBlamer.new(@attributes).blame || false
  when false
    nil
  else
    @git_metadata
  end
end

#has_git_metadata?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/code_hunter/warning.rb', line 69

def has_git_metadata?
  !!
end

#ignore?Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/code_hunter/warning.rb', line 73

def ignore?
  path && line && has_ignore_annotation?
end

#lineObject



21
22
23
# File 'lib/code_hunter/warning.rb', line 21

def line
  @attributes[:line]
end

#messageObject



25
26
27
# File 'lib/code_hunter/warning.rb', line 25

def message
  @attributes[:message]
end

#modified_atObject



53
54
55
# File 'lib/code_hunter/warning.rb', line 53

def modified_at
  @git_metadata[:modified_at]
end

#pathObject



29
30
31
# File 'lib/code_hunter/warning.rb', line 29

def path
  @attributes[:path]
end

#serviceObject



33
34
35
# File 'lib/code_hunter/warning.rb', line 33

def service
  @attributes[:service]
end

#sha1Object



41
42
43
# File 'lib/code_hunter/warning.rb', line 41

def sha1
  @git_metadata[:sha1]
end

#to_hashObject



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/code_hunter/warning.rb', line 7

def to_hash
  {
    :line        => line,
    :message     => message,
    :path        => path,
    :service     => service,
    :url         => url,
    :sha1        => sha1,
    :author      => author,
    :email       => email,
    :modified_at => modified_at,
  }
end

#urlObject



37
38
39
# File 'lib/code_hunter/warning.rb', line 37

def url
  @attributes[:url]
end