class RuboCop::Cop::Chef::Correctness::PropertyWithoutType

Resource properties or attributes should always define a type to help users understand the correct allowed values.

@example

#### incorrect
property :size, regex: /^\d+[KMGTP]$/
attribute :size, regex: /^\d+[KMGTP]$/

#### correct
property :size, String, regex: /^\d+[KMGTP]$/
attribute :size, kind_of: String, regex: /^\d+[KMGTP]$/

Constants

MSG
RESTRICT_ON_SEND

Public Instance Methods

on_send(node) click to toggle source
# File lib/rubocop/cop/chef/correctness/property_without_type.rb, line 48
def on_send(node)
  property_without_type?(node) do |hash_vals|
    return if hash_vals&.first&.keys&.include?(s(:sym, :kind_of))

    add_offense(node, severity: :refactor)
  end
end