foodcritic 13.1.1 → 14.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -0
  3. data/chef_dsl_metadata/chef_13.4.19.json +0 -212
  4. data/chef_dsl_metadata/chef_13.5.3.json +0 -212
  5. data/chef_dsl_metadata/chef_13.6.0.json +0 -212
  6. data/chef_dsl_metadata/chef_13.7.16.json +0 -212
  7. data/chef_dsl_metadata/{chef_13.3.42.json → chef_13.9.1.json} +189 -48
  8. data/chef_dsl_metadata/{chef_13.1.31.json → chef_14.1.12.json} +8735 -1444
  9. data/chef_dsl_metadata/{chef_13.0.113.json → chef_14.2.0.json} +8763 -1432
  10. data/features/continuous_integration_support.feature +0 -2
  11. data/features/step_definitions/cookbook_steps.rb +0 -26
  12. data/features/support/command_helpers.rb +0 -2
  13. data/lib/foodcritic/api.rb +6 -1
  14. data/lib/foodcritic/linter.rb +1 -1
  15. data/lib/foodcritic/rules/fc048.rb +1 -1
  16. data/lib/foodcritic/rules/fc069.rb +145 -115
  17. data/lib/foodcritic/rules/fc071.rb +1 -1
  18. data/lib/foodcritic/rules/fc078.rb +54 -48
  19. data/lib/foodcritic/rules/fc121.rb +6 -0
  20. data/lib/foodcritic/version.rb +1 -1
  21. data/spec/functional/fc009_spec.rb +6 -6
  22. data/spec/functional/fc040_spec.rb +156 -0
  23. data/spec/functional/fc041_spec.rb +121 -0
  24. data/spec/functional/fc048_spec.rb +67 -0
  25. data/spec/functional/fc121_spec.rb +43 -0
  26. data/spec/regression/expected/aix.txt +4 -0
  27. data/spec/regression/expected/apt.txt +1 -1
  28. data/spec/regression/expected/ark.txt +1 -0
  29. data/spec/regression/expected/boost.txt +1 -0
  30. data/spec/regression/expected/chef-client.txt +4 -4
  31. data/spec/regression/expected/chef-ingredient.txt +1 -0
  32. data/spec/regression/expected/chef_client_updater.txt +1 -0
  33. data/spec/regression/expected/chef_nginx.txt +2 -0
  34. data/spec/regression/expected/dmg.txt +3 -3
  35. data/spec/regression/expected/docker.txt +1 -0
  36. data/spec/regression/expected/erlang.txt +1 -0
  37. data/spec/regression/expected/gecode.txt +2 -0
  38. data/spec/regression/expected/mysql.txt +2 -0
  39. data/spec/regression/expected/passenger_apache2.txt +2 -0
  40. data/spec/regression/expected/php.txt +2 -0
  41. data/spec/regression/expected/tomcat.txt +16 -0
  42. data/spec/regression/expected/transmission.txt +2 -0
  43. data/spec/regression/expected/ufw.txt +1 -0
  44. data/spec/regression/expected/windows.txt +2 -1
  45. data/spec/regression/expected/xml.txt +2 -0
  46. data/spec/unit/linter_spec.rb +1 -1
  47. metadata +11 -11
  48. data/features/040_check_raw_git_usage.feature +0 -43
  49. data/features/041_check_raw_download.feature +0 -34
  50. data/features/048_check_for_shellout.feature +0 -44
  51. data/lib/foodcritic/rules/fc012.rb +0 -8
  52. data/spec/functional/fc012_spec.rb +0 -20
@@ -26,10 +26,8 @@ Feature: Continuous Integration Support
26
26
  | FC002,FC005 | -f ~any | FC002,FC005 | successful |
27
27
  | FC002,FC005 | -f any -f ~FC014 | FC002,FC005 | failed |
28
28
  | FC002,FC005 | -f any,~FC014 | FC002,FC005 | failed |
29
- | FC002 | -f ~FC002 -f ~metadata | FC002 | failed |
30
29
  | FC002,FC005 | -f ~FC002 | FC002,FC005 | failed |
31
30
  | FC002,FC005 | -f any -f ~FC002 | FC002,FC005 | failed |
32
31
  | FC002 | -f any,~FC002 | FC002 | failed |
