foodcritic 15.0.0 → 15.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (233) hide show
  1. checksums.yaml +4 -4
  2. data/chef_dsl_metadata/{chef_14.7.17.json → chef_14.8.12.json} +61 -1
  3. data/foodcritic.gemspec +1 -3
  4. data/lib/foodcritic/linter.rb +1 -1
  5. data/lib/foodcritic/version.rb +1 -1
  6. metadata +5 -232
  7. data/Rakefile +0 -73
  8. data/features/002_check_string_interpolation.feature +0 -50
  9. data/features/005_check_for_resource_repetition.feature +0 -64
  10. data/features/006_check_file_mode.feature +0 -36
  11. data/features/009_check_for_unrecognised_resource_attributes.feature +0 -55
  12. data/features/014_check_for_long_ruby_blocks.feature +0 -30
  13. data/features/018_check_for_old_lwrp_notification_syntax.feature +0 -25
  14. data/features/019_check_for_consistent_node_access.feature +0 -108
  15. data/features/021_check_for_dodgy_lwrp_conditions.feature +0 -28
  16. data/features/022_check_for_dodgy_conditions_within_loop.feature +0 -43
  17. data/features/024_check_for_missing_platforms.feature +0 -43
  18. data/features/027_check_for_internal_attribute_use.feature +0 -22
  19. data/features/030_check_for_debugger_breakpoints.feature +0 -25
  20. data/features/032_check_for_invalid_notification_timing.feature +0 -24
  21. data/features/033_check_for_missing_template.feature +0 -39
  22. data/features/034_check_for_unused_template_variables.feature +0 -80
  23. data/features/037_check_for_invalid_notification_action.feature +0 -34
  24. data/features/038_check_for_invalid_action.feature +0 -39
  25. data/features/039_check_for_key_access_to_node_methods.feature +0 -33
  26. data/features/044_check_for_bare_attribute_keys.feature +0 -53
  27. data/features/046_check_for_assign_unless_nil_attributes.feature +0 -21
  28. data/features/047_check_for_attribute_assignment_without_precedence.feature +0 -49
  29. data/features/051_check_for_template_partial_loops.feature +0 -40
  30. data/features/build_framework_support.feature +0 -109
  31. data/features/checking_all_types_of_file.feature +0 -40
  32. data/features/choose_rules_to_apply.feature +0 -47
  33. data/features/command_line_help.feature +0 -58
  34. data/features/continuous_integration_support.feature +0 -33
  35. data/features/exclude_paths_to_lint.feature +0 -12
  36. data/features/ignore_via_line_comments.feature +0 -69
  37. data/features/include_custom_rules.feature +0 -29
  38. data/features/individual_file.feature +0 -28
  39. data/features/limit_rules_to_specific_versions.feature +0 -65
  40. data/features/multiple_paths.feature +0 -35
  41. data/features/show_lines_matched.feature +0 -20
  42. data/features/sort_warnings.feature +0 -10
  43. data/features/specify_search_grammar.feature +0 -25
  44. data/features/step_definitions/cookbook_steps.rb +0 -1826
  45. data/features/support/command_helpers.rb +0 -418
  46. data/features/support/cookbook_helpers.rb +0 -599
  47. data/features/support/env.rb +0 -19
  48. data/man/foodcritic.1.ronn +0 -76
  49. data/spec/functional/fc001_spec.rb +0 -72
  50. data/spec/functional/fc004_spec.rb +0 -84
  51. data/spec/functional/fc007_spec.rb +0 -127
  52. data/spec/functional/fc008_spec.rb +0 -33
  53. data/spec/functional/fc009_spec.rb +0 -37
  54. data/spec/functional/fc010_spec.rb +0 -32
  55. data/spec/functional/fc011_spec.rb +0 -20
  56. data/spec/functional/fc013_spec.rb +0 -39
  57. data/spec/functional/fc015_spec.rb +0 -19
  58. data/spec/functional/fc016_spec.rb +0 -57
  59. data/spec/functional/fc025_spec.rb +0 -60
  60. data/spec/functional/fc026_spec.rb +0 -66
  61. data/spec/functional/fc028_spec.rb +0 -93
  62. data/spec/functional/fc029_spec.rb +0 -33
  63. data/spec/functional/fc031_spec.rb +0 -14
  64. data/spec/functional/fc037_spec.rb +0 -75
  65. data/spec/functional/fc038_spec.rb +0 -28
  66. data/spec/functional/fc040_spec.rb +0 -156
  67. data/spec/functional/fc041_spec.rb +0 -121
  68. data/spec/functional/fc042_spec.rb +0 -13
  69. data/spec/functional/fc043_spec.rb +0 -28
  70. data/spec/functional/fc045_spec.rb +0 -18
  71. data/spec/functional/fc048_spec.rb +0 -67
  72. data/spec/functional/fc049_spec.rb +0 -56
  73. data/spec/functional/fc050_spec.rb +0 -85
  74. data/spec/functional/fc052_spec.rb +0 -13
  75. data/spec/functional/fc053_spec.rb +0 -13
  76. data/spec/functional/fc055_spec.rb +0 -18
  77. data/spec/functional/fc056_spec.rb +0 -18
  78. data/spec/functional/fc058_spec.rb +0 -102
  79. data/spec/functional/fc060_spec.rb +0 -45
  80. data/spec/functional/fc061_spec.rb +0 -48
  81. data/spec/functional/fc062_spec.rb +0 -13
  82. data/spec/functional/fc063_spec.rb +0 -18
  83. data/spec/functional/fc064_spec.rb +0 -13
  84. data/spec/functional/fc065_spec.rb +0 -13
  85. data/spec/functional/fc066_spec.rb +0 -33
  86. data/spec/functional/fc067_spec.rb +0 -13
  87. data/spec/functional/fc068_spec.rb +0 -13
  88. data/spec/functional/fc069_spec.rb +0 -38
  89. data/spec/functional/fc070_spec.rb +0 -65
  90. data/spec/functional/fc071_spec.rb +0 -36
  91. data/spec/functional/fc072_spec.rb +0 -13
  92. data/spec/functional/fc073_spec.rb +0 -56
  93. data/spec/functional/fc074_spec.rb +0 -39
  94. data/spec/functional/fc075_spec.rb +0 -41
  95. data/spec/functional/fc076_spec.rb +0 -13
  96. data/spec/functional/fc077_spec.rb +0 -13
  97. data/spec/functional/fc078_spec.rb +0 -35
  98. data/spec/functional/fc079_spec.rb +0 -21
  99. data/spec/functional/fc080_spec.rb +0 -68
  100. data/spec/functional/fc081_spec.rb +0 -25
  101. data/spec/functional/fc082_spec.rb +0 -23
  102. data/spec/functional/fc083_spec.rb +0 -34
  103. data/spec/functional/fc084_spec.rb +0 -49
  104. data/spec/functional/fc085_spec.rb +0 -77
  105. data/spec/functional/fc086_spec.rb +0 -45
  106. data/spec/functional/fc087_spec.rb +0 -43
  107. data/spec/functional/fc088_spec.rb +0 -18
  108. data/spec/functional/fc089_spec.rb +0 -23
  109. data/spec/functional/fc091_spec.rb +0 -38
  110. data/spec/functional/fc092_spec.rb +0 -31
  111. data/spec/functional/fc093_spec.rb +0 -27
  112. data/spec/functional/fc094_spec.rb +0 -18
  113. data/spec/functional/fc095_spec.rb +0 -18
  114. data/spec/functional/fc096_spec.rb +0 -18
  115. data/spec/functional/fc097_spec.rb +0 -18
  116. data/spec/functional/fc098_spec.rb +0 -18
  117. data/spec/functional/fc099_spec.rb +0 -18
  118. data/spec/functional/fc100_spec.rb +0 -18
  119. data/spec/functional/fc101_spec.rb +0 -23
  120. data/spec/functional/fc102_spec.rb +0 -18
  121. data/spec/functional/fc103_spec.rb +0 -30
  122. data/spec/functional/fc104_spec.rb +0 -54
  123. data/spec/functional/fc105_spec.rb +0 -36
  124. data/spec/functional/fc106_spec.rb +0 -21
  125. data/spec/functional/fc107_spec.rb +0 -22
  126. data/spec/functional/fc108_spec.rb +0 -43
  127. data/spec/functional/fc109_spec.rb +0 -22
  128. data/spec/functional/fc110_spec.rb +0 -21
  129. data/spec/functional/fc111_spec.rb +0 -17
  130. data/spec/functional/fc112_spec.rb +0 -17
  131. data/spec/functional/fc113_spec.rb +0 -98
  132. data/spec/functional/fc114_spec.rb +0 -31
  133. data/spec/functional/fc115_spec.rb +0 -24
  134. data/spec/functional/fc116_spec.rb +0 -18
  135. data/spec/functional/fc117_spec.rb +0 -23
  136. data/spec/functional/fc118_spec.rb +0 -17
  137. data/spec/functional/fc119_spec.rb +0 -27
  138. data/spec/functional/fc120_spec.rb +0 -21
  139. data/spec/functional/fc121_spec.rb +0 -45
  140. data/spec/functional/fc122_spec.rb +0 -18
  141. data/spec/functional/root_aliases_spec.rb +0 -13
  142. data/spec/regression/cookbooks.txt +0 -83
  143. data/spec/regression/expected/activemq.txt +0 -6
  144. data/spec/regression/expected/aix.txt +0 -27
  145. data/spec/regression/expected/apparmor.txt +0 -9
  146. data/spec/regression/expected/apt.txt +0 -14
  147. data/spec/regression/expected/ark.txt +0 -3
  148. data/spec/regression/expected/auditd.txt +0 -2
  149. data/spec/regression/expected/aws.txt +0 -16
  150. data/spec/regression/expected/bluepill.txt +0 -12
  151. data/spec/regression/expected/boost.txt +0 -8
  152. data/spec/regression/expected/build-essential.txt +0 -8
  153. data/spec/regression/expected/chef-client.txt +0 -17
  154. data/spec/regression/expected/chef-ingredient.txt +0 -6
  155. data/spec/regression/expected/chef-server.txt +0 -13
  156. data/spec/regression/expected/chef-vault.txt +0 -7
  157. data/spec/regression/expected/chef.txt +0 -104
  158. data/spec/regression/expected/chef_client_updater.txt +0 -2
  159. data/spec/regression/expected/chef_handler.txt +0 -7
  160. data/spec/regression/expected/chef_hostname.txt +0 -3
  161. data/spec/regression/expected/chef_nginx.txt +0 -4
  162. data/spec/regression/expected/cron.txt +0 -7
  163. data/spec/regression/expected/database.txt +0 -42
  164. data/spec/regression/expected/dmg.txt +0 -11
  165. data/spec/regression/expected/docker.txt +0 -4
  166. data/spec/regression/expected/drbd.txt +0 -29
  167. data/spec/regression/expected/dynect.txt +0 -33
  168. data/spec/regression/expected/erlang.txt +0 -6
  169. data/spec/regression/expected/fail2ban.txt +0 -5
  170. data/spec/regression/expected/firewall.txt +0 -11
  171. data/spec/regression/expected/gecode.txt +0 -10
  172. data/spec/regression/expected/gems.txt +0 -32
  173. data/spec/regression/expected/gunicorn.txt +0 -11
  174. data/spec/regression/expected/heartbeat.txt +0 -8
  175. data/spec/regression/expected/homebrew.txt +0 -7
  176. data/spec/regression/expected/iis.txt +0 -22
  177. data/spec/regression/expected/iptables.txt +0 -9
  178. data/spec/regression/expected/jetty.txt +0 -13
  179. data/spec/regression/expected/jpackage.txt +0 -9
  180. data/spec/regression/expected/keepalived.txt +0 -3
  181. data/spec/regression/expected/kickstart.txt +0 -15
  182. data/spec/regression/expected/libarchive.txt +0 -6
  183. data/spec/regression/expected/logwatch.txt +0 -5
  184. data/spec/regression/expected/lvm.txt +0 -14
  185. data/spec/regression/expected/maradns.txt +0 -14
  186. data/spec/regression/expected/maven.txt +0 -8
  187. data/spec/regression/expected/memcached.txt +0 -31
  188. data/spec/regression/expected/motd-tail.txt +0 -5
  189. data/spec/regression/expected/mysql.txt +0 -19
  190. data/spec/regression/expected/ohai.txt +0 -9
  191. data/spec/regression/expected/openldap.txt +0 -12
  192. data/spec/regression/expected/openssh.txt +0 -6
  193. data/spec/regression/expected/openssl.txt +0 -6
  194. data/spec/regression/expected/partial_search.txt +0 -7
  195. data/spec/regression/expected/passenger_apache2.txt +0 -31
  196. data/spec/regression/expected/perl.txt +0 -14
  197. data/spec/regression/expected/php.txt +0 -6
  198. data/spec/regression/expected/postfix.txt +0 -8
  199. data/spec/regression/expected/powershell.txt +0 -8
  200. data/spec/regression/expected/resolver.txt +0 -7
  201. data/spec/regression/expected/rsync.txt +0 -9
  202. data/spec/regression/expected/rsyslog.txt +0 -11
  203. data/spec/regression/expected/runit.txt +0 -4
  204. data/spec/regression/expected/smokeping.txt +0 -6
  205. data/spec/regression/expected/sql_server.txt +0 -7
  206. data/spec/regression/expected/ssh_known_hosts.txt +0 -6
  207. data/spec/regression/expected/stompserver.txt +0 -6
  208. data/spec/regression/expected/subversion.txt +0 -6
  209. data/spec/regression/expected/sudo.txt +0 -10
  210. data/spec/regression/expected/tar.txt +0 -10
  211. data/spec/regression/expected/tftp.txt +0 -6
  212. data/spec/regression/expected/tomcat.txt +0 -18
  213. data/spec/regression/expected/transmission.txt +0 -13
  214. data/spec/regression/expected/ubuntu.txt +0 -5
  215. data/spec/regression/expected/ufw.txt +0 -12
  216. data/spec/regression/expected/unicorn.txt +0 -7
  217. data/spec/regression/expected/users.txt +0 -12
  218. data/spec/regression/expected/vcruntime.txt +0 -8
  219. data/spec/regression/expected/vim.txt +0 -7
  220. data/spec/regression/expected/webpi.txt +0 -7
  221. data/spec/regression/expected/whitelist-node-attrs.txt +0 -7
  222. data/spec/regression/expected/windows.txt +0 -35
  223. data/spec/regression/expected/wix.txt +0 -5
  224. data/spec/regression/expected/xml.txt +0 -7
  225. data/spec/regression/expected/yum.txt +0 -15
  226. data/spec/regression/regression_spec.rb +0 -23
  227. data/spec/spec_helper.rb +0 -132
  228. data/spec/unit/api_spec.rb +0 -1939
  229. data/spec/unit/chef_spec.rb +0 -66
  230. data/spec/unit/command_line_spec.rb +0 -136
  231. data/spec/unit/domain_spec.rb +0 -78
  232. data/spec/unit/linter_spec.rb +0 -107
  233. data/spec/unit/template_spec.rb +0 -53
