Module: Laser::Analysis::OverrideSafetyInfo

Defined in:
lib/laser/analysis/override_safety_info.rb

Constant Summary

ALWAYS_CALL_SUPER_KERNEL =
'Always call super when overriding Kernel#%s.'
ALWAYS_CALL_SUPER_MODULE =
'Always call super when overriding Module#%s.'
KERNEL_SUPER_NEEDED =
%w(throw catch raise loop proc lambda throw abort
autoload method methods exit exit! sleep puts p fork exec warn test trap)
MODULE_SUPER_NEEDED =
%w(attr attr_reader attr_writer attr_accessor include
extend)

Class Method Summary (collapse)

Class Method Details

+ (Boolean) needs_super_on_override?(method)

Returns:

  • (Boolean)


8
9
10
# File 'lib/laser/analysis/override_safety_info.rb', line 8

def self.needs_super_on_override?(method)
  super_when_override.include?(method)
end

+ (Boolean) warn_on_any_override?(method)

Returns:

  • (Boolean)


4
5
6
# File 'lib/laser/analysis/override_safety_info.rb', line 4

def self.warn_on_any_override?(method)
  do_not_override.include?(method)
end

+ (Object) warning_message(method, overridden_name)

Returns the warning message when method is overridden. Since we may actually be overriding an alias, we need to provide the name of the override, and substitute it into the message.



15
16
17
# File 'lib/laser/analysis/override_safety_info.rb', line 15

def self.warning_message(method, overridden_name)
  (do_not_override[method] || super_when_override[method]) % overridden_name
end