Sha256: 0a31ee80d866ea6de00805763b737f9be2a94d674baccf64d7db5eec4eb48706

Contents?: true

Size: 793 Bytes

Versions: 252

Compression:

Stored size: 793 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  class ConfigObsoletion
    # Encapsulation of a ConfigObsoletion rule for renaming
    # a cop or moving it to a new department.
    # @api private
    class RenamedCop < CopRule
      attr_reader :new_name

      def initialize(config, old_name, new_name)
        super(config, old_name)
        @new_name = new_name
      end

      def rule_message
        "The `#{old_name}` cop has been #{verb} to `#{new_name}`."
      end

      private

      def moved?
        old_badge = Cop::Badge.parse(old_name)
        new_badge = Cop::Badge.parse(new_name)

        old_badge.department != new_badge.department && old_badge.cop_name == new_badge.cop_name
      end

      def verb
        moved? ? 'moved' : 'renamed'
      end
    end
  end
end

Version data entries

252 entries across 243 versions & 24 rubygems

Version Path
rubocop-1.74.0 lib/rubocop/config_obsoletion/renamed_cop.rb
rubocop-1.73.2 lib/rubocop/config_obsoletion/renamed_cop.rb
siteimprove_api_client-1.0.1 vendor/bundle/ruby/3.2.0/gems/rubocop-1.73.1/lib/rubocop/config_obsoletion/renamed_cop.rb
rubocop-1.73.1 lib/rubocop/config_obsoletion/renamed_cop.rb
rubocop-1.73.0 lib/rubocop/config_obsoletion/renamed_cop.rb
rubocop-1.72.2 lib/rubocop/config_obsoletion/renamed_cop.rb
rubocop-1.72.1 lib/rubocop/config_obsoletion/renamed_cop.rb
rubocop-1.72.0 lib/rubocop/config_obsoletion/renamed_cop.rb
rubocop-1.71.2 lib/rubocop/config_obsoletion/renamed_cop.rb
tailscale_middleware-0.0.3 vendor/cache/ruby/3.4.0/gems/rubocop-1.71.1/lib/rubocop/config_obsoletion/renamed_cop.rb
rubocop-1.71.1 lib/rubocop/config_obsoletion/renamed_cop.rb
rubocop-1.71.0 lib/rubocop/config_obsoletion/renamed_cop.rb
rubocop-1.70.0 lib/rubocop/config_obsoletion/renamed_cop.rb
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/rubocop-1.64.1/lib/rubocop/config_obsoletion/renamed_cop.rb
rubocop-1.69.2 lib/rubocop/config_obsoletion/renamed_cop.rb
rubocop-1.69.1 lib/rubocop/config_obsoletion/renamed_cop.rb
rubocop-1.69.0 lib/rubocop/config_obsoletion/renamed_cop.rb
rubocop-1.68.0 lib/rubocop/config_obsoletion/renamed_cop.rb
rubocop-1.67.0 lib/rubocop/config_obsoletion/renamed_cop.rb
rubocop-1.66.1 lib/rubocop/config_obsoletion/renamed_cop.rb