@@ -1,19 +0,0 @@
1
- begin
2
- require "simplecov"
3
- SimpleCov.start do
4
- add_filter "/features/"
5
- end
6
- rescue LoadError
7
- warn "warning: simplecov gem not found; skipping coverage"
8
- end
9
-
10
- require "aruba/cucumber"
11
- require "foodcritic"
12
-
13
- require "minitest/spec"
14
-
15
- MiniTest::Spec.new(nil)
16
-
17
- Before do
18
- @aruba_timeout_seconds = 300
19
- end
@@ -1,76 +0,0 @@
1
- foodcritic(1) -- lint tool for chef cookbooks
2
- =============================================
3
-
4
- ## SYNOPSIS
5
-
6
- `foodcritic` [<options>...] <cookbook>...
7
-
8
- `foodcritic` [<options>...] --list
9
-
10
-
11
- ## DESCRIPTION
12
-
13
- `foodcritic` makes it easier to flag problems in your Chef cookbooks that will
14
- cause Chef to blow up when you attempt to converge.
15
- This is about faster feedback.
16
-
17
- Each `cookbook` path specified will be examined for common problems and
18
- poor style.
19
-
20
-
21
- ## OPTIONS
22
-
23
- * `-t`, `--tags` <TAGS>:
24
- Only check against rules with the specified tags. Prefix
25
- tags with a tilde `~` to exclude rules.
26
-
27
- * `-l`, `--list`:
28
- Do not perform a lint check; instead simply list the
29
- rules that would be enabled based on the defaults and
30
- the rule selection options (-t, -I)
31
-
32
- * `-f`, `--epic-fail` <TAGS>:
33
- Exit non-zero if any of the specified tags are matched.
34
- Use the pseudo-tag `any` to fail if any tag is matched.
35
-
36
- * `-c`, `--chef-version` <VERSION>:
37
- Only check against rules valid for this version of Chef.
38
-
39
- * `-B`, `--cookbook-path`:
40
- Cookbook path(s) to check.
41
-
42
- * `-C`, `--`[`no-`]`context`:
43
- Show lines matched against rather than the default summary.
44
-
45
- * `-E`, `--environment-path`:
46
- Environment path(s) to check.
47
-
48
- * `-I`, `--include` <PATH>:
49
- Additional rule file path(s) to load.
50
-
51
- * `-R`, `--role-path`:
52
- Role path(s) to check.
53
-
54
- * `-S`, `--search-grammar` <PATH>:
55
- Specify grammar to use when validating search syntax.
56
- (Default: the grammar of any installed Chef)
57
-
58
- * `-V`, `--version`:
59
- Display the foodcritic version.
60
-
61
- * `-X`, `--exclude` <PATH>:
62
- Exclude path(s) from being linted.
63
-
64
- ## RETURN VALUES
65
-
66
- By default, `foodcritic` will always return `0`.
67
-
68
- If `--epic-fail` is specified, then `foodcritic` will return `3` if any tags are matched.
69
-
70
- ## COPYRIGHT
71
-
72
- `foodcritic` is Copyright 2011 by Andrew Crump.
73
-
74
- ## SEE ALSO
75
-
76
- chef(1)
@@ -1,72 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "FC001" do
4
- context "with a cookbook with a single recipe that reads node attributes via symbols" do
5
- recipe_file "log node[:foo]\n"
6
- it { is_expected.to violate_rule("FC001") }
7
- end
8
-
9
- context "with a cookbook with a single recipe that references the node run_state" do
10
- recipe_file "node.run_state[:foo]\n"
11
- it { is_expected.not_to violate_rule("FC001") }
12
- end
13
-
14
- context "with a cookbook with a single recipe that accesses multiple node attributes via symbols" do
15
- recipe_file "node[:foo] = 'bar'\nnode[:testing] = 'bar'\n"
16
- it { is_expected.to violate_rule("FC001") }
17
- end
18
-
19
- context "with a cookbook with a single recipe that assigns node attributes accessed via symbols to a local variable" do
20
- recipe_file "baz = node[:foo]\n"
21
- it { is_expected.to violate_rule("FC001") }
22
- end
23
-
24
- context "with a cookbook with a single recipe that accesses nested node attributes via symbols" do
25
- recipe_file "node[:foo][:foo2] = 'bar'\n"
26
- it { is_expected.to violate_rule("FC001") }
27
- end
28
-
29
- context "with a cookbook with a single recipe that reads node attributes via strings" do
30
- recipe_file "log node['foo']\n"
31
- it { is_expected.to_not violate_rule("FC001") }
32
- end
33
-
34
- context "with a cookbook with a single recipe that searches based on a node attribute accessed via strings" do
35
- recipe_file %Q{remote = search(:node, "name:\#{node['drbd']['remote_host']}")[0]\n}
36
- it { is_expected.to_not violate_rule("FC001") }
37
- end
38
-
39
- context "with a cookbook with a single recipe that passes node attributes accessed via symbols to a template" do
40
- recipe_file <<-EOH
41
- template "/etc/foo" do
42
- source "foo.erb"
43
- variables({
44
- :port => node[:foo][:port],
45
- :user => node[:foo][:user]
46
- })
47
- end
48
- EOH
49
- it { is_expected.to violate_rule("FC001").in("recipes/default.rb:4") }
50
- it { is_expected.to violate_rule("FC001").in("recipes/default.rb:5") }
51
- end
52
-
53
- context "with a cookbook that declares default attributes via symbols" do
54
- attributes_file "default[:apache][:dir] = '/etc/apache2'\n"
55
- it { is_expected.to violate_rule("FC001") }
56
- end
57
-
58
- context "with a cookbook that declares override attributes via symbols" do
59
- attributes_file "override[:apache][:dir] = '/etc/apache2'\n"
60
- it { is_expected.to violate_rule("FC001") }
61
- end
62
-
63
- context "with a cookbook that declares set attributes via symbols" do
64
- attributes_file "set[:apache][:dir] = '/etc/apache2'\n"
65
- it { is_expected.to violate_rule("FC001") }
66
- end
67
-
68
- context "with a cookbook that declares normal attributes via symbols" do
69
- attributes_file "normal[:apache][:dir] = '/etc/apache2'\n"
70
- it { is_expected.to violate_rule("FC001") }
71
- end
72
- end
@@ -1,84 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "FC004" do
4
- context "using a execute to run a service init script" do
5
- recipe_file <<-EOH
6
- execute 'service stuff' do
7
- command '/etc/init.d/foo start'
8
- action :run
9
- end
10
- EOH
11
- it { is_expected.to violate_rule }
12
- end
13
-
14
- context "using a execute to run a invoke-rc.d" do
15
- recipe_file <<-EOH
16
- execute 'service stuff' do
17
- command 'invoke-rc.d foo restart'
18
- action :run
19
- end
20
- EOH
21
- it { is_expected.to violate_rule }
22
- end
23
-
24
- %w{reload start stop restart}.each do |command|
25
- context "using a execute to run an upstart #{command} command" do
26
- recipe_file <<-EOH
27
- execute 'service stuff' do
28
- command "#{command} foo"
29
- action :run
30
- end
31
- EOH
32
- it { is_expected.to violate_rule }
33
- end
34
-
35
- context "using a execute to run the upstart service command to #{command}" do
36
- recipe_file <<-EOH
37
- execute 'service stuff' do
38
- command "service foo #{command}"
39
- action :run
40
- end
41
- EOH
42
- it { is_expected.to violate_rule }
43
- end
44
-
45
- context "using a execute to run systemcl to #{command}" do
46
- recipe_file <<-EOH
47
- execute 'service stuff' do
48
- command "systemctl #{command} foo"
49
- action :run
50
- end
51
- EOH
52
- it { is_expected.to violate_rule }
53
- end
54
- end
55
-
56
- context "using a execute to run a windows start command" do
57
- recipe_file <<-EOH
58
- execute 'Run setup' do
59
- command 'start /wait my_setup.exe --silent'
60
- end
61
- EOH
62
- it { is_expected.not_to violate_rule }
63
- end
64
-
65
- context "using a execute to run systemctl daemon-reload" do
66
- recipe_file <<-EOH
67
- execute 'Run setup' do
68
- command 'systemctl daemon-reload'
69
- end
70
- EOH
71
- it { is_expected.not_to violate_rule }
72
- end
73
-
74
- context "using a execute to run check the contents of an init script" do
75
- recipe_file <<-EOH
76
- execute "Configure the scheduler" do
77
- user "root"
78
- command 'sed -i "s/\([^/]\)ondemand/\1performace/g" /etc/init.d/ondemand'
79
- notifies :start, "service[ondemand]"
80
- end
81
- EOH
82
- it { is_expected.not_to violate_rule }
83
- end
84
- end
@@ -1,127 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "FC007" do
4
- metadata_file "name 'test'\ndepends 'dep'"
5
- context "with an undeclared dependency" do
6
- recipe_file 'include_recipe "foo"'
7
-
8
- it { is_expected.to violate_rule }
9
-
10
- context "with parens" do
11
- recipe_file 'include_recipe("foo")'
12
- it { is_expected.to violate_rule }
13
- end
14
-
15
- context "with ::default" do
16
- recipe_file 'include_recipe "foo::default"'
17
- it { is_expected.to violate_rule }
18
- end
19
-
20
- context "with parens and ::default" do
21
- recipe_file 'include_recipe("foo::default")'
22
- it { is_expected.to violate_rule }
23
- end
24
-
25
- # context 'with a partial expression' do
26
- # recipe_file 'include_recipe "foo::#{something}"'
27
- # it { pending; is_expected.to violate_rule }
28
- # end
29
- end
30
-
31
- context "with a declared dependency" do
32
- recipe_file 'include_recipe "dep"'
33
-
34
- it { is_expected.to_not violate_rule }
35
-
36
- context "with parens" do
37
- recipe_file 'include_recipe("dep")'
38
- it { is_expected.to_not violate_rule }
39
- end
40
-
41
- context "with ::default" do
42
- recipe_file 'include_recipe "dep::default"'
43
- it { is_expected.to_not violate_rule }
44
- end
45
-
46
- context "with parens and ::default" do
47
- recipe_file 'include_recipe("dep::default")'
48
- it { is_expected.to_not violate_rule }
49
- end
50
-
51
- # context 'with a partial expression' do
52
- # recipe_file 'include_recipe "dep::#{something}"'
53
- # it { pending; is_expected.to_not violate_rule }
54
- # end
55
- end
56
- context "with an unknowable include_recipe" do
57
- context "with a node attribute" do
58
- recipe_file 'include_recipe node["foo"]'
59
- it { is_expected.to_not violate_rule }
60
- end
61
-
62
- context "with a variable" do
63
- recipe_file "include_recipe something"
64
- it { is_expected.to_not violate_rule }
65
- end
66
-
67
- context "with a string expression" do
68
- recipe_file 'include_recipe "#{something}"'
69
- it { is_expected.to_not violate_rule }
70
- end
71
-
72
- context "with a parial string expression" do
73
- recipe_file 'include_recipe "#{something}::default"'
74
- it { is_expected.to_not violate_rule }
75
- end
76
- end
77
-
78
- context "with an include from the same cookbook" do
79
- recipe_file 'include_recipe "test::other"'
80
- it { is_expected.to_not violate_rule }
81
-
82
- context "with the shorthand syntax" do
83
- recipe_file 'include_recipe "::other"'
84
- it { is_expected.to_not violate_rule }
85
- end
86
- end
87
-
88
- context "with multiple includes" do
89
- recipe_file "include_recipe 'test::other'\ninclude_recipe 'foo'"
90
- it { is_expected.to violate_rule.in("recipes/default.rb:2") }
91
- end
92
-
93
- context "with multiple dependencies" do
94
- shared_examples "multiple includes" do
95
- context "with declared includes" do
96
- recipe_file %Q{include_recipe 'one'\ninclude_recipe "two"\ninclude_recipe 'three::default'}
97
- it { is_expected.to_not violate_rule }
98
- end
99
-
100
- context "with undeclared includes" do
101
- recipe_file %Q{include_recipe 'one'\ninclude_recipe "other"\ninclude_recipe 'foo::default'}
102
- it { is_expected.to violate_rule.in("recipes/default.rb:2") }
103
- it { is_expected.to violate_rule.in("recipes/default.rb:2") }
104
- end
105
- end
106
-
107
- context "using multiple depends" do
108
- metadata_file "name 'test'\ndepends 'one'\ndepends 'two'\ndepends 'three'"
109
- it_behaves_like "multiple includes"
110
- end
111
-
112
- context "using a word array and a one-line block" do
113
- metadata_file "name 'test'\n%w{one two three}.each {|d| depends d }"
114
- it_behaves_like "multiple includes"
115
- end
116
-
117
- context "using a word array and a multi-line block" do
118
- metadata_file "name 'test'\n%w{one two three}.each do |d|\n depends d\nend"
119
- it_behaves_like "multiple includes"
120
- end
121
-
122
- context "using a non-standard word array" do
123
- metadata_file "name 'test'\n%w|one two three|.each {|d| depends d }"
124
- it_behaves_like "multiple includes"
125
- end
126
- end
127
- end
@@ -1,33 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "FC008" do
4
- context "with a cookbook with a metadata file containing boilerplate maintainer from knife CLI" do
5
- metadata_file "maintainer 'YOUR_COMPANY_NAME'"
6
- it { is_expected.to violate_rule }
7
- end
8
-
9
- context "with a cookbook with a metadata file containing boilerplate maintainer from chef CLI" do
10
- metadata_file "maintainer 'The Authors'"
11
- it { is_expected.to violate_rule }
12
- end
13
-
14
- context "with a cookbook with a metadata file containing boilerplate maintainer_email from knife CLI" do
15
- metadata_file "maintainer_email 'YOUR_EMAIL'"
16
- it { is_expected.to violate_rule }
17
- end
18
-
19
- context "with a cookbook with a metadata file containing boilerplate maintainer_email from chef CLI" do
20
- metadata_file "maintainer_email 'you@example.com'"
21
- it { is_expected.to violate_rule }
22
- end
23
-
24
- context "with a cookbook with a metadata file containing non-boilerplate maintainer and maintainer_email" do
25
- metadata_file "maintainer 'John Smith'\nmaintainer_email 'john@smith.com'"
26
- it { is_expected.not_to violate_rule }
27
- end
28
-
29
- context "with a cookbook with a metadata file not containing maintainer or maintainer_email" do
30
- metadata_file
31
- it { is_expected.not_to violate_rule }
32
- end
33
- end
@@ -1,37 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "FC009" do
4
- context "on chef 14.2.0 with a cookbook that uses ifconfig attributes introduced in 14.0" do
5
- foodcritic_command("--chef-version", "14.2.0", "--no-progress", ".")
6
- recipe_file <<-EOH
7
- ifconfig 'foo' do
8
- family 'inet'
9
- end
10
- EOH
11
- it { is_expected.not_to violate_rule }
12
- end
13
-
14
- context "on chef 13.12.3 with a cookbook that uses ifconfig attributes introduced in 14.0" do
15
- foodcritic_command("--chef-version", "13.12.3", "--no-progress", ".")
16
- recipe_file <<-EOH
17
- ifconfig 'foo' do
18
- family 'inet'
19
- end
20
- EOH
21
- it { is_expected.to violate_rule }
22
- end
23
-
24
- context "when the resource attribute is actually a raise" do
25
- recipe_file <<-EOH
26
- package package_name do
27
- provider case node["platform_family"]
28
- when "debian"; Chef::Provider::Package::Dpkg
29
- when "rhel"; Chef::Provider::Package::Rpm
30
- else
31
- raise RuntimeError("I don't know how to install chef-server packages for this platform family")
32
- end
33
- end
34
- EOH
35
- it { is_expected.not_to violate_rule }
36
- end
37
- end