Skip to content

chazzly/cars_foodcritic_rules

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

#Cars Custom foodcritic rules

Contained herein are custom foodcritic rules I have written for use on our cookbook at cars.com. We also use several comminity rules.

CARS001 - Remote file resource called without sanity check

This searches remote_file resources and checks to see if they contain either only_if or not_if guards.

While the content of the guard is not examined, the intent is that this guard should perform some generic check to ensure the file being downloaded is valid. This would typically involve some form of content check to avoid replacing a nessesary config file with an unintended file (such as an error page recieved from a http call).

remote_file '/etc/sudoers' do
  source 'https://github.com/nobody/example-sudoers.txt?raw'
  action :create
  only_if "curl -sl https://github.com/nobody/example-sudoers.txt?raw|grep -iE '\# Generated by Chef'"
end

CARS002 - Missing CHANGELOG entry for current version

A companion to CINK001, this pulls the cookbook version from metadata.rb and searches for an entry in CHANGELOG.md which matches it. While not perfect as it passes on any string that matches the version string, it does help ensure this "incredibly important" document is updated with the current changes.

CARS003 - OS Support not specified

This simply checks that a supports entry is made in metadata.rb. The idea being that in an environment of multiple platforms it is helpful to know which coookbooks have been designed for and tested with which platforms.

CARS004 - Invalid data bag JSON

This is stolen entirely from john-karp and his pending pull request Foodcritic/foodcritic#270

CARS005 - Metadata depends does specify version constraint

Checks that each 'depends' entry in metadata.rb includes a version constraint. NOTE: this does NOT check that it is a VALID constraint, simply that it exists.

CARS006 - Removing this in favor of FC061 & FC062 which cover this more cleanly.

CARS007 - file mode not specified as string.

Checks the the mode property on file resources (templates, cookbook,remote, etc) is specified as a string, not a number. Numbers with a leading zero are interperated by ruby as an ocatal, which gives a different result than a number without a leading zero (interprated as an integer). Ensuring they are specified as a string avoids this confusion and ensure Chef interprates the mode as expected.

About

Foodcritic rules I've written for use with Chef & foodcritic

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages