Chef - Foodcritic

Scrivere buoni libri di cucina senza problemi è un compito abbastanza difficile. Ma ci sono modi che possono aiutare a identificare le insidie. È possibile contrassegnare in Chef Cookbook. Foodcritic è uno dei modi migliori per archiviarlo, che cerca di identificare possibili problemi con la logica e lo stile dei libri di cucina.

Configurazione Foodcritic

Step 1 - Aggiungi gemma Foodcritic.

[email protected]:~/chef-repo $ subl Gemfile 
source 'https://rubygems.org' 
gem 'foodcritic', '~>2.2.0'

Step 2 - Installa la gemma.

[email protected]:~/chef-repo $ bundle install 
Fetching gem metadata from https://rubygems.org/ 
...TRUNCATED OUTPUT... 
Installing foodcritic (2.2.0)

Gemma critica per il cibo

Step 1 - Esegui Foodcritic sul ricettario.

[email protected]:~/chef-repo $ foodcritic ./cookbooks/<Cookbook Name> 
FC002: Avoid string interpolation where not required: ./cookbooks/ 
mysql/attributes/server.rb:220 
...TRUNCATED OUTPUT... 
FC024: Consider adding platform equivalents: ./cookbooks/<Cookbook Name>/ 
recipes/server.rb:132

Step 2 - Genera un rapporto dettagliato.

[email protected]:~/chef-repo $ foodcritic -C ./cookbooks/mysql 
cookbooks/<cookbook Name>/attributes/server.rb 
FC002: Avoid string interpolation where not required 
[...] 
85| default['<Cookbook Name>']['conf_dir'] = "#{mysql['basedir']}" 
[...] 
cookbooks/<Cookbook Name>/recipes/client.rb 
FC007: Ensure recipe dependencies are reflected in cookbook 
metadata 
40| end 
41|when "mac_os_x" 
42| include_recipe 'homebrew' 
43|end 
44|

Metodo di lavoro

Foodcritic definisce un insieme di regole e controlla gli agenti delle ricette, ciascuno di essi. Viene fornito con più regole riguardanti varie aree: stili, connessione, attributi, stringa, probabilità, ricerca, servizi, file, metadati e così via.