Class: RuboCop::Cop::Chef::Correctness::InvalidPlatformValueForPlatformFamilyHelper
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Chef::Correctness::InvalidPlatformValueForPlatformFamilyHelper
- Includes:
- RuboCop::Chef::PlatformHelpers
- Defined in:
- lib/rubocop/cop/chef/correctness/invalid_value_for_platform_family_helper.rb
Overview
Pass valid platform families to the value_for_platform_family helper. See [Infra Language: Platform Family](docs.chef.io/infra_language/checking_platforms/#platform_family-values) for a complete list of platform families.
Constant Summary collapse
- MSG =
'Pass valid platform families to the value_for_platform_family helper.'
- RESTRICT_ON_SEND =
[:value_for_platform_family].freeze
Constants included from RuboCop::Chef::PlatformHelpers
RuboCop::Chef::PlatformHelpers::INVALID_PLATFORMS, RuboCop::Chef::PlatformHelpers::INVALID_PLATFORM_FAMILIES
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#on_send(node) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/rubocop/cop/chef/correctness/invalid_value_for_platform_family_helper.rb', line 52 def on_send(node) value_for_platform_family?(node) do |plats| plats.each do |p_hash| if p_hash.key.array_type? p_hash.key.values.each do |plat| next unless INVALID_PLATFORM_FAMILIES.key?(plat.value) add_offense(plat, severity: :refactor) end elsif INVALID_PLATFORM_FAMILIES.key?(p_hash.key.value) add_offense(p_hash.key, severity: :refactor) end end end end |