chef / cookstyle

A linting tool that helps you to write better Chef Infra cookbooks and InSpec profiles by detecting and automatically correcting style, syntax, and logic mistakes in your code.
Apache License 2.0
107 stars 54 forks source link

Chef/Modernize/CronDFileOrTemplate fails to match when the path property is used to provide the file path #943

Closed yacn closed 2 years ago

yacn commented 2 years ago

Version:

7.31.3

Environment:

Scenario:

cookstyle should flag when a file, cookbook_file, or template is used to manage a file in '/etc/cron.d when the file path is provided to the resource via the path property.

Steps to Reproduce:

file 'delete old cron job' do
  path '/etc/cron.d/backup'
  action :delete
end

Expected Result:

cookstyle should flag the above resource to be replaced with cron_d.

❯ ../bundlebin/cookstyle --only Chef/Modernize/CronDFileOrTemplate
Inspecting 2 files
.R

Offenses:

recipes/tst.rb:1:1: R: Chef/Modernize/CronDFileOrTemplate: Use the cron_d resource that ships with Chef Infra Client 14.4+ instead of manually creating the file with template, file, or cookbook_file resources (https://docs.chef.io/workstation/cookstyle/chef_modernize_crondfileortemplate)
file 'delete old job' do ...

Actual Result:

No linting offenses raised

❯ cinc exec cookstyle .
Inspecting 2 files
..

2 files inspected, no offenses detected