Class: LintFu::Issue

Inherits:
Object
  • Object
show all
Defined in:
lib/lint_fu/issue.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scan, file, sexp, confidence = 1.0) ⇒ Issue

Returns a new instance of Issue.



5
6
7
8
9
10
# File 'lib/lint_fu/issue.rb', line 5

def initialize(scan, file, sexp, confidence=1.0)
  @scan = scan
  @file = file
  @sexp = sexp.deep_clone
  self.confidence = confidence
end

Instance Attribute Details

#confidenceObject

Returns the value of attribute confidence.



3
4
5
# File 'lib/lint_fu/issue.rb', line 3

def confidence
  @confidence
end

#fileObject (readonly)

Returns the value of attribute file.



3
4
5
# File 'lib/lint_fu/issue.rb', line 3

def file
  @file
end

#sexpObject (readonly)

Returns the value of attribute sexp.



3
4
5
# File 'lib/lint_fu/issue.rb', line 3

def sexp
  @sexp
end

Instance Method Details

#briefObject



20
21
22
# File 'lib/lint_fu/issue.rb', line 20

def brief
  self.class.name.split('::')[-1].underscore.gsub('_', ' ').titleize
end

#detailObject



24
25
26
# File 'lib/lint_fu/issue.rb', line 24

def detail
  "There is an issue at #{file_basename}:#{line}."
end

#file_basenameObject



32
33
34
# File 'lib/lint_fu/issue.rb', line 32

def file_basename
  File.basename(file)
end

#issue_hashObject



36
37
38
# File 'lib/lint_fu/issue.rb', line 36

def issue_hash()
  Digest::SHA1.hexdigest("#{self.class.name} - #{self.relative_file} - #{sexp.fingerprint}")
end

#lineObject



12
13
14
# File 'lib/lint_fu/issue.rb', line 12

def line
  @sexp.line
end

#reference_infoObject



28
29
30
# File 'lib/lint_fu/issue.rb', line 28

def reference_info
  "No reference information is available for #{brief}."
end

#relative_fileObject



16
17
18
# File 'lib/lint_fu/issue.rb', line 16

def relative_file
  File.relative_path(@scan.fs_root, file)
end