Sha256: 195b1cee3ae4d1fc21f0875068ff89e686567565c5a73620b7860e6e5ff58625
Contents?: true
Size: 1.23 KB
Versions: 3
Compression:
Stored size: 1.23 KB
Contents
# frozen_string_literal: true 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). # # @example # # bad # Timeout::timeout(500) { do_something } # FileUtils::rmdir(dir) # Marshal::dump(obj) # # # good # Timeout.timeout(500) { do_something } # FileUtils.rmdir(dir) # Marshal.dump(obj) # class ColonMethodCall < Base extend AutoCorrector MSG = 'Do not use `::` for method calls.' # @!method java_type_node?(node) def_node_matcher :java_type_node?, <<~PATTERN (send (const nil? :Java) _) PATTERN def self.autocorrect_incompatible_with [RedundantSelf] end def on_send(node) return unless node.receiver && node.double_colon? return if node.camel_case_method? # ignore Java interop code like Java::int return if java_type_node?(node) add_offense(node.loc.dot) do |corrector| corrector.replace(node.loc.dot, '.') end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rubocop-1.12.1 | lib/rubocop/cop/style/colon_method_call.rb |
rubocop-1.12.0 | lib/rubocop/cop/style/colon_method_call.rb |
rubocop-1.11.0 | lib/rubocop/cop/style/colon_method_call.rb |