Sha256: 2c7a0d6024047f0fc5dcf7179155e2df43e9991256c86926040d689867926830

Contents?: true

Size: 852 Bytes

Versions: 2

Compression:

Stored size: 852 Bytes

Contents

module RuboCop
  module Cop
    module Facter
      # Check that custom facts do not require files in facter/util, as they've all been removed in cfacter.
      #
      # @example
      #   # bad
      #   Facter::Util::Macaddress.standardize('eth1')
      #
      #   # good
      #   Facter::Core::Resolution.exec('ip  addr show eth1|sed -n 2p').split(' ')[1]
      class FacterUtil < Cop
        # rubocop:disable Metrics/LineLength
        MSG = 'Functionality under facter/util has been mostly removed and must be implemented at the fact-level'.freeze
        # rubocop:enable Metrics/LineLength

        def on_send(node)
          _receiver, method_name, *args = *node

          add_offense(node, :selector) if (method_name == :require && _receiver == nil && args.first.children.first =~ /facter\/util/)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubocop-facter-0.2.1 lib/rubocop/cop/facter/facter_util.rb
rubocop-facter-0.2.0 lib/rubocop/cop/facter/facter_util.rb