class RubbyCop::Cop::Lint::DeprecatedClassMethods
This cop checks for uses of the deprecated class method usages.
@example
# bad File.exists?(some_path)
@example
# good File.exist?(some_path)
Constants
- DEPRECATED_METHODS_OBJECT
- MSG
Public Instance Methods
autocorrect(node)
click to toggle source
# File lib/rubbycop/cop/lint/deprecated_class_methods.rb, line 57 def autocorrect(node) lambda do |corrector| check(node) do |data| corrector.replace(node.loc.selector, data.replacement_method.to_s) end end end
on_send(node)
click to toggle source
# File lib/rubbycop/cop/lint/deprecated_class_methods.rb, line 48 def on_send(node) check(node) do |data| add_offense(node, :selector, format(MSG, deprecated_method(data), replacement_method(data))) end end
Private Instance Methods
check(node) { |data| ... }
click to toggle source
# File lib/rubbycop/cop/lint/deprecated_class_methods.rb, line 68 def check(node) DEPRECATED_METHODS_OBJECT.each do |data| next unless data.class_nodes.include?(node.receiver) next unless node.method?(data.deprecated_method) yield data end end
deprecated_method(data)
click to toggle source
# File lib/rubbycop/cop/lint/deprecated_class_methods.rb, line 76 def deprecated_method(data) method_call(data.class_constant, data.deprecated_method) end
method_call(class_constant, method)
click to toggle source
# File lib/rubbycop/cop/lint/deprecated_class_methods.rb, line 84 def method_call(class_constant, method) format('%s.%s', class_constant, method) end
replacement_method(data)
click to toggle source
# File lib/rubbycop/cop/lint/deprecated_class_methods.rb, line 80 def replacement_method(data) method_call(data.class_constant, data.replacement_method) end