Class: RuboCop::Cop::Chef::Sharing::IncludeResourceExamples

Inherits:
Base
  • Object
show all
Extended by:
TargetChefVersion
Includes:
RangeHelp
Defined in:
lib/rubocop/cop/chef/sharing/include_resource_examples.rb

Overview

Resources should include examples field to allow automated documentation. Requires Chef Infra Client 13.9 or later.

Examples:


### correct
examples <<~DOC
  **Specify a global domain value**

  ```ruby
  macos_userdefaults 'full keyboard access to all controls' do
    key 'AppleKeyboardUIMode'
    value '2'
  end
  ```
DOC

Constant Summary collapse

MSG =
'Resources should include examples field to allow automated documentation. Requires Chef Infra Client 13.9 or later.'

Instance Method Summary collapse

Methods included from TargetChefVersion

minimum_target_chef_version, required_minimum_chef_version, support_target_chef_version?

Methods inherited from Base

#target_chef_version

Instance Method Details

#on_new_investigationObject



46
47
48
49
50
51
52
53
# File 'lib/rubocop/cop/chef/sharing/include_resource_examples.rb', line 46

def on_new_investigation
  return if processed_source.blank? || resource_examples(processed_source.ast).any?

  # Using range similar to RuboCop::Cop::Naming::Filename (file_name.rb)
  range = source_range(processed_source.buffer, 1, 0)

  add_offense(range, severity: :refactor)
end