Class: Spektr::Warning

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, full_path, check, location, message, confidence = :high) ⇒ Warning

Returns a new instance of Warning.



7
8
9
10
11
12
13
14
# File 'lib/spektr/warning.rb', line 7

def initialize(path, full_path, check, location, message, confidence = :high)
  @path = path
  @check = check
  @location = location
  @message = message
  @confidence = confidence
  @line = IO.readlines(full_path)[@location.line - 1].strip if full_path && @location && File.exist?(full_path)
end

Instance Attribute Details

#checkObject

Returns the value of attribute check.



5
6
7
# File 'lib/spektr/warning.rb', line 5

def check
  @check
end

#confidenceObject

Returns the value of attribute confidence.



5
6
7
# File 'lib/spektr/warning.rb', line 5

def confidence
  @confidence
end

#full_pathObject

Returns the value of attribute full_path.



5
6
7
# File 'lib/spektr/warning.rb', line 5

def full_path
  @full_path
end

#lineObject

Returns the value of attribute line.



5
6
7
# File 'lib/spektr/warning.rb', line 5

def line
  @line
end

#locationObject

Returns the value of attribute location.



5
6
7
# File 'lib/spektr/warning.rb', line 5

def location
  @location
end

#messageObject

Returns the value of attribute message.



5
6
7
# File 'lib/spektr/warning.rb', line 5

def message
  @message
end

#pathObject

Returns the value of attribute path.



5
6
7
# File 'lib/spektr/warning.rb', line 5

def path
  @path
end

Instance Method Details

#fingerprintObject



24
25
26
# File 'lib/spektr/warning.rb', line 24

def fingerprint
  Digest::MD5.hexdigest("#{path}:#{line}:#{check.name}")
end

#full_messageObject



16
17
18
19
20
21
22
# File 'lib/spektr/warning.rb', line 16

def full_message
  if @location
    "#{message} at line #{@location.line} of #{@path}"
  else
    "#{message}"
  end
end