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
109 stars 54 forks source link

Chef/Modernize/CronDFileOrTemplate triggers on cron.daily #954

Closed ddamw closed 5 months ago

ddamw commented 2 years ago

Version:

Chef Workstation 22.2.807 Cookstyle 7.32.0

Environment:

Debian 11

Scenario:

We use a _cookbookfile resource to process a file in /etc/cron.daily

Steps to Reproduce:

Add the following resource to a cookbook recipe:

cookbook_file '/etc/cron.daily/locate' do
  source 'locate'
  owner 'root'
  group 'root'
  mode '755'
end

Then run cookstyle

Expected Result:

I expect no warning from this.

Actual Result:

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) cookbook_file '/etc/cron.daily/locate' do ... ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I am guessing that the cop is triggering on cron.d*, instead of just cron.d

https://github.com/chef/cookstyle/issues/946 seems to have a very similar issue

FYI: cron.daily is a directory where scripts can be dropped that run daily, cron.d is a directory where cron jobs with full cron configuration (i.e.: with time, user, etc) are placed.

dafyddcrosby commented 5 months ago

Confirmed bug fixed with https://github.com/chef/cookstyle/pull/959, but didn't have a regression test, so made one with https://github.com/chef/cookstyle/pull/972