33
- | FC002 | -f any -f ~FC002 -f ~metadata | FC002 | failed |
34
32
  | FC002,FC005 | -f any,~FC002 | FC002,FC005 | failed |
35
33
  | FC002,FC005 | -f ~FC002 -f ~FC004 | FC002,FC005 | failed |
@@ -682,20 +682,6 @@ Given "a cookbook recipe with a service resource with an action specified via a
682
682
  }.strip
683
683
  end
684
684
 
685
- Given "a cookbook recipe with multiple execute resources where the last uses git" do
686
- write_recipe %q{
687
- execute "one" do
688
- command "ls -al"
689
- end
690
- execute "two" do
691
- command "df -H"
692
- end
693
- execute "three" do
694
- command "git clone https://example.org/bar.git"
695
- end
696
- }.strip
697
- end
698
-
699
685
  Given "a cookbook template that uses all variables passed" do
700
686
  write_recipe %q{
701
687
  template "/tmp/config.conf" do
@@ -1614,18 +1600,6 @@ Then /^the invalid environment name warning 050 should( not)? be shown against t
1614
1600
  :file => "environments/production_#{env}.rb", :line => 1 }
1615
1601
  end
1616
1602
 
1617
- Then "the prefer mixlib shellout warning 048 should not be displayed against the group resource" do
1618
- expect_warning "FC048", { :expect_warning => false, :line => 2 }
1619
- end
1620
-
1621
- Then "the prefer mixlib shellout warning 048 should not be displayed against the user resource" do
1622
- expect_warning "FC048", { :expect_warning => false, :line => 2 }
1623
- end
1624
-
1625
- Then "the prefer mixlib shellout warning 048 should be displayed against the ruby_block resource" do
1626
- expect_warning("FC048", :file_type => :provider, :line => 4)
1627
- end
1628
-
1629
1603
  Then /^the role name does not match file name warning 049 should( not)? be shown( against the second name)?$/ do |not_shown, second|
1630
1604
  expect_warning "FC049", { :expect_warning => ! not_shown,
1631
1605
  :file => "roles/webserver.rb", :line => second ? 2 : 1 }
@@ -25,7 +25,6 @@ module FoodCritic
25
25
  "FC009" => "Resource attribute not recognised",
26
26
  "FC010" => "Invalid search syntax",
27
27
  "FC011" => "Missing README in markdown format",
28
- "FC012" => "Use Markdown for README rather than RDoc",
29
28
  "FC013" => "Use file_cache_path rather than hard-coding tmp paths",
30
29
  "FC014" => "Consider extracting long ruby_block to library",
31
30
  "FC015" => "Consider converting definition to a Custom Resource",
@@ -54,7 +53,6 @@ module FoodCritic
54
53
  "FC045" => "Metadata does not contain cookbook name",
55
54
  "FC046" => "Attribute assignment uses assign unless nil",
56
55
  "FC047" => "Attribute assignment does not specify precedence",
57
- "FC048" => "Prefer Mixlib::ShellOut",
58
56
  "FC049" => "Role name does not match containing file name",
59
57
  "FC050" => "Name includes invalid characters",
60
58
  "FC051" => "Template partials loop indefinitely",
@@ -511,8 +511,13 @@ module FoodCritic
511
511
  end.join
512
512
  end
513
513
 
514
+ # check to see if the passed method is a node method
515
+ # we generally look this up from the chef DSL data we have
516
+ # but we specifically check for 'set' and 'set_unless' since
517
+ # those exist in cookbooks, but are not longer part of chef 14+
518
+ # this prevents false positives in FC019 anytime node.set is found
514
519
  def node_method?(meth, cookbook_dir)
515
- chef_dsl_methods.include?(meth) ||
520
+ chef_dsl_methods.include?(meth) || meth == :set || meth == :set_unless ||
516
521
  patched_node_method?(meth, cookbook_dir)
517
522
  end
518
523
 
@@ -9,7 +9,7 @@ module FoodCritic
9
9
 
10
10
  # The default version that will be used to determine relevant rules. This
11
11
  # can be over-ridden at the command line with the `--chef-version` option.
12
- DEFAULT_CHEF_VERSION = "13.7.16"
12
+ DEFAULT_CHEF_VERSION = "14.2.0"
13
13
  attr_reader :chef_version
