Sha256: 6ccec696d9f58055e967a8b41f3eb7139f3c1e587c97a0b9576e42c27d69c3dc

Contents?: true

Size: 954 Bytes

Versions: 10

Compression:

Stored size: 954 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Gemspec
      # Prefer `add_dependency` over `add_runtime_dependency` as the latter is
      # considered soft-deprecated.
      #
      # @example
      #
      #   # bad
      #   Gem::Specification.new do |spec|
      #     spec.add_runtime_dependency('rubocop')
      #   end
      #
      #   # good
      #   Gem::Specification.new do |spec|
      #     spec.add_dependency('rubocop')
      #   end
      #
      class AddRuntimeDependency < Base
        extend AutoCorrector

        MSG = 'Use `add_dependency` instead of `add_runtime_dependency`.'

        RESTRICT_ON_SEND = %i[add_runtime_dependency].freeze

        def on_send(node)
          return if !node.receiver || node.arguments.empty?

          add_offense(node.loc.selector) do |corrector|
            corrector.replace(node.loc.selector, 'add_dependency')
          end
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rubocop-1.70.0 lib/rubocop/cop/gemspec/add_runtime_dependency.rb
rubocop-1.69.2 lib/rubocop/cop/gemspec/add_runtime_dependency.rb
rubocop-1.69.1 lib/rubocop/cop/gemspec/add_runtime_dependency.rb
rubocop-1.69.0 lib/rubocop/cop/gemspec/add_runtime_dependency.rb
rubocop-1.68.0 lib/rubocop/cop/gemspec/add_runtime_dependency.rb
rubocop-1.67.0 lib/rubocop/cop/gemspec/add_runtime_dependency.rb
rubocop-1.66.1 lib/rubocop/cop/gemspec/add_runtime_dependency.rb
rubocop-1.66.0 lib/rubocop/cop/gemspec/add_runtime_dependency.rb
rubocop-1.65.1 lib/rubocop/cop/gemspec/add_runtime_dependency.rb
rubocop-1.65.0 lib/rubocop/cop/gemspec/add_runtime_dependency.rb