Class: Nitpick::Warnings::RescueValue

Inherits:
SimpleWarning show all
Defined in:
lib/nitpick/warnings/rescue_value.rb

Instance Method Summary collapse

Methods inherited from SimpleWarning

#==, discover

Constructor Details

#initialize(*args) ⇒ RescueValue

Returns a new instance of RescueValue.



4
5
6
# File 'lib/nitpick/warnings/rescue_value.rb', line 4

def initialize(*args)
  @exceptions, *@rescue_value = args
end

Instance Method Details

#matches?Boolean

Returns:

  • (Boolean)


8
9
10
11
12
13
14
15
# File 'lib/nitpick/warnings/rescue_value.rb', line 8

def matches?
  return false if @rescue_value.nil?
  return false if @rescue_value.size > 1
  return false if @rescue_value.empty?
  val = @rescue_value.first
  return false if val.nil? or val.empty?
  [:lit, :nil].include? val.first # the value's type
end

#messageObject



17
18
19
# File 'lib/nitpick/warnings/rescue_value.rb', line 17

def message
  "A rescue is returning #{sexp_to_ruby(@rescue_value.first).inspect} directly and may not handle an error."
end