Class: RuboCop::Cop::Facter::FacterUtil

Inherits:
RuboCop::Cop show all
Defined in:
lib/rubocop/cop/facter/facter_util.rb

Overview

Check that custom facts do not require files in facter/util, as they’ve all been removed in cfacter.

Examples:

# bad
Facter::Util::Macaddress.standardize('eth1')

# good
Facter::Core::Resolution.exec('ip  addr show eth1|sed -n 2p').split(' ')[1]

Constant Summary collapse

MSG =

rubocop:disable Metrics/LineLength

'Functionality under facter/util has been mostly removed and must be implemented at the fact-level'.freeze

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object

rubocop:enable Metrics/LineLength



17
18
19
20
21
# File 'lib/rubocop/cop/facter/facter_util.rb', line 17

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