class RuboCop::Cop::Chef::Style::IncludeRecipeWithParentheses

There is no need to wrap the recipe in parentheses when using the include_recipe helper.

@example

#### incorrect
include_recipe('foo::bar')

#### correct
include_recipe 'foo::bar'

Constants

MSG
RESTRICT_ON_SEND

Public Instance Methods

on_send(node) click to toggle source
# File lib/rubocop/cop/chef/style/include_recipe_with_parentheses.rb, line 42
def on_send(node)
  include_recipe?(node) do |recipe|
    return unless node.parenthesized?

    # avoid chefspec: expect(chef_run).to include_recipe('foo')
    return if node.parent&.send_type?

    add_offense(node, message: MSG, severity: :refactor) do |corrector|
      corrector.replace(node, "include_recipe #{recipe.source}")
    end
  end
end