Sha256: f5ce28279fe616c1f5f2110cd5e7dafd0d3175f129d19c9358c87981529565ae

Contents?: true

Size: 1.21 KB

Versions: 6833

Compression:

Stored size: 1.21 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 < Cop
        MSG = 'Do not use `::` for method calls.'.freeze

        def_node_matcher :java_type_node?, <<-PATTERN
          (send
            (const nil? :Java) _)
        PATTERN

        def self.autocorrect_incompatible_with
          [RedundantSelf]
        end

        def on_send(node)
          # ignore Java interop code like Java::int
          return if java_type_node?(node)

          return unless node.receiver && node.double_colon?
          return if node.camel_case_method?

          add_offense(node, location: :dot)
        end

        def autocorrect(node)
          ->(corrector) { corrector.replace(node.loc.dot, '.') }
        end
      end
    end
  end
end

Version data entries

6,833 entries across 6,827 versions & 26 rubygems

Version Path
cybrid_api_organization_ruby-0.123.162 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/colon_method_call.rb
cybrid_api_id_ruby-0.123.162 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/colon_method_call.rb
cybrid_api_id_ruby-0.123.161 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/colon_method_call.rb
cybrid_api_organization_ruby-0.123.161 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/colon_method_call.rb
cybrid_api_organization_ruby-0.123.160 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/colon_method_call.rb
cybrid_api_id_ruby-0.123.160 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/colon_method_call.rb
cybrid_api_organization_ruby-0.123.159 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/colon_method_call.rb
cybrid_api_id_ruby-0.123.159 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/colon_method_call.rb
cybrid_api_id_ruby-0.123.158 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/colon_method_call.rb
cybrid_api_organization_ruby-0.123.158 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/colon_method_call.rb
cybrid_api_id_ruby-0.123.157 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/colon_method_call.rb
cybrid_api_organization_ruby-0.123.157 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/colon_method_call.rb
cybrid_api_organization_ruby-0.123.156 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/colon_method_call.rb
cybrid_api_id_ruby-0.123.156 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/colon_method_call.rb
messente_api-2.3.0 vendor/bundle/ruby/3.4.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/colon_method_call.rb
cybrid_api_bank_ruby-0.123.153 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/colon_method_call.rb
cybrid_api_id_ruby-0.123.153 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/colon_method_call.rb
cybrid_api_organization_ruby-0.123.153 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/colon_method_call.rb
cybrid_api_bank_ruby-0.123.152 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/colon_method_call.rb
cybrid_api_id_ruby-0.123.152 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/colon_method_call.rb