Parent

Files

Class/Module Index [+]

Quicksearch

RuboCop::Cop::Style::ColonMethodCall

This cop checks for methods invoked via the

operator instead

of the . operator (like FileUtils::rmdir instead of FileUtils.rmdir).

Constants

MSG

Public Instance Methods

allowed_name(method_name) click to toggle source
# File lib/rubocop/cop/style/colon_method_call.rb, line 20
def allowed_name(method_name)
  method_name.match(/^[A-Z]/)
end
autocorrect(node) click to toggle source
# File lib/rubocop/cop/style/colon_method_call.rb, line 24
def autocorrect(node)
  @corrections << lambda do |corrector|
    corrector.replace(node.loc.dot, '.')
  end
end
on_send(node) click to toggle source
# File lib/rubocop/cop/style/colon_method_call.rb, line 10
def on_send(node)
  receiver, method_name, *_args = *node

  # discard methods with nil receivers and op methods(like [])
  return unless receiver && node.loc.dot && node.loc.dot.is?('::')
  return if allowed_name(method_name.to_s)

  add_offense(node, :dot)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.