Sha256: 33440490b2fe010d4846ac6c1135b8db0a9f50e0e2325286b67096e063c08f16
Contents?: true
Size: 889 Bytes
Versions: 8
Compression:
Stored size: 889 Bytes
Contents
# encoding: utf-8 module RuboCop module Cop module Style # This cop checks for methods invoked via the :: operator instead # of the . operator (like FileUtils::rmdir instead of FileUtils.rmdir). class ColonMethodCall < Cop MSG = 'Do not use `::` for method calls.' 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 def allowed_name(method_name) method_name.match(/^[A-Z]/) end def autocorrect(node) @corrections << lambda do |corrector| corrector.replace(node.loc.dot, '.') end end end end end end
Version data entries
8 entries across 8 versions & 2 rubygems