1.

What is Cookstyle in Chef?

Answer»

Cookstyle is an in-built  linting tool that checks for 

  • Best practices and style conventions
  • Source code uniformity
  • Metrics like in “line length” and FUNCTIONAL size

Cookstyle is based on RuboCop Ruby linting tool.

Cookstyle is run from the command line against a cookbook and verifies all the Ruby files in the cookbook. Cookstyle is run as cookstyle <cookbook path> and the output is PROVIDED via STANDARD output on the terminal.

The output gives us information about the number of files present and verified, defects detected and place of defects. The result of the verification of the files is shown below:

  • . - No issues found in the file
  • C - Convention issue in the file
  • W - Warning issue in the file
  • F - Fatal error in the file
  • E - Error in the file 

Autocorrection facility is available for files with cookstyle warnings but care must be taken not to alter the functionality of the code after using auto-correction. Default SETTINGS in the cookstyle could be overridden by .rubocop.yml file in a cookbook.



Discussion

No Comment Found