Sha256: f795e40be0d5959d53138ac7c7c4879ef4e456ea2ae1b9320db466d1ace6dd94

Contents?: true

Size: 865 Bytes

Versions: 23

Compression:

Stored size: 865 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module InternalAffairs
      # Checks for redundant arguments of `RuboCop::RSpec::ExpectOffense`'s methods.
      #
      # @example
      #
      #   # bad
      #   expect_no_offenses('code', keyword: keyword)
      #
      #   # good
      #   expect_no_offenses('code')
      #
      class RedundantExpectOffenseArguments < Base
        extend AutoCorrector

        MSG = 'Remove the redundant arguments.'
        RESTRICT_ON_SEND = %i[expect_no_offenses].freeze

        def on_send(node)
          return if node.arguments.one? || !node.arguments[1]&.hash_type?

          range = node.first_argument.source_range.end.join(node.last_argument.source_range.end)

          add_offense(range) do |corrector|
            corrector.remove(range)
          end
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 5 rubygems

Version Path
rubocop-1.70.0 lib/rubocop/cop/internal_affairs/redundant_expect_offense_arguments.rb
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/rubocop-1.64.1/lib/rubocop/cop/internal_affairs/redundant_expect_offense_arguments.rb
rubocop-1.69.2 lib/rubocop/cop/internal_affairs/redundant_expect_offense_arguments.rb
rubocop-1.69.1 lib/rubocop/cop/internal_affairs/redundant_expect_offense_arguments.rb
rubocop-1.69.0 lib/rubocop/cop/internal_affairs/redundant_expect_offense_arguments.rb
rubocop-1.68.0 lib/rubocop/cop/internal_affairs/redundant_expect_offense_arguments.rb
rubocop-1.67.0 lib/rubocop/cop/internal_affairs/redundant_expect_offense_arguments.rb
rubocop-1.66.1 lib/rubocop/cop/internal_affairs/redundant_expect_offense_arguments.rb
rubocop-1.66.0 lib/rubocop/cop/internal_affairs/redundant_expect_offense_arguments.rb
rubocop-1.65.1 lib/rubocop/cop/internal_affairs/redundant_expect_offense_arguments.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/rubocop-1.64.1/lib/rubocop/cop/internal_affairs/redundant_expect_offense_arguments.rb
rubocop-1.65.0 lib/rubocop/cop/internal_affairs/redundant_expect_offense_arguments.rb
katalyst-govuk-formbuilder-1.9.2 vendor/bundle/ruby/3.3.0/gems/rubocop-1.64.1/lib/rubocop/cop/internal_affairs/redundant_expect_offense_arguments.rb
rubocop-1.64.1 lib/rubocop/cop/internal_affairs/redundant_expect_offense_arguments.rb
rubocop-1.63.4 lib/rubocop/cop/internal_affairs/redundant_expect_offense_arguments.rb
rubocop-1.63.3 lib/rubocop/cop/internal_affairs/redundant_expect_offense_arguments.rb
rubocop-1.63.2 lib/rubocop/cop/internal_affairs/redundant_expect_offense_arguments.rb
rubocop-1.63.1 lib/rubocop/cop/internal_affairs/redundant_expect_offense_arguments.rb
rubocop-1.63.0 lib/rubocop/cop/internal_affairs/redundant_expect_offense_arguments.rb
bison-0.1.0 vendor/bundle/ruby/3.2.0/gems/rubocop-1.62.1/lib/rubocop/cop/internal_affairs/redundant_expect_offense_arguments.rb