foodcritic 10.4.1 → 11.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +26 -1
- data/Rakefile +7 -1
- data/features/step_definitions/cookbook_steps.rb +0 -96
- data/lib/foodcritic/api.rb +77 -79
- data/lib/foodcritic/rules/fc008.rb +2 -2
- data/lib/foodcritic/rules/fc029.rb +1 -1
- data/lib/foodcritic/rules/fc042.rb +1 -1
- data/lib/foodcritic/rules/fc052.rb +1 -1
- data/lib/foodcritic/rules/fc053.rb +1 -1
- data/lib/foodcritic/rules/fc057.rb +1 -1
- data/lib/foodcritic/rules/fc058.rb +1 -1
- data/lib/foodcritic/rules/fc060.rb +1 -1
- data/lib/foodcritic/rules/fc061.rb +3 -3
- data/lib/foodcritic/rules/fc063.rb +1 -2
- data/lib/foodcritic/rules/fc069.rb +2 -4
- data/lib/foodcritic/rules/fc078.rb +2 -3
- data/lib/foodcritic/rules/fc079.rb +6 -0
- data/lib/foodcritic/rules/fc080.rb +6 -0
- data/lib/foodcritic/rules/fc081.rb +6 -0
- data/lib/foodcritic/rules/fc082.rb +9 -0
- data/lib/foodcritic/rules/fc083.rb +6 -0
- data/lib/foodcritic/rules/fc084.rb +9 -0
- data/lib/foodcritic/rules/fc085.rb +12 -0
- data/lib/foodcritic/version.rb +1 -1
- data/spec/functional/fc007_spec.rb +127 -0
- data/spec/functional/fc049_spec.rb +56 -0
- data/spec/functional/fc050_spec.rb +85 -0
- data/spec/functional/fc066_spec.rb +20 -0
- data/spec/functional/fc069_spec.rb +15 -0
- data/spec/functional/fc070_spec.rb +9 -0
- data/spec/functional/fc076_spec.rb +2 -2
- data/spec/functional/fc077_spec.rb +2 -2
- data/spec/functional/fc078_spec.rb +14 -4
- data/spec/functional/fc079_spec.rb +21 -0
- data/spec/functional/fc080_spec.rb +68 -0
- data/spec/functional/fc081_spec.rb +25 -0
- data/spec/functional/fc082_spec.rb +23 -0
- data/spec/functional/fc083_spec.rb +34 -0
- data/spec/functional/fc084_spec.rb +49 -0
- data/spec/functional/fc085_spec.rb +58 -0
- data/spec/regression/expected/aix.txt +1 -0
- data/spec/regression/expected/aws.txt +3 -0
- data/spec/regression/expected/chef-client.txt +2 -0
- data/spec/regression/expected/chef.txt +67 -0
- data/spec/regression/expected/database.txt +1 -0
- data/spec/regression/expected/drbd.txt +1 -0
- data/spec/regression/expected/jetty.txt +1 -0
- data/spec/regression/expected/mysql.txt +4 -0
- data/spec/regression/expected/openssh.txt +1 -0
- data/spec/regression/expected/postfix.txt +1 -0
- data/spec/regression/expected/rsyslog.txt +1 -0
- data/spec/regression/expected/smokeping.txt +1 -0
- data/spec/regression/expected/sql_server.txt +1 -0
- data/spec/regression/expected/ufw.txt +1 -0
- data/spec/regression/expected/users.txt +2 -0
- data/spec/regression/expected/xml.txt +1 -0
- data/spec/regression/expected/yum.txt +0 -1
- data/spec/regression/regression_spec.rb +2 -2
- data/spec/unit/api_spec.rb +130 -149
- metadata +20 -32
- data/features/007_check_for_undeclared_recipe_dependencies.feature +0 -59
- data/features/049_check_for_role_name_mismatch_with_file_name.feature +0 -31
- data/features/050_check_for_invalid_name.feature +0 -33
- data/man/foodcritic.1 +0 -81
- data/spec/foodcritic/coverage/assets/0.10.0/application.css +0 -799
- data/spec/foodcritic/coverage/assets/0.10.0/application.js +0 -1707
- data/spec/foodcritic/coverage/assets/0.10.0/colorbox/border.png +0 -0
- data/spec/foodcritic/coverage/assets/0.10.0/colorbox/controls.png +0 -0
- data/spec/foodcritic/coverage/assets/0.10.0/colorbox/loading.gif +0 -0
- data/spec/foodcritic/coverage/assets/0.10.0/colorbox/loading_background.png +0 -0
- data/spec/foodcritic/coverage/assets/0.10.0/favicon_green.png +0 -0
- data/spec/foodcritic/coverage/assets/0.10.0/favicon_red.png +0 -0
- data/spec/foodcritic/coverage/assets/0.10.0/favicon_yellow.png +0 -0
- data/spec/foodcritic/coverage/assets/0.10.0/loading.gif +0 -0
- data/spec/foodcritic/coverage/assets/0.10.0/magnify.png +0 -0
- data/spec/foodcritic/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/spec/foodcritic/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/spec/foodcritic/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/spec/foodcritic/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/spec/foodcritic/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/spec/foodcritic/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/spec/foodcritic/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/spec/foodcritic/coverage/assets/0.10.0/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/spec/foodcritic/coverage/assets/0.10.0/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/spec/foodcritic/coverage/assets/0.10.0/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/spec/foodcritic/coverage/assets/0.10.0/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/spec/foodcritic/coverage/assets/0.10.0/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/spec/foodcritic/coverage/assets/0.10.0/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/spec/foodcritic/coverage/index.html +0 -72
@@ -13,3 +13,4 @@ FC066: Ensure chef_version is set in metadata: ./metadata.rb:1
|
|
13
13
|
FC069: Ensure standardized license defined in metadata: ./metadata.rb:1
|
14
14
|
FC075: Cookbook uses node.save to save partial node data to the chef-server mid-run: ./recipes/master.rb:37
|
15
15
|
FC078: Ensure cookbook shared under an OSI-approved open source license: ./metadata.rb:1
|
16
|
+
FC082: node.set or node.set_unless used to set node attributes: ./recipes/master.rb:36
|
@@ -25,3 +25,4 @@ FC066: Ensure chef_version is set in metadata: ./metadata.rb:1
|
|
25
25
|
FC069: Ensure standardized license defined in metadata: ./metadata.rb:1
|
26
26
|
FC075: Cookbook uses node.save to save partial node data to the chef-server mid-run: ./recipes/default.rb:21
|
27
27
|
FC078: Ensure cookbook shared under an OSI-approved open source license: ./metadata.rb:1
|
28
|
+
FC082: node.set or node.set_unless used to set node attributes: ./recipes/pair.rb:87
|
@@ -10,3 +10,4 @@ FC065: Ensure source_url is set in metadata: ./metadata.rb:1
|
|
10
10
|
FC066: Ensure chef_version is set in metadata: ./metadata.rb:1
|
11
11
|
FC069: Ensure standardized license defined in metadata: ./metadata.rb:1
|
12
12
|
FC078: Ensure cookbook shared under an OSI-approved open source license: ./metadata.rb:1
|
13
|
+
FC082: node.set or node.set_unless used to set node attributes: ./recipes/cargo.rb:38
|
@@ -12,3 +12,7 @@ FC069: Ensure standardized license defined in metadata: ./metadata.rb:1
|
|
12
12
|
FC072: Metadata should not contain "attribute" keyword: ./metadata.rb:1
|
13
13
|
FC075: Cookbook uses node.save to save partial node data to the chef-server mid-run: ./recipes/server.rb:42
|
14
14
|
FC078: Ensure cookbook shared under an OSI-approved open source license: ./metadata.rb:1
|
15
|
+
FC082: node.set or node.set_unless used to set node attributes: ./recipes/ruby.rb:28
|
16
|
+
FC082: node.set or node.set_unless used to set node attributes: ./recipes/server.rb:39
|
17
|
+
FC082: node.set or node.set_unless used to set node attributes: ./recipes/server.rb:40
|
18
|
+
FC082: node.set or node.set_unless used to set node attributes: ./recipes/server.rb:41
|
@@ -3,3 +3,4 @@ FC065: Ensure source_url is set in metadata: ./metadata.rb:1
|
|
3
3
|
FC066: Ensure chef_version is set in metadata: ./metadata.rb:1
|
4
4
|
FC069: Ensure standardized license defined in metadata: ./metadata.rb:1
|
5
5
|
FC078: Ensure cookbook shared under an OSI-approved open source license: ./metadata.rb:1
|
6
|
+
FC082: node.set or node.set_unless used to set node attributes: ./recipes/default.rb:63
|
@@ -5,3 +5,4 @@ FC066: Ensure chef_version is set in metadata: ./metadata.rb:1
|
|
5
5
|
FC069: Ensure standardized license defined in metadata: ./metadata.rb:1
|
6
6
|
FC072: Metadata should not contain "attribute" keyword: ./metadata.rb:1
|
7
7
|
FC078: Ensure cookbook shared under an OSI-approved open source license: ./metadata.rb:1
|
8
|
+
FC082: node.set or node.set_unless used to set node attributes: ./recipes/client.rb:40
|
@@ -8,3 +8,4 @@ FC069: Ensure standardized license defined in metadata: ./metadata.rb:1
|
|
8
8
|
FC072: Metadata should not contain "attribute" keyword: ./metadata.rb:1
|
9
9
|
FC075: Cookbook uses node.save to save partial node data to the chef-server mid-run: ./recipes/server.rb:23
|
10
10
|
FC078: Ensure cookbook shared under an OSI-approved open source license: ./metadata.rb:1
|
11
|
+
FC082: node.set or node.set_unless used to set node attributes: ./recipes/server.rb:22
|
@@ -2,3 +2,4 @@ FC059: LWRP provider does not declare use_inline_resources: ./providers/target.r
|
|
2
2
|
FC066: Ensure chef_version is set in metadata: ./metadata.rb:1
|
3
3
|
FC069: Ensure standardized license defined in metadata: ./metadata.rb:1
|
4
4
|
FC078: Ensure cookbook shared under an OSI-approved open source license: ./metadata.rb:1
|
5
|
+
FC082: node.set or node.set_unless used to set node attributes: ./recipes/example_slave.rb:19
|
@@ -4,3 +4,4 @@ FC066: Ensure chef_version is set in metadata: ./metadata.rb:1
|
|
4
4
|
FC069: Ensure standardized license defined in metadata: ./metadata.rb:1
|
5
5
|
FC075: Cookbook uses node.save to save partial node data to the chef-server mid-run: ./recipes/server.rb:28
|
6
6
|
FC078: Ensure cookbook shared under an OSI-approved open source license: ./metadata.rb:1
|
7
|
+
FC082: node.set or node.set_unless used to set node attributes: ./recipes/server.rb:26
|
@@ -8,3 +8,4 @@ FC066: Ensure chef_version is set in metadata: ./metadata.rb:1
|
|
8
8
|
FC069: Ensure standardized license defined in metadata: ./metadata.rb:1
|
9
9
|
FC072: Metadata should not contain "attribute" keyword: ./metadata.rb:1
|
10
10
|
FC078: Ensure cookbook shared under an OSI-approved open source license: ./metadata.rb:1
|
11
|
+
FC082: node.set or node.set_unless used to set node attributes: ./recipes/default.rb:34
|
@@ -6,3 +6,5 @@ FC066: Ensure chef_version is set in metadata: ./metadata.rb:1
|
|
6
6
|
FC069: Ensure standardized license defined in metadata: ./metadata.rb:1
|
7
7
|
FC074: LWRP should use DSL to define resource's default action: ./resources/manage.rb:1
|
8
8
|
FC078: Ensure cookbook shared under an OSI-approved open source license: ./metadata.rb:1
|
9
|
+
FC080: User resource uses supports property: ./providers/manage.rb:87
|
10
|
+
FC080: User resource uses supports property: ./providers/manage.rb:89
|
@@ -3,3 +3,4 @@ FC065: Ensure source_url is set in metadata: ./metadata.rb:1
|
|
3
3
|
FC066: Ensure chef_version is set in metadata: ./metadata.rb:1
|
4
4
|
FC069: Ensure standardized license defined in metadata: ./metadata.rb:1
|
5
5
|
FC078: Ensure cookbook shared under an OSI-approved open source license: ./metadata.rb:1
|
6
|
+
FC082: node.set or node.set_unless used to set node attributes: ./recipes/ruby.rb:27
|
@@ -11,7 +11,6 @@ FC064: Ensure issues_url is set in metadata: ./metadata.rb:1
|
|
11
11
|
FC065: Ensure source_url is set in metadata: ./metadata.rb:1
|
12
12
|
FC066: Ensure chef_version is set in metadata: ./metadata.rb:1
|
13
13
|
FC069: Ensure standardized license defined in metadata: ./metadata.rb:1
|
14
|
-
FC070: Ensure supports metadata defines valid platforms: ./metadata.rb:1
|
15
14
|
FC072: Metadata should not contain "attribute" keyword: ./metadata.rb:1
|
16
15
|
FC074: LWRP should use DSL to define resource's default action: ./resources/key.rb:1
|
17
16
|
FC074: LWRP should use DSL to define resource's default action: ./resources/repository.rb:1
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe "regression test" do
|
4
|
-
command("#{File.expand_path("../../../bin/foodcritic", __FILE__)} --tags any .", allow_error: true)
|
4
|
+
command("#{File.expand_path("../../../bin/foodcritic", __FILE__)} --no-progress --tags any .", allow_error: true)
|
5
5
|
|
6
6
|
IO.readlines(File.expand_path("../cookbooks.txt", __FILE__)).each do |line|
|
7
7
|
name, ref = line.strip.split(":")
|
8
8
|
|
9
|
-
context "with cookbook #{name}" do
|
9
|
+
context "with cookbook #{name}", "regression_#{name}" => true do
|
10
10
|
before do
|
11
11
|
command("git clone -q https://github.com/chef-cookbooks/#{name}.git .")
|
12
12
|
command("git checkout -q #{ref}")
|
data/spec/unit/api_spec.rb
CHANGED
@@ -6,6 +6,10 @@ describe FoodCritic::Api do
|
|
6
6
|
api.send(:build_xml, Ripper::SexpBuilder.new(str).parse)
|
7
7
|
end
|
8
8
|
|
9
|
+
def self.ast(str)
|
10
|
+
let(:ast) { parse_ast(str) }
|
11
|
+
end
|
12
|
+
|
9
13
|
let(:api) { Object.new.extend(FoodCritic::Api) }
|
10
14
|
|
11
15
|
describe :exposed_api do
|
@@ -15,10 +19,8 @@ describe FoodCritic::Api do
|
|
15
19
|
it "exposes the expected api to rule authors" do
|
16
20
|
expect(api.public_methods.sort - ignorable_methods).to eq [
|
17
21
|
:attribute_access,
|
18
|
-
:checks_for_chef_solo?,
|
19
22
|
:chef_dsl_methods,
|
20
23
|
:chef_node_methods,
|
21
|
-
:chef_solo_search_supported?,
|
22
24
|
:cookbook_base_path,
|
23
25
|
:cookbook_maintainer,
|
24
26
|
:cookbook_maintainer_email,
|
@@ -31,6 +33,7 @@ describe FoodCritic::Api do
|
|
31
33
|
:find_resources,
|
32
34
|
:gem_version,
|
33
35
|
:included_recipes,
|
36
|
+
:json_file_to_hash,
|
34
37
|
:literal_searches,
|
35
38
|
:match,
|
36
39
|
:metadata_field,
|
@@ -138,50 +141,6 @@ describe FoodCritic::Api do
|
|
138
141
|
end
|
139
142
|
end
|
140
143
|
|
141
|
-
describe "#checks_for_chef_solo?" do
|
142
|
-
let(:ast) { double() }
|
143
|
-
around do |ex|
|
144
|
-
begin
|
145
|
-
$stderr = StringIO.new
|
146
|
-
ex.run
|
147
|
-
ensure
|
148
|
-
$stderr = STDERR
|
149
|
-
end
|
150
|
-
end
|
151
|
-
it "raises if the provided ast does not support XPath" do
|
152
|
-
expect { api.checks_for_chef_solo?(nil) }.to raise_error ArgumentError
|
153
|
-
end
|
154
|
-
it "returns false if there is no reference to chef solo" do
|
155
|
-
expect(ast).to receive(:xpath).with(kind_of(String)).and_return([]).twice
|
156
|
-
expect(api.checks_for_chef_solo?(ast)).to be_falsey
|
157
|
-
end
|
158
|
-
it "returns true if there is one reference to chef solo" do
|
159
|
-
expect(ast).to receive(:xpath).with(kind_of(String)).and_return(["aref"])
|
160
|
-
expect(api.checks_for_chef_solo?(ast)).to be_truthy
|
161
|
-
end
|
162
|
-
it "returns true if there are multiple references to chef solo" do
|
163
|
-
expect(ast).to receive(:xpath).with(kind_of(String)).and_return(%w{aref aref})
|
164
|
-
expect(api.checks_for_chef_solo?(ast)).to be_truthy
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
describe "#chef_solo_search_supported?" do
|
169
|
-
around do |ex|
|
170
|
-
begin
|
171
|
-
$stderr = StringIO.new
|
172
|
-
ex.run
|
173
|
-
ensure
|
174
|
-
$stderr = STDERR
|
175
|
-
end
|
176
|
-
end
|
177
|
-
it "returns false if the recipe path is nil" do
|
178
|
-
expect(api.chef_solo_search_supported?(nil)).to be_falsey
|
179
|
-
end
|
180
|
-
it "returns false if the recipe path does not exist" do
|
181
|
-
expect(api.chef_solo_search_supported?("/tmp/non-existent-path")).to be_falsey
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
144
|
describe "#metadata_field" do
|
186
145
|
file "metadata.rb", 'name "YOUR_COOKBOOK_NAME"'
|
187
146
|
|
@@ -310,46 +269,34 @@ describe FoodCritic::Api do
|
|
310
269
|
end
|
311
270
|
|
312
271
|
describe "#declared_dependencies" do
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
<string_add>
|
342
|
-
<string_content/>
|
343
|
-
<tstring_content value=">= 1.2.0">
|
344
|
-
<pos line="14" column="18"/>
|
345
|
-
</tstring_content>
|
346
|
-
</string_add>
|
347
|
-
</string_literal>
|
348
|
-
</args_add>
|
349
|
-
</args_add_block>
|
350
|
-
</command>
|
351
|
-
})
|
352
|
-
expect(api.declared_dependencies(ast)).to eq ["mysql"]
|
272
|
+
let(:ast) { nil }
|
273
|
+
subject { api.declared_dependencies(ast) }
|
274
|
+
context "with an invalid options" do
|
275
|
+
it { expect { subject }.to raise_error ArgumentError }
|
276
|
+
end
|
277
|
+
context "with no dependencies" do
|
278
|
+
ast 'name "cook"'
|
279
|
+
it { is_expected.to eq [] }
|
280
|
+
end
|
281
|
+
context "with a simple dependency" do
|
282
|
+
ast 'depends "one"'
|
283
|
+
it { is_expected.to eq %w{one} }
|
284
|
+
end
|
285
|
+
context "with multiple simple dependencies" do
|
286
|
+
ast %Q{depends "one"\ndepends 'two'\ndepends('three')}
|
287
|
+
it { is_expected.to eq %w{one two three} }
|
288
|
+
end
|
289
|
+
context "using a word array and a one-line block" do
|
290
|
+
ast "%w{one two three}.each {|d| depends d }"
|
291
|
+
it { is_expected.to eq %w{one two three} }
|
292
|
+
end
|
293
|
+
context "using a word array and a multi-line block" do
|
294
|
+
ast "%w{one two three}.each do |d|\n depends d\nend"
|
295
|
+
it { is_expected.to eq %w{one two three} }
|
296
|
+
end
|
297
|
+
context "using a non-standard word array" do
|
298
|
+
ast "%w|one two three|.each {|d| depends d }"
|
299
|
+
it { is_expected.to eq %w{one two three} }
|
353
300
|
end
|
354
301
|
end
|
355
302
|
|
@@ -1821,75 +1768,91 @@ describe FoodCritic::Api do
|
|
1821
1768
|
end
|
1822
1769
|
|
1823
1770
|
describe "#supported_platforms" do
|
1824
|
-
|
1825
|
-
|
1826
|
-
|
1827
|
-
|
1828
|
-
|
1829
|
-
end
|
1830
|
-
|
1831
|
-
|
1832
|
-
|
1833
|
-
|
1834
|
-
|
1835
|
-
|
1836
|
-
|
1837
|
-
end
|
1838
|
-
|
1839
|
-
|
1840
|
-
|
1841
|
-
|
1842
|
-
|
1843
|
-
|
1844
|
-
|
1845
|
-
|
1846
|
-
|
1847
|
-
|
1848
|
-
|
1849
|
-
|
1850
|
-
|
1851
|
-
|
1852
|
-
|
1853
|
-
|
1854
|
-
|
1855
|
-
|
1856
|
-
|
1857
|
-
|
1858
|
-
|
1771
|
+
subject { api.supported_platforms(ast) }
|
1772
|
+
|
1773
|
+
context "with no platforms" do
|
1774
|
+
ast 'name "supports"'
|
1775
|
+
it { is_expected.to eq [] }
|
1776
|
+
end
|
1777
|
+
context "with supports but no argument" do
|
1778
|
+
ast "supports"
|
1779
|
+
it { is_expected.to eq [] }
|
1780
|
+
end
|
1781
|
+
context "with supports using a string expression" do
|
1782
|
+
ast 'supports "red#{hat}"'
|
1783
|
+
it { is_expected.to eq [] }
|
1784
|
+
end
|
1785
|
+
context "with supports using a complex string expression" do
|
1786
|
+
ast 'supports "red#{hat(foo "bar")}"'
|
1787
|
+
it { is_expected.to eq [] }
|
1788
|
+
end
|
1789
|
+
context "with a single platform" do
|
1790
|
+
ast 'supports "redhat"'
|
1791
|
+
it { is_expected.to eq [{ platform: "redhat", versions: [] }] }
|
1792
|
+
end
|
1793
|
+
context "with multiple platforms" do
|
1794
|
+
ast "supports 'oracle'\nsupports 'redhat'\nsupports 'scientific'"
|
1795
|
+
it do
|
1796
|
+
is_expected.to eq [{ platform: "oracle", versions: [] },
|
1797
|
+
{ platform: "redhat", versions: [] },
|
1798
|
+
{ platform: "scientific", versions: [] }] end
|
1799
|
+
end
|
1800
|
+
context "with multiple platforms not in alphabetical order" do
|
1801
|
+
ast "supports 'redhat'\nsupports 'scientific'\nsupports 'oracle'"
|
1802
|
+
it do
|
1803
|
+
is_expected.to eq [{ platform: "oracle", versions: [] },
|
1804
|
+
{ platform: "redhat", versions: [] },
|
1805
|
+
{ platform: "scientific", versions: [] }] end
|
1806
|
+
end
|
1807
|
+
context "with a version constraint" do
|
1808
|
+
ast 'supports "redhat", ">= 6"'
|
1809
|
+
it { is_expected.to eq [{ platform: "redhat", versions: [">= 6"] }] }
|
1810
|
+
end
|
1811
|
+
context "with complex version constraints" do
|
1812
|
+
ast %q{
|
1859
1813
|
supports 'redhat', '> 5.0', '< 7.0'
|
1860
1814
|
supports 'scientific', '> 5.0', '< 6.0'
|
1861
|
-
}
|
1862
|
-
|
1863
|
-
|
1864
|
-
|
1865
|
-
|
1866
|
-
|
1867
|
-
|
1868
|
-
|
1869
|
-
|
1870
|
-
|
1871
|
-
|
1872
|
-
|
1873
|
-
end
|
1874
|
-
|
1875
|
-
|
1876
|
-
|
1877
|
-
|
1878
|
-
|
1879
|
-
|
1880
|
-
|
1881
|
-
|
1882
|
-
|
1883
|
-
it "handles support declarations from arrays that include whitespace" do
|
1884
|
-
expect(supports(%q{
|
1815
|
+
}
|
1816
|
+
it do
|
1817
|
+
is_expected.to eq [{ platform: "redhat", versions: ["> 5.0", "< 7.0"] },
|
1818
|
+
{ platform: "scientific", versions: ["> 5.0", "< 6.0"] }] end
|
1819
|
+
end
|
1820
|
+
context "with a symbol platform" do
|
1821
|
+
ast "supports :ubuntu"
|
1822
|
+
it { is_expected.to eq [{ platform: "ubuntu", versions: [] }] }
|
1823
|
+
end
|
1824
|
+
context "with a symbol platform with a version constraint" do
|
1825
|
+
ast 'supports :ubuntu, ">= 6"'
|
1826
|
+
it { is_expected.to eq [{ platform: "ubuntu", versions: [">= 6"] }] }
|
1827
|
+
end
|
1828
|
+
context "with a word list" do
|
1829
|
+
ast "%w{redhat centos fedora}.each {|os| supports os }"
|
1830
|
+
it do
|
1831
|
+
is_expected.to eq [{ platform: "centos", versions: [] },
|
1832
|
+
{ platform: "fedora", versions: [] },
|
1833
|
+
{ platform: "redhat", versions: [] }] end
|
1834
|
+
end
|
1835
|
+
context "with a multi-line word list" do
|
1836
|
+
ast %q{
|
1885
1837
|
%w(
|
1886
|
-
|
1887
|
-
|
1838
|
+
redhat
|
1839
|
+
centos
|
1840
|
+
fedora
|
1888
1841
|
).each do |os|
|
1889
1842
|
supports os
|
1890
1843
|
end
|
1891
|
-
}
|
1892
|
-
|
1844
|
+
}
|
1845
|
+
it do
|
1846
|
+
is_expected.to eq [{ platform: "centos", versions: [] },
|
1847
|
+
{ platform: "fedora", versions: [] },
|
1848
|
+
{ platform: "redhat", versions: [] }] end
|
1849
|
+
end
|
1850
|
+
context "with both a word list and a non-word list" do
|
1851
|
+
ast "supports 'redhat'\n%w{centos fedora}.each {|os| supports os }"
|
1852
|
+
it do
|
1853
|
+
is_expected.to eq [{ platform: "centos", versions: [] },
|
1854
|
+
{ platform: "fedora", versions: [] },
|
1855
|
+
{ platform: "redhat", versions: [] }] end
|
1893
1856
|
end
|
1894
1857
|
end
|
1895
1858
|
|
@@ -1951,4 +1914,22 @@ describe FoodCritic::Api do
|
|
1951
1914
|
end
|
1952
1915
|
end
|
1953
1916
|
|
1917
|
+
describe "#json_file_to_hash" do
|
1918
|
+
|
1919
|
+
it "raises if the filename is not provided" do
|
1920
|
+
expect { api.json_file_to_hash }.to raise_error ArgumentError
|
1921
|
+
end
|
1922
|
+
|
1923
|
+
it "raises if the filename is not found" do
|
1924
|
+
expect(::File).to receive(:exist?).with("/some/path/with/a/file").and_return(false)
|
1925
|
+
expect { api.json_file_to_hash("/some/path/with/a/file") }.to raise_error RuntimeError
|
1926
|
+
end
|
1927
|
+
|
1928
|
+
it "raises if the json is not valid" do
|
1929
|
+
expect(::File).to receive(:exist?).with("/some/path/with/a/file").and_return(true)
|
1930
|
+
allow(File).to receive(:read).with("/some/path/with/a/file").and_return("I am bogus data")
|
1931
|
+
expect { api.json_file_to_hash("/some/path/with/a/file") }.to raise_error JSON::ParserError
|
1932
|
+
end
|
1933
|
+
end
|
1934
|
+
|
1954
1935
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foodcritic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 11.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Crump
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cucumber-core
|
@@ -188,7 +188,6 @@ files:
|
|
188
188
|
- features/004_check_service_resource_used.feature
|
189
189
|
- features/005_check_for_resource_repetition.feature
|
190
190
|
- features/006_check_file_mode.feature
|
191
|
-
- features/007_check_for_undeclared_recipe_dependencies.feature
|
192
191
|
- features/009_check_for_unrecognised_resource_attributes.feature
|
193
192
|
- features/010_check_search_syntax.feature
|
194
193
|
- features/014_check_for_long_ruby_blocks.feature
|
@@ -216,8 +215,6 @@ files:
|
|
216
215
|
- features/046_check_for_assign_unless_nil_attributes.feature
|
217
216
|
- features/047_check_for_attribute_assignment_without_precedence.feature
|
218
217
|
- features/048_check_for_shellout.feature
|
219
|
-
- features/049_check_for_role_name_mismatch_with_file_name.feature
|
220
|
-
- features/050_check_for_invalid_name.feature
|
221
218
|
- features/051_check_for_template_partial_loops.feature
|
222
219
|
- features/057_check_for_library_provider_without_use_inline_resources.feature
|
223
220
|
- features/058_check_for_library_provider_bad_action_methods.feature
|
@@ -326,38 +323,20 @@ files:
|
|
326
323
|
- lib/foodcritic/rules/fc076.rb
|
327
324
|
- lib/foodcritic/rules/fc077.rb
|
328
325
|
- lib/foodcritic/rules/fc078.rb
|
326
|
+
- lib/foodcritic/rules/fc079.rb
|
327
|
+
- lib/foodcritic/rules/fc080.rb
|
328
|
+
- lib/foodcritic/rules/fc081.rb
|
329
|
+
- lib/foodcritic/rules/fc082.rb
|
330
|
+
- lib/foodcritic/rules/fc083.rb
|
331
|
+
- lib/foodcritic/rules/fc084.rb
|
332
|
+
- lib/foodcritic/rules/fc085.rb
|
329
333
|
- lib/foodcritic/template.rb
|
330
334
|
- lib/foodcritic/version.rb
|
331
335
|
- lib/foodcritic/xml.rb
|
332
|
-
- man/foodcritic.1
|
333
336
|
- man/foodcritic.1.ronn
|
334
337
|
- misc/lucene.treetop
|
335
|
-
- spec/foodcritic/coverage/assets/0.10.0/application.css
|
336
|
-
- spec/foodcritic/coverage/assets/0.10.0/application.js
|
337
|
-
- spec/foodcritic/coverage/assets/0.10.0/colorbox/border.png
|
338
|
-
- spec/foodcritic/coverage/assets/0.10.0/colorbox/controls.png
|
339
|
-
- spec/foodcritic/coverage/assets/0.10.0/colorbox/loading.gif
|
340
|
-
- spec/foodcritic/coverage/assets/0.10.0/colorbox/loading_background.png
|
341
|
-
- spec/foodcritic/coverage/assets/0.10.0/favicon_green.png
|
342
|
-
- spec/foodcritic/coverage/assets/0.10.0/favicon_red.png
|
343
|
-
- spec/foodcritic/coverage/assets/0.10.0/favicon_yellow.png
|
344
|
-
- spec/foodcritic/coverage/assets/0.10.0/loading.gif
|
345
|
-
- spec/foodcritic/coverage/assets/0.10.0/magnify.png
|
346
|
-
- spec/foodcritic/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png
|
347
|
-
- spec/foodcritic/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_75_ffffff_40x100.png
|
348
|
-
- spec/foodcritic/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png
|
349
|
-
- spec/foodcritic/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_65_ffffff_1x400.png
|
350
|
-
- spec/foodcritic/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_dadada_1x400.png
|
351
|
-
- spec/foodcritic/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png
|
352
|
-
- spec/foodcritic/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png
|
353
|
-
- spec/foodcritic/coverage/assets/0.10.0/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png
|
354
|
-
- spec/foodcritic/coverage/assets/0.10.0/smoothness/images/ui-icons_222222_256x240.png
|
355
|
-
- spec/foodcritic/coverage/assets/0.10.0/smoothness/images/ui-icons_2e83ff_256x240.png
|
356
|
-
- spec/foodcritic/coverage/assets/0.10.0/smoothness/images/ui-icons_454545_256x240.png
|
357
|
-
- spec/foodcritic/coverage/assets/0.10.0/smoothness/images/ui-icons_888888_256x240.png
|
358
|
-
- spec/foodcritic/coverage/assets/0.10.0/smoothness/images/ui-icons_cd0a0a_256x240.png
|
359
|
-
- spec/foodcritic/coverage/index.html
|
360
338
|
- spec/functional/fc001_spec.rb
|
339
|
+
- spec/functional/fc007_spec.rb
|
361
340
|
- spec/functional/fc008_spec.rb
|
362
341
|
- spec/functional/fc011_spec.rb
|
363
342
|
- spec/functional/fc012_spec.rb
|
@@ -368,6 +347,8 @@ files:
|
|
368
347
|
- spec/functional/fc031_spec.rb
|
369
348
|
- spec/functional/fc042_spec.rb
|
370
349
|
- spec/functional/fc045_spec.rb
|
350
|
+
- spec/functional/fc049_spec.rb
|
351
|
+
- spec/functional/fc050_spec.rb
|
371
352
|
- spec/functional/fc052_spec.rb
|
372
353
|
- spec/functional/fc053_spec.rb
|
373
354
|
- spec/functional/fc055_spec.rb
|
@@ -390,6 +371,13 @@ files:
|
|
390
371
|
- spec/functional/fc076_spec.rb
|
391
372
|
- spec/functional/fc077_spec.rb
|
392
373
|
- spec/functional/fc078_spec.rb
|
374
|
+
- spec/functional/fc079_spec.rb
|
375
|
+
- spec/functional/fc080_spec.rb
|
376
|
+
- spec/functional/fc081_spec.rb
|
377
|
+
- spec/functional/fc082_spec.rb
|
378
|
+
- spec/functional/fc083_spec.rb
|
379
|
+
- spec/functional/fc084_spec.rb
|
380
|
+
- spec/functional/fc085_spec.rb
|
393
381
|
- spec/functional/root_aliases_spec.rb
|
394
382
|
- spec/regression/cookbooks.txt
|
395
383
|
- spec/regression/expected/activemq.txt
|
@@ -506,5 +494,5 @@ rubyforge_project:
|
|
506
494
|
rubygems_version: 2.6.11
|
507
495
|
signing_key:
|
508
496
|
specification_version: 4
|
509
|
-
summary: foodcritic-
|
497
|
+
summary: foodcritic-11.0.0
|
510
498
|
test_files: []
|