class RuboCop::Cop::Chef::Correctness::InvalidPlatformValueForPlatformHelper
Pass valid platforms to the value_for_platform helper. See [Infra Language: Platform](docs.chef.io/infra_language/checking_platforms/#platform-values) for a list of many common platform values.
@example
#### incorrect value_for_platform( %w(rhel mac_os_x_server) => { 'default' => 'foo' }, %w(sles) => { 'default' => 'bar' } ) #### correct value_for_platform( %w(redhat mac_os_x) => { 'default' => 'foo' }, %w(opensuseleap) => { 'default' => 'bar' } )
Constants
- MSG
- RESTRICT_ON_SEND
Public Instance Methods
on_send(node)
click to toggle source
# File lib/rubocop/cop/chef/correctness/invalid_value_for_platform_helper.rb, line 51 def on_send(node) value_for_platform?(node) do |plats| plats.each do |p_hash| if p_hash.key.array_type? p_hash.key.values.each do |plat| next unless INVALID_PLATFORMS.key?(plat.value) add_offense(plat, message: MSG, severity: :refactor) end elsif INVALID_PLATFORMS.key?(p_hash.key.value) add_offense(p_hash.key, message: MSG, severity: :refactor) end end end end