Class: RuboCop::Cop::Chef::Correctness::InvalidPlatformValueForPlatformHelper
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Chef::Correctness::InvalidPlatformValueForPlatformHelper
- Includes:
- RuboCop::Chef::PlatformHelpers
- Defined in:
- lib/rubocop/cop/chef/correctness/invalid_value_for_platform_helper.rb
Overview
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.
Constant Summary collapse
- MSG =
'Pass valid platforms to the value_for_platform helper.'
- RESTRICT_ON_SEND =
[:value_for_platform].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
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# 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, severity: :refactor) end elsif INVALID_PLATFORMS.key?(p_hash.key.value) add_offense(p_hash.key, severity: :refactor) end end end end |