foodcritic 3.0.1 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.md +16 -0
- data/features/022_check_for_dodgy_conditions_within_loop.feature +5 -0
- data/features/051_check_for_template_partial_loops.feature +10 -0
- data/features/step_definitions/cookbook_steps.rb +25 -0
- data/lib/foodcritic/api.rb +5 -1
- data/lib/foodcritic/rules.rb +2 -0
- data/lib/foodcritic/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YWNiNzYyZTkwODc2YjJiZDdmMTVlMzk4OTQxZjQxYThhMWZhMGY1Nw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MmFhODIzYTlhYWZhMjI3MDlmMGE4ZWU1NmEwNTkwNDc0NTJiMDEzOA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YjYxNjgwOWNkYTU4ZmQ2MmU4YzRjODc4OWM0NWEyN2MzMTQwYmViNjZiZmMw
|
10
|
+
OWE2MWNjOTI0ZjA3NTQyMTQyYmJhNzMwZjhlOTkxMDFiODM2YzI4ZDhkNTYx
|
11
|
+
ZDhhMDI5MjY3YzQ2YmRjMGY5OTRjNTk1NTcxNmE5MzA3NjIyZGY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ODlhNjFlNjBiMjc5YTRjYjgxNWFhNDgwM2Y2NmFjNDYxNTZlMzFjOTNmYzYx
|
14
|
+
MTIyOGJlMDQ4NWQ5ZTNjNzNkODIwMzViNTVhMjk1MTllOWYwYWU4OWNhMGEw
|
15
|
+
NjIyNDBhMGFjN2NiOTBjMGU5Y2NlNTU3OTI5ZGQ2MmM4MTMyZDk=
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
## 3.0.2 (5th October, 2013)
|
2
|
+
|
3
|
+
Bugfixes:
|
4
|
+
|
5
|
+
- [FC051: Template partials loop indefinitely](http://foodcritic.io/#FC051)
|
6
|
+
can cause foodcritic to exit with an error on encountering a file that
|
7
|
+
cannot be read as UTF-8. We now explicitly exclude `.DS_Store` and `*.swp`
|
8
|
+
as a workaround
|
9
|
+
([related issue](https://github.com/acrmp/foodcritic/issues/172)). Thanks
|
10
|
+
@tmatilai, @claco.
|
11
|
+
- [FC022: Resource condition within loop may not behave as expected](http://foodcritic.io/#FC022)
|
12
|
+
would warn incorrectly against loops where the block accepts more than one
|
13
|
+
argument
|
14
|
+
([related issue](https://github.com/acrmp/foodcritic/issues/69)). Thanks
|
15
|
+
@Ips1975, @jaymzh.
|
16
|
+
|
1
17
|
## 3.0.1 (25th September, 2013)
|
2
18
|
|
3
19
|
Other:
|
@@ -26,3 +26,8 @@ Feature: Check for dodgy resource conditions within a loop
|
|
26
26
|
| "feed_pet" | only_if "[ -f \"/tmp/#{pet_name}\" ]" | should |
|
27
27
|
| "feed_pet_#{pet_name}" | not_if "[ -f \"/tmp/#{pet_name}\" ]" | should not |
|
28
28
|
| pet_name | not_if "[ -f \"/tmp/#{pet_name}\" ]" | should not |
|
29
|
+
|
30
|
+
Scenario: Resource within a multi-arg block
|
31
|
+
Given a resource declared with a guard within a loop with multiple block arguments
|
32
|
+
When I check the cookbook
|
33
|
+
Then the dodgy resource condition warning 022 should not be shown
|
@@ -19,3 +19,13 @@ Feature: Check for template partial includes cycle
|
|
19
19
|
When I check the cookbook
|
20
20
|
Then the template partials loop indefinitely warning 051 should be displayed against the templates
|
21
21
|
And no error should have occurred
|
22
|
+
|
23
|
+
Scenario Outline: Template directory contains binary files
|
24
|
+
Given a template directory that contains a binary file <file> that is not valid UTF-8
|
25
|
+
When I check the cookbook
|
26
|
+
Then the template partials loop indefinitely warning 051 should not be displayed against the templates
|
27
|
+
And no error should have occurred
|
28
|
+
Examples:
|
29
|
+
| file |
|
30
|
+
| .DS_Store |
|
31
|
+
| foo.erb.swp |
|
@@ -1423,6 +1423,20 @@ Given 'a recipe that declares multiple resources of the same type of which one h
|
|
1423
1423
|
}
|
1424
1424
|
end
|
1425
1425
|
|
1426
|
+
Given 'a resource declared with a guard within a loop with multiple block arguments' do
|
1427
|
+
write_recipe %q{
|
1428
|
+
{
|
1429
|
+
'foo' => 'bar',
|
1430
|
+
'baz' => 'bing',
|
1431
|
+
}.each do |foo, bar|
|
1432
|
+
package bar do
|
1433
|
+
not_if { node['foo'] == foo }
|
1434
|
+
action :install
|
1435
|
+
end
|
1436
|
+
end
|
1437
|
+
}
|
1438
|
+
end
|
1439
|
+
|
1426
1440
|
Given /^a rule that (declares|does not declare) a version constraint(?: of ([^ ]+)? to ([^ ]+)?)?$/ do |constraint, from, to|
|
1427
1441
|
if from || to
|
1428
1442
|
rule_with_version_constraint(from, to)
|
@@ -1624,6 +1638,13 @@ Given /^a ruby role that triggers FC049 with comment (.*)$/ do |comment|
|
|
1624
1638
|
}.strip
|
1625
1639
|
end
|
1626
1640
|
|
1641
|
+
Given /^a template directory that contains a binary file (.*) that is not valid UTF-8$/ do |filename|
|
1642
|
+
template_dir = 'cookbooks/example/templates/default'
|
1643
|
+
write_recipe ''
|
1644
|
+
write_file "#{template_dir}/innocent_template.erb", '<%= hello %>'
|
1645
|
+
File.open("#{current_dir}/#{template_dir}/#{filename}", 'wb'){|f| f.putc(0x93)}
|
1646
|
+
end
|
1647
|
+
|
1627
1648
|
Given 'each role directory has a role with a name that does not match the containing file name' do
|
1628
1649
|
role(:dir => 'roles1', :role_name => '"apache"', :file_name => 'webserver.rb')
|
1629
1650
|
role(:dir => 'roles2', :role_name => '"postgresql"', :file_name => 'database.rb')
|
@@ -1987,6 +2008,10 @@ Then /^the debugger breakpoint warning 030 should be (not )?shown against the (.
|
|
1987
2008
|
expect_warning('FC030', :line => nil, :expect_warning => should_not.nil?, :file => filename)
|
1988
2009
|
end
|
1989
2010
|
|
2011
|
+
Then 'the dodgy resource condition warning 022 should not be shown' do
|
2012
|
+
expect_warning('FC022', {:line => nil, :expect_warning => false})
|
2013
|
+
end
|
2014
|
+
|
1990
2015
|
Then /^the warning (\d+) should be (valid|invalid)$/ do |code, valid|
|
1991
2016
|
code = "FC#{code}"
|
1992
2017
|
valid == 'valid' ? expect_no_warning(code) : expect_warning(code)
|
data/lib/foodcritic/api.rb
CHANGED
@@ -349,7 +349,11 @@ module FoodCritic
|
|
349
349
|
# Templates in the current cookbook
|
350
350
|
def template_paths(recipe_path)
|
351
351
|
Dir.glob(Pathname.new(recipe_path).dirname.dirname + 'templates' +
|
352
|
-
'**/*', File::FNM_DOTMATCH).select
|
352
|
+
'**/*', File::FNM_DOTMATCH).select do |path|
|
353
|
+
File.file?(path)
|
354
|
+
end.reject do |path|
|
355
|
+
File.basename(path) == '.DS_Store' || File.extname(path) == '.swp'
|
356
|
+
end
|
353
357
|
end
|
354
358
|
|
355
359
|
private
|
data/lib/foodcritic/rules.rb
CHANGED
@@ -296,6 +296,8 @@ rule "FC022", "Resource condition within loop may not behave as expected" do
|
|
296
296
|
ast.xpath("//call[ident/@value='each']/../do_block").map do |loop|
|
297
297
|
block_vars = loop.xpath("block_var/params/child::*").map do |n|
|
298
298
|
n.name.sub(/^ident/, '')
|
299
|
+
end + loop.xpath("block_var/params/child::*/descendant::ident").map do |v|
|
300
|
+
v['value']
|
299
301
|
end
|
300
302
|
find_resources(loop).map do |resource|
|
301
303
|
# if any of the parameters to the block are used in a condition then we
|
data/lib/foodcritic/version.rb
CHANGED
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: 3.0.
|
4
|
+
version: 3.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Crump
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gherkin
|
@@ -260,5 +260,5 @@ rubyforge_project:
|
|
260
260
|
rubygems_version: 2.0.7
|
261
261
|
signing_key:
|
262
262
|
specification_version: 4
|
263
|
-
summary: foodcritic-3.0.
|
263
|
+
summary: foodcritic-3.0.2
|
264
264
|
test_files: []
|