14
14
 
15
15
  # Perform a lint check. This method is intended for use by the command-line
@@ -1,4 +1,4 @@
1
- rule "FC048", "Prefer Mixlib::ShellOut" do
1
+ rule "FC048", "Prefer shell_out helper method to shelling out with Ruby" do
2
2
  tags %w{portability}
3
3
  recipe do |ast|
4
4
  xstring_literal = ast.xpath("//xstring_literal")
@@ -8,92 +8,77 @@ rule "FC069", "Ensure standardized license defined in metadata" do
8
8
  # require 'json'
9
9
  # require 'net/http'
10
10
  # json_data = JSON.parse(Net::HTTP.get(URI('https://raw.githubusercontent.com/spdx/license-list-data/master/json/licenses.json')))
11
- # licenses = json_data['licenses'].map {|l| l['licenseId'] }
11
+ # licenses = json_data['licenses'].map {|l| l['licenseId'] }.sort
12
12
  #
13
13
  valid = %w{
14
- Glide
14
+ 0BSD
15
+ AAL
15
16
  Abstyles
17
+ Adobe-2006
18
+ Adobe-Glyph
19
+ ADSL
16
20
  AFL-1.1
17
21
  AFL-1.2
18
22
  AFL-2.0
19
23
  AFL-2.1
20
24
  AFL-3.0
21
- AMPAS
22
- APL-1.0
23
- Adobe-Glyph
24
- APAFML
25
- Adobe-2006
26
- AGPL-1.0
27
25
  Afmparse
26
+ AGPL-1.0
27
+ AGPL-1.0-only
28
+ AGPL-1.0-or-later
29
+ AGPL-3.0
30
+ AGPL-3.0-only
31
+ AGPL-3.0-or-later
28
32
  Aladdin
29
- ADSL
30
33
  AMDPLPA
34
+ AML
35
+ AMPAS
31
36
  ANTLR-PD
32
37
  Apache-1.0
33
38
  Apache-1.1
34
39
  Apache-2.0
35
- AML
40
+ APAFML
41
+ APL-1.0
36
42
  APSL-1.0
37
43
  APSL-1.1
38
44
  APSL-1.2
39
45
  APSL-2.0
40
46
  Artistic-1.0
41
- Artistic-1.0-Perl
42
47
  Artistic-1.0-cl8
48
+ Artistic-1.0-Perl
43
49
  Artistic-2.0
44
- AAL
45
50
  Bahyph
46
51
  Barr
47
52
  Beerware
48
53
  BitTorrent-1.0
49
54
  BitTorrent-1.1
50
- BSL-1.0
51
55
  Borceux
56
+ BSD-1-Clause
52
57
  BSD-2-Clause
53
58
  BSD-2-Clause-FreeBSD
54
59
  BSD-2-Clause-NetBSD
60
+ BSD-2-Clause-Patent
55
61
  BSD-3-Clause
62
+ BSD-3-Clause-Attribution
56
63
  BSD-3-Clause-Clear
64
+ BSD-3-Clause-LBNL
57
65
  BSD-3-Clause-No-Nuclear-License
58
66
  BSD-3-Clause-No-Nuclear-License-2014
59
67
  BSD-3-Clause-No-Nuclear-Warranty
60
68
  BSD-4-Clause
69
+ BSD-4-Clause-UC
61
70
  BSD-Protection
62
71
  BSD-Source-Code
63
- BSD-3-Clause-Attribution
64
- 0BSD
65
- BSD-4-Clause-UC
72
+ BSL-1.0
66
73
  bzip2-1.0.5
67
74
  bzip2-1.0.6
68
75
  Caldera
69
- CECILL-1.0
70
- CECILL-1.1
71
- CECILL-2.0
72
- CECILL-2.1
73
- CECILL-B
74
- CECILL-C
75
- ClArtistic
76
- MIT-CMU
77
- CNRI-Jython
78
- CNRI-Python
79
- CNRI-Python-GPL-Compatible
80
- CPOL-1.02
81
- CDDL-1.0
82
- CDDL-1.1
83
- CPAL-1.0
84
- CPL-1.0
85
76
  CATOSL-1.1
86
- Condor-1.1
87
77
  CC-BY-1.0
88
78
  CC-BY-2.0
89
79
  CC-BY-2.5
90
80
  CC-BY-3.0
91
81
  CC-BY-4.0
92
- CC-BY-ND-1.0
93
- CC-BY-ND-2.0
94
- CC-BY-ND-2.5
95
- CC-BY-ND-3.0
96
- CC-BY-ND-4.0
97
82
  CC-BY-NC-1.0
98
83
  CC-BY-NC-2.0
99
84
  CC-BY-NC-2.5
@@ -109,12 +94,35 @@ rule "FC069", "Ensure standardized license defined in metadata" do
109
94
  CC-BY-NC-SA-2.5
110
95
  CC-BY-NC-SA-3.0
111
96
  CC-BY-NC-SA-4.0
97
+ CC-BY-ND-1.0
98
+ CC-BY-ND-2.0
99
+ CC-BY-ND-2.5
100
+ CC-BY-ND-3.0
101
+ CC-BY-ND-4.0
112
102
  CC-BY-SA-1.0
113
103
  CC-BY-SA-2.0
114
104
  CC-BY-SA-2.5
115
105
  CC-BY-SA-3.0
116
106
  CC-BY-SA-4.0
117
107
  CC0-1.0
108
+ CDDL-1.0
109
+ CDDL-1.1
110
+ CDLA-Permissive-1.0
111
+ CDLA-Sharing-1.0
112
+ CECILL-1.0
113
+ CECILL-1.1
114
+ CECILL-2.0
115
+ CECILL-2.1
116
+ CECILL-B
117
+ CECILL-C
118
+ ClArtistic
119
+ CNRI-Jython
120
+ CNRI-Python
121
+ CNRI-Python-GPL-Compatible
122
+ Condor-1.1
123
+ CPAL-1.0
124
+ CPL-1.0
125
+ CPOL-1.02
118
126
  Crossword
119
127
  CrystalStacker
120
128
  CUA-OPL-1.0
@@ -122,122 +130,158 @@ rule "FC069", "Ensure standardized license defined in metadata" do
122
130
  curl
123
131
  D-FSL-1.0
124
132
  diffmark
125
- WTFPL
126
133
  DOC
127
134
  Dotseqn
128
135
  DSDP
129
136
  dvipdfm
130
- EPL-1.0
131
137
  ECL-1.0
132
138
  ECL-2.0
133
- eGenix
139
+ eCos-2.0
134
140
  EFL-1.0
135
141
  EFL-2.0
136
- MIT-advertising
137
- MIT-enna
142
+ eGenix
138
143
  Entessa
144
+ EPL-1.0
145
+ EPL-2.0
139
146
  ErlPL-1.1
140
147
  EUDatagrid
141
148
  EUPL-1.0
142
149
  EUPL-1.1
150
+ EUPL-1.2
143
151
  Eurosym
144
152
  Fair
145
- MIT-feh
146
153
  Frameworx-1.0
147
154
  FreeImage
148
- FTL
149
155
  FSFAP
150
156
  FSFUL
151
157
  FSFULLR
152
- Giftware
153
- GL2PS
154
- Glulxe
155
- AGPL-3.0
158
+ FTL
156
159
  GFDL-1.1
160
+ GFDL-1.1-only
161
+ GFDL-1.1-or-later
157
162
  GFDL-1.2
163
+ GFDL-1.2-only
164
+ GFDL-1.2-or-later
158
165
  GFDL-1.3
166
+ GFDL-1.3-only
167
+ GFDL-1.3-or-later
168
+ Giftware
169
+ GL2PS
170
+ Glide
171
+ Glulxe
172
+ gnuplot
159
173
  GPL-1.0
174
+ GPL-1.0-only
175
+ GPL-1.0-or-later
176
+ GPL-1.0+
160
177
  GPL-2.0
178
+ GPL-2.0-only
179
+ GPL-2.0-or-later
180
+ GPL-2.0-with-autoconf-exception
181
+ GPL-2.0-with-bison-exception
182
+ GPL-2.0-with-classpath-exception
183
+ GPL-2.0-with-font-exception
184
+ GPL-2.0-with-GCC-exception
185
+ GPL-2.0+
161
186
  GPL-3.0
162
- LGPL-2.1
163
- LGPL-3.0
164
- LGPL-2.0
165
- gnuplot
187
+ GPL-3.0-only
188
+ GPL-3.0-or-later
189
+ GPL-3.0-with-autoconf-exception
190
+ GPL-3.0-with-GCC-exception
191
+ GPL-3.0+
166
192
  gSOAP-1.3b
167
193
  HaskellReport
168
194
  HPND
169
195
  IBM-pibs
170
- IPL-1.0
171
196
  ICU
197
+ IJG
172
198
  ImageMagick
173
199
  iMatix
174
200
  Imlib2
175
- IJG
176
201
  Info-ZIP
177
- Intel-ACPI
178
202
  Intel
203
+ Intel-ACPI
179
204
  Interbase-1.0
180
205
  IPA
206
+ IPL-1.0
181
207
  ISC
182
208
  JasPer-2.0
183
209
  JSON
184
- LPPL-1.0
185
- LPPL-1.1
186
- LPPL-1.2
187
- LPPL-1.3a
188
- LPPL-1.3c
210
+ LAL-1.2
211
+ LAL-1.3
189
212
  Latex2e
190
- BSD-3-Clause-LBNL
191
213
  Leptonica
214
+ LGPL-2.0
215
+ LGPL-2.0-only
216
+ LGPL-2.0-or-later
217
+ LGPL-2.0+
218
+ LGPL-2.1
219
+ LGPL-2.1-only
220
+ LGPL-2.1-or-later
221
+ LGPL-2.1+
222
+ LGPL-3.0
223
+ LGPL-3.0-only
224
+ LGPL-3.0-or-later
225
+ LGPL-3.0+
192
226
  LGPLLR
193
227
  Libpng
194
228
  libtiff
195
- LAL-1.2
196
- LAL-1.3
197
229
  LiLiQ-P-1.1
198
- LiLiQ-Rplus-1.1
199
230
  LiLiQ-R-1.1
200
- LPL-1.02
231
+ LiLiQ-Rplus-1.1
232
+ Linux-OpenIB
201
233
  LPL-1.0
234
+ LPL-1.02
235
+ LPPL-1.0
236
+ LPPL-1.1
237
+ LPPL-1.2
238
+ LPPL-1.3a
239
+ LPPL-1.3c
202
240
  MakeIndex
203
- MTLL
204
- MS-PL
205
- MS-RL
206
241
  MirOS
207
- MITNFA
208
242
  MIT
243
+ MIT-0
244
+ MIT-advertising
245
+ MIT-CMU
246
+ MIT-enna
247
+ MIT-feh
248
+ MITNFA
209
249
  Motosoto
250
+ mpich2
210
251
  MPL-1.0
211
252
  MPL-1.1
212
253
  MPL-2.0
213
254
  MPL-2.0-no-copyleft-exception
214
- mpich2
255
+ MS-PL
256
+ MS-RL
257
+ MTLL
215
258
  Multics
216
259
  Mup
217
260
  NASA-1.3
218
261
  Naumen
219
262
  NBPL-1.0
263
+ NCSA
220
264
  Net-SNMP
221
265
  NetCDF
266
+ Newsletr
222
267
  NGPL
268
+ NLOD-1.0
269
+ NLPL
270
+ Nokia
223
271
  NOSL
272
+ Noweb
224
273
  NPL-1.0
225
274
  NPL-1.1
226
- Newsletr
227
- NLPL
228
- Nokia
229
275
  NPOSL-3.0
230
- NLOD-1.0
231
- Noweb
232
276
  NRL
233
277
  NTP
234
278
  Nunit
279
+ OCCT-PL
235
280
  OCLC-2.0
236
281
  ODbL-1.0
237
- PDDL-1.0
238
- OCCT-PL
282
+ OFL-1.0
283
+ OFL-1.1
239
284
  OGTSL
240
- OLDAP-2.2.2
241
285
  OLDAP-1.1
242
286
  OLDAP-1.2
243
287
  OLDAP-1.3
@@ -247,6 +291,7 @@ rule "FC069", "Ensure standardized license defined in metadata" do
247
291
  OLDAP-2.1
248
292
  OLDAP-2.2
249
293
  OLDAP-2.2.1
294
+ OLDAP-2.2.2
250
295
  OLDAP-2.3
251
296
  OLDAP-2.4
252
297
  OLDAP-2.5
@@ -254,14 +299,15 @@ rule "FC069", "Ensure standardized license defined in metadata" do
254
299
  OLDAP-2.7
255
300
  OLDAP-2.8
256
301
  OML
302
+ OpenSSL
257
303
  OPL-1.0
304
+ OSET-PL-2.1
258
305
  OSL-1.0
259
306
  OSL-1.1
260
307
  OSL-2.0
261
308
  OSL-2.1
262
309
  OSL-3.0
263
- OpenSSL
264
- OSET-PL-2.1
310
+ PDDL-1.0
265
311
  PHP-3.0
266
312
  PHP-3.01
267
313
  Plexus
@@ -269,62 +315,62 @@ rule "FC069", "Ensure standardized license defined in metadata" do
269
315
  psfrag
270
316
  psutils
271
317
  Python-2.0
272
- QPL-1.0
273
318
  Qhull
319
+ QPL-1.0
274
320
  Rdisc
275
- RPSL-1.0
321
+ RHeCos-1.1
276
322
  RPL-1.1
277
323
  RPL-1.5
278
- RHeCos-1.1
279
- RSCPL
324
+ RPSL-1.0
280
325
  RSA-MD
326
+ RSCPL
281
327
  Ruby
282
328
  SAX-PD
283
329
  Saxpath
284
330
  SCEA
285
- SWL
286
- SMPPL
287
331
  Sendmail
288
332
  SGI-B-1.0
289
333
  SGI-B-1.1
290
334
  SGI-B-2.0
291
- OFL-1.0
292
- OFL-1.1
293
335
  SimPL-2.0
336
+ SISSL
337
+ SISSL-1.2
294
338
  Sleepycat
339
+ SMLNJ
340
+ SMPPL
295
341
  SNIA
296
342
  Spencer-86
297
343
  Spencer-94
298
344
  Spencer-99
299
- SMLNJ
300
- SugarCRM-1.1.3
301
- SISSL
302
- SISSL-1.2
303
345
  SPL-1.0
304
- Watcom-1.0
346
+ StandardML-NJ
347
+ SugarCRM-1.1.3
348
+ SWL
305
349
  TCL
306
350
  TCP-wrappers
307
- Unlicense
308
351
  TMate
309
352
  TORQUE-1.1
310
353
  TOSL
311
354
  Unicode-DFS-2015
312
355
  Unicode-DFS-2016
313
356
  Unicode-TOU
357
+ Unlicense
314
358
  UPL-1.0
315
- NCSA
316
359
  Vim
317
360
  VOSTROM
318
361
  VSL-1.0
319
- W3C-20150513
320
- W3C-19980720
321
362
  W3C
363
+ W3C-19980720
364
+ W3C-20150513
365
+ Watcom-1.0
322
366
  Wsuipa
323
- Xnet
367
+ WTFPL
368
+ wxWindows
324
369
  X11
325
370
  Xerox
326
371
  XFree86-1.1
327
372
  xinetd
373
+ Xnet
328
374
  xpp
329
375
  XSkat
330
376
  YPL-1.0
@@ -338,22 +384,6 @@ rule "FC069", "Ensure standardized license defined in metadata" do
338
384
  ZPL-1.1
339
385
  ZPL-2.0
340
386
  ZPL-2.1
341
- eCos-2.0
342
- GPL-1.0+
343
- GPL-2.0+
344
- GPL-2.0-with-autoconf-exception
345
- GPL-2.0-with-bison-exception
346
- GPL-2.0-with-classpath-exception
347
- GPL-2.0-with-font-exception
348
- GPL-2.0-with-GCC-exception
349
- GPL-3.0+
350
- GPL-3.0-with-autoconf-exception
351
- GPL-3.0-with-GCC-exception
352
- LGPL-2.1+
353
- LGPL-3.0+
354
- LGPL-2.0+
355
- StandardML-NJ
356
- WXwindows
357
387
  }
358
388
  [file_match(filename)] unless valid.include?(license) || license =~ /all rights reserved/i
359
389
  rescue NoMethodError # no license in the metadata