foodcritic 8.2.0 → 9.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 -5
- data/Gemfile +1 -1
- data/Rakefile +3 -3
- data/chef_dsl_metadata/chef_12.18.31.json +19738 -0
- data/features/007_check_for_undeclared_recipe_dependencies.feature +0 -1
- data/features/009_check_for_unrecognised_resource_attributes.feature +0 -1
- data/features/014_check_for_long_ruby_blocks.feature +1 -1
- data/features/015_check_for_definitions.feature +0 -1
- data/features/033_check_for_missing_template.feature +9 -0
- data/features/034_check_for_unused_template_variables.feature +0 -1
- data/features/041_check_raw_download.feature +1 -1
- data/features/051_check_for_template_partial_loops.feature +1 -4
- data/features/061_valid_cookbook_version_should_be_defined.feature +1 -1
- data/features/063_cookbook_incorrectly_depends_on_itself.feature +2 -2
- data/features/continuous_integration_support.feature +4 -4
- data/features/exclude_paths_to_lint.feature +0 -7
- data/features/step_definitions/cookbook_steps.rb +17 -5
- data/features/support/command_helpers.rb +2 -2
- data/lib/foodcritic/command_line.rb +8 -7
- data/lib/foodcritic/domain.rb +1 -1
- data/lib/foodcritic/linter.rb +1 -1
- data/lib/foodcritic/rules.rb +2 -0
- data/lib/foodcritic/version.rb +1 -1
- metadata +5 -4
@@ -28,7 +28,6 @@ Feature: Check for unrecognised resource attributes
|
|
28
28
|
Given a recipe that declares a user-defined resource
|
29
29
|
When I check the cookbook
|
30
30
|
Then the unrecognised attribute warning 009 should not be displayed
|
31
|
-
And no error should have occurred
|
32
31
|
|
33
32
|
Scenario: Resource declared with only a name attribute
|
34
33
|
Given a recipe that declares a resource with only a name attribute
|
@@ -27,4 +27,4 @@ Feature: Check for overly long ruby blocks
|
|
27
27
|
Scenario: Missing block attribute
|
28
28
|
Given a recipe that contains a ruby block without a block attribute
|
29
29
|
When I check the cookbook
|
30
|
-
Then
|
30
|
+
Then the long ruby block warning 014 should not be displayed
|
@@ -13,7 +13,6 @@ Feature: Check for use of definitions
|
|
13
13
|
Given a cookbook that does not contain a definition and has no definitions directory
|
14
14
|
When I check the cookbook
|
15
15
|
Then the definitions are deprecated warning 015 should not be displayed against the definition file
|
16
|
-
And no error should have occurred
|
17
16
|
|
18
17
|
Scenario: Cookbook does not contain a definition - directory
|
19
18
|
Given a cookbook that does not contain a definition and has a definitions directory
|
@@ -25,6 +25,15 @@ Feature: Check for missing template
|
|
25
25
|
| uses an inferred template | should not be displayed |
|
26
26
|
| uses a template from another cookbook | should not be displayed |
|
27
27
|
|
28
|
+
Scenario Outline: Template in the root of the templates directory
|
29
|
+
Given a cookbook recipe that refers to a template in the root of the templates directory
|
30
|
+
When I check the cookbook specifying <version> as the Chef version
|
31
|
+
Then the missing template warning 033 <warning>
|
32
|
+
Examples:
|
33
|
+
| version | warning |
|
34
|
+
| 11.18.12 | should be displayed |
|
35
|
+
| 12.0.0 | should not be displayed |
|
36
|
+
|
28
37
|
Scenario: Template within deploy resource
|
29
38
|
Given a cookbook recipe with a deploy resource that contains a template resource
|
30
39
|
When I check the cookbook
|
@@ -18,25 +18,22 @@ Feature: Check for template partial includes cycle
|
|
18
18
|
Given a template that includes a partial that includes the original template again
|
19
19
|
When I check the cookbook
|
20
20
|
Then the template partials loop indefinitely warning 051 should be displayed against the templates
|
21
|
-
And no error should have occurred
|
22
21
|
|
23
22
|
Scenario: Relative partial
|
24
23
|
Given a template that includes a partial with a relative subdirectory path
|
25
24
|
When I check the cookbook
|
26
25
|
Then the template partials loop indefinitely warning 051 should not be displayed against the templates
|
27
|
-
And no error should have occurred
|
28
26
|
|
29
27
|
Scenario: Missing partial
|
30
28
|
Given a template that includes a missing partial with a relative subdirectory path
|
31
29
|
When I check the cookbook
|
32
30
|
Then the template partials loop indefinitely warning 051 should not be displayed against the templates
|
33
|
-
And no error should have occurred
|
34
31
|
|
35
32
|
Scenario Outline: Template directory contains binary files
|
36
33
|
Given a template directory that contains a binary file <file> that is not valid UTF-8
|
37
34
|
When I check the cookbook
|
38
35
|
Then the template partials loop indefinitely warning 051 should not be displayed against the templates
|
39
|
-
|
36
|
+
|
40
37
|
Examples:
|
41
38
|
| file |
|
42
39
|
| .DS_Store |
|
@@ -2,7 +2,7 @@ Feature: Defined cookbook version should be valid
|
|
2
2
|
|
3
3
|
In order to ensure that recipe metadata is stable
|
4
4
|
As a developer
|
5
|
-
I want to identify metadata that does not define a valid
|
5
|
+
I want to identify metadata that does not define a valid version for the cookbook
|
6
6
|
|
7
7
|
Scenario: Metadata with the version keyword and a valid version
|
8
8
|
Given a cookbook with metadata that includes the version keyword and a valid version string
|
@@ -2,14 +2,14 @@ Feature: Check for metadata using suggests keyword
|
|
2
2
|
|
3
3
|
In order to avoid pathological depsolving issues
|
4
4
|
As a developer
|
5
|
-
I want to identify
|
5
|
+
I want to identify cookbooks that depend on themselves and remove that (unnecessary) dependency
|
6
6
|
|
7
7
|
Scenario: Metadata with self dependency
|
8
8
|
Given a cookbook with metadata that includes a self dependency
|
9
9
|
When I check the cookbook
|
10
10
|
Then the metadata with self dependency warning 063 should be shown against the metadata file
|
11
11
|
|
12
|
-
Scenario: Metadata without self
|
12
|
+
Scenario: Metadata without self dependency
|
13
13
|
Given a cookbook with metadata that does not include a self dependency
|
14
14
|
When I check the cookbook
|
15
15
|
Then the metadata with self dependency warning 063 should be not shown against the metadata file
|
@@ -17,13 +17,13 @@ Feature: Continuous Integration Support
|
|
17
17
|
|
18
18
|
Examples:
|
19
19
|
| cookbook_matches | tag_arguments | warnings_shown | build_status |
|
20
|
-
| FC002,FC003,FC004 | | FC002,FC003,FC004 |
|
21
|
-
| FC002,FC003,FC004 | -t style | FC002,FC004 |
|
22
|
-
| FC002,FC003,FC004 | -f
|
20
|
+
| FC002,FC003,FC004 | | FC002,FC003,FC004 | failed |
|
21
|
+
| FC002,FC003,FC004 | -t style | FC002,FC004 | failed |
|
22
|
+
| FC002,FC003,FC004 | -t style -f ~any | FC002,FC004 | successful |
|
23
23
|
| FC002,FC003,FC004 | -f FC005 | FC002,FC003,FC004 | successful |
|
24
24
|
| FC002,FC003,FC004 | -f FC003,FC004 | FC002,FC003,FC004 | failed |
|
25
25
|
| FC002,FC003,FC004 | --epic-fail FC003 | FC002,FC003,FC004 | failed |
|
26
|
-
| FC002,FC003 | -f any
|
26
|
+
| FC002,FC003 | -f ~any | FC002,FC003 | successful |
|
27
27
|
| FC002,FC003 | -f any -f ~FC014 | FC002,FC003 | failed |
|
28
28
|
| FC002,FC003 | -f any,~FC014 | FC002,FC003 | failed |
|
29
29
|
| FC002 | -f ~FC002 | FC002 | successful |
|
@@ -4,13 +4,6 @@ Feature: Exclude paths from being linted
|
|
4
4
|
As a developer
|
5
5
|
I want to be able to exclude some files or directories from the passed paths
|
6
6
|
|
7
|
-
Scenario: Don't exclude a non cookbook directory
|
8
|
-
Given a cookbook that has style problems
|
9
|
-
And unit tests under a top-level test directory
|
10
|
-
When I check the cookbook without excluding the test directory
|
11
|
-
Then warnings will be displayed against the tests
|
12
|
-
And the style warning 002 should be displayed
|
13
|
-
|
14
7
|
Scenario: Exclude a non cookbook directory
|
15
8
|
Given a cookbook that has style problems
|
16
9
|
And unit tests under a top-level test directory
|
@@ -261,12 +261,10 @@ Given /^a cookbook recipe that declares (a resource|multiple resources) nested i
|
|
261
261
|
#{conds.first} node['foo'] == 'bar'
|
262
262
|
service "apache" do
|
263
263
|
action :enable
|
264
|
-
#{
|
265
|
-
case condition_attribute
|
264
|
+
#{case condition_attribute
|
266
265
|
when /(only_if|not_if) block/ then "#{$1} #{blk}"
|
267
266
|
when /(only_if|not_if) string/ then "#{$1} #{str}"
|
268
|
-
end
|
269
|
-
}
|
267
|
+
end}
|
270
268
|
end
|
271
269
|
#{%q{service "httpd" do
|
272
270
|
action :enable
|
@@ -556,6 +554,20 @@ Given /^a cookbook recipe that refers to a (missing |local )?template( in a subd
|
|
556
554
|
end
|
557
555
|
end
|
558
556
|
|
557
|
+
Given /^a cookbook recipe that refers to a template in the root of the templates directory$/ do
|
558
|
+
write_recipe %q{
|
559
|
+
template "/tmp/config.conf" do
|
560
|
+
source "config.conf.erb"
|
561
|
+
variables({
|
562
|
+
:config_var => 'foo'
|
563
|
+
})
|
564
|
+
end
|
565
|
+
}
|
566
|
+
write_file "cookbooks/example/templates/config.conf.erb", %q{
|
567
|
+
<%= @config_var %>
|
568
|
+
}
|
569
|
+
end
|
570
|
+
|
559
571
|
Given "a cookbook recipe that refers to a template without an erb extension" do
|
560
572
|
write_recipe %q{
|
561
573
|
template '/etc/resolv.conf' do
|
@@ -2313,7 +2325,7 @@ end
|
|
2313
2325
|
|
2314
2326
|
Then "the usage text should include an option for specifying tags that will fail the build" do
|
2315
2327
|
expect_usage_option("f", "epic-fail TAGS",
|
2316
|
-
"Fail the build based on tags.
|
2328
|
+
"Fail the build based on tags. Default of 'any' to fail on all warnings.")
|
2317
2329
|
end
|
2318
2330
|
|
2319
2331
|
Then /^the warnings shown should be (.*)$/ do |warnings|
|
@@ -195,7 +195,7 @@ module FoodCritic
|
|
195
195
|
:description => "Only check against rules valid for this version of Chef." },
|
196
196
|
|
197
197
|
{ :short => "f", :long => "epic-fail TAGS",
|
198
|
-
:description => "Fail the build based on tags.
|
198
|
+
:description => "Fail the build based on tags. Default of 'any' to fail on all warnings." },
|
199
199
|
|
200
200
|
{ :short => "l", :long => "list",
|
201
201
|
:description => "List all enabled rules and their descriptions." },
|
@@ -225,7 +225,7 @@ module FoodCritic
|
|
225
225
|
:description => "Display the foodcritic version." },
|
226
226
|
|
227
227
|
{ :short => "X", :long => "exclude PATH",
|
228
|
-
:description => "Exclude path(s) from being linted." },
|
228
|
+
:description => "Exclude path(s) from being linted. PATH is relative to the cookbook, not an absolute PATH. Default test/**/*,spec/**/*,features/**/*" },
|
229
229
|
|
230
230
|
]
|
231
231
|
end
|
@@ -8,13 +8,14 @@ module FoodCritic
|
|
8
8
|
@args = args
|
9
9
|
@original_args = args.dup
|
10
10
|
@options = {
|
11
|
-
fail_tags: [],
|
11
|
+
fail_tags: ["any"],
|
12
12
|
tags: [],
|
13
13
|
include_rules: [],
|
14
14
|
cookbook_paths: [],
|
15
15
|
role_paths: [],
|
16
16
|
environment_paths: [],
|
17
|
-
exclude_paths: [],
|
17
|
+
exclude_paths: ["test/**/*", "spec/**/*", "features/**/*"],
|
18
|
+
progress: true,
|
18
19
|
}
|
19
20
|
@parser = OptionParser.new do |opts|
|
20
21
|
opts.banner = "foodcritic [cookbook_paths]"
|
@@ -28,7 +29,7 @@ module FoodCritic
|
|
28
29
|
@options[:list] = t
|
29
30
|
end
|
30
31
|
opts.on("-f", "--epic-fail TAGS",
|
31
|
-
"Fail the build based on tags.
|
32
|
+
"Fail the build based on tags. Default of 'any' to fail "\
|
32
33
|
"on all warnings.") do |t|
|
33
34
|
@options[:fail_tags] << t
|
34
35
|
end
|
@@ -59,9 +60,9 @@ module FoodCritic
|
|
59
60
|
"foodcritic/rules/**/*.rb") do |g|
|
60
61
|
@options[:search_gems] = true
|
61
62
|
end
|
62
|
-
opts.on("-P", "--progress",
|
63
|
-
"Show progress of files being checked") do
|
64
|
-
@options[:progress] =
|
63
|
+
opts.on("-P", "--[no-]progress",
|
64
|
+
"Show progress of files being checked. default: true") do |q|
|
65
|
+
@options[:progress] = q
|
65
66
|
end
|
66
67
|
opts.on("-R", "--role-path PATH",
|
67
68
|
"Role path(s) to check.") do |r|
|
@@ -76,7 +77,7 @@ module FoodCritic
|
|
76
77
|
@options[:version] = true
|
77
78
|
end
|
78
79
|
opts.on("-X", "--exclude PATH",
|
79
|
-
"Exclude path(s) from being linted. PATH is relative to the cookbook, not an absolute PATH") do |e|
|
80
|
+
"Exclude path(s) from being linted. PATH is relative to the cookbook, not an absolute PATH. Default test/**/*,spec/**/*,features/**/*") do |e|
|
80
81
|
options[:exclude_paths] << e
|
81
82
|
end
|
82
83
|
end
|
data/lib/foodcritic/domain.rb
CHANGED
data/lib/foodcritic/linter.rb
CHANGED
@@ -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 = "12.
|
12
|
+
DEFAULT_CHEF_VERSION = "12.18.31"
|
13
13
|
attr_reader :chef_version
|
14
14
|
|
15
15
|
# Perform a lint check. This method is intended for use by the command-line
|
data/lib/foodcritic/rules.rb
CHANGED
@@ -502,6 +502,8 @@ rule "FC033", "Missing template" do
|
|
502
502
|
relative_path = []
|
503
503
|
Pathname.new(path).ascend do |template_path|
|
504
504
|
relative_path << template_path.basename
|
505
|
+
break if gem_version(chef_version) >= gem_version("12.0.0") &&
|
506
|
+
template_path.dirname.basename.to_s == "templates"
|
505
507
|
break if template_path.dirname.dirname.basename.to_s == "templates"
|
506
508
|
end
|
507
509
|
File.join(relative_path.reverse) == resource[:file]
|
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:
|
4
|
+
version: 9.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-01-
|
11
|
+
date: 2017-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cucumber-core
|
@@ -141,6 +141,7 @@ files:
|
|
141
141
|
- chef_dsl_metadata/chef_12.15.19.json
|
142
142
|
- chef_dsl_metadata/chef_12.16.42.json
|
143
143
|
- chef_dsl_metadata/chef_12.17.44.json
|
144
|
+
- chef_dsl_metadata/chef_12.18.31.json
|
144
145
|
- chef_dsl_metadata/chef_12.2.1.json
|
145
146
|
- chef_dsl_metadata/chef_12.3.0.json
|
146
147
|
- chef_dsl_metadata/chef_12.4.0.json
|
@@ -280,8 +281,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
280
281
|
version: '0'
|
281
282
|
requirements: []
|
282
283
|
rubyforge_project:
|
283
|
-
rubygems_version: 2.
|
284
|
+
rubygems_version: 2.6.10
|
284
285
|
signing_key:
|
285
286
|
specification_version: 4
|
286
|
-
summary: foodcritic-
|
287
|
+
summary: foodcritic-9.0.0
|
287
288
|
test_files: []
|