📅  最后修改于: 2020-11-02 03:22:25             🧑  作者: Mango
毫无问题地编写好的食谱是一项艰巨的任务。但是,有些方法可以帮助您确定陷阱。可以在Chef Cookbook中进行标记。食品评论家是将其存档的最佳方法之一,它试图识别食谱的逻辑和样式可能存在的问题。
步骤1-添加Foodcritic宝石。
vipin@laptop:~/chef-repo $ subl Gemfile
source 'https://rubygems.org'
gem 'foodcritic', '~>2.2.0'
步骤2-安装宝石。
vipin@laptop:~/chef-repo $ bundle install
Fetching gem metadata from https://rubygems.org/
...TRUNCATED OUTPUT...
Installing foodcritic (2.2.0)
步骤1-在食谱上运行Foodcritic。
vipin@laptop:~/chef-repo $ foodcritic ./cookbooks/
FC002: Avoid string interpolation where not required: ./cookbooks/
mysql/attributes/server.rb:220
...TRUNCATED OUTPUT...
FC024: Consider adding platform equivalents: ./cookbooks//
recipes/server.rb:132
步骤2-生成详细的报告。
vipin@laptop:~/chef-repo $ foodcritic -C ./cookbooks/mysql
cookbooks//attributes/server.rb
FC002: Avoid string interpolation where not required
[...]
85| default['']['conf_dir'] = "#{mysql['basedir']}"
[...]
cookbooks//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|
Foodcritic定义了一组规则并检查配方代理,每个规则都有。它带有涉及多个领域的多个规则:样式,连接性,属性,字符串,概率,搜索,服务,文件,元数据等。