class RuboCop::Cop::Chef::Modernize::LibarchiveFileResource

Use the archive_file resource built into Chef Infra Client 15+ instead of the libarchive_file resource from the libarchive cookbook.

@example

#### incorrect
depends 'libarchive'

libarchive_file "C:\file.zip" do
  path 'C:\expand_here'
end

#### correct
archive_file "C:\file.zip" do
  path 'C:\expand_here'
end

Constants

MSG
RESTRICT_ON_SEND

Public Instance Methods

on_send(node) click to toggle source
# File lib/rubocop/cop/chef/modernize/libarchive_file.rb, line 51
def on_send(node)
  # The need for this goes away once https://github.com/rubocop-hq/rubocop/pull/8365 is pulled into Cookstyle
  if node.method_name == :libarchive_file
    add_offense(node, message: MSG, severity: :refactor) do |corrector|
      corrector.replace(node, node.source.gsub('libarchive_file', 'archive_file'))
    end
  end

  notification_property?(node) do |val|
    next unless val.str_content&.start_with?('libarchive_file')
    add_offense(val, message: MSG, severity: :refactor) do |corrector|
      corrector.replace(node, node.source.gsub('libarchive_file', 'archive_file'))
    end
  end
end