Sha256: ab0173728d7cfcd38faedd51b8a0e56763479c7788204b1124bd89f6e9ac6869
Contents?: true
Size: 1.07 KB
Versions: 145
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true require "rubocop" require "primer/deprecations" # :nocov: module RuboCop module Cop module Primer # This cop ensures that components don't use deprecated component names # # bad # Primer::ComponentNameComponent.new() # # good # Primer::Beta::ComponentName.new() class ComponentNameMigration < BaseCop def on_send(node) return unless node.method_name == :new && !node.receiver.nil? && ::Primer::Deprecations.deprecated?(node.receiver.const_name) message = ::Primer::Deprecations.deprecation_message(node.receiver.const_name) add_offense(node.receiver, message: message) end def autocorrect(node) lambda do |corrector| component_name = node.const_name return unless ::Primer::Deprecations.correctable?(component_name) replacement = ::Primer::Deprecations.replacement(component_name) corrector.replace(node, replacement) if replacement.present? end end end end end end
Version data entries
145 entries across 145 versions & 2 rubygems