class RuboCop::Cop::Chef::Ruby::UnlessDefinedRequire
wrap your require statement with an ‘if defined?()` check.
Rubygems is VERY slow to require gems even if they’ve already been loaded. To work around this
def on_send(node)
def on_send(node) require?(node) do |r| next if node.parent && node.parent.conditional? # catch both if and unless next unless REQUIRE_TO_CLASS[r] add_offense(node.loc.expression, message: MSG, severity: :refactor) do |corrector| corrector.replace(node.loc.expression, "#{node.source} unless defined?(#{REQUIRE_TO_CLASS[r]})") end end end