foodcritic 10.2.2 → 10.3.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 +24 -2
- data/Gemfile +2 -1
- data/README.md +7 -1
- data/Rakefile +55 -35
- data/bin/foodcritic +1 -7
- data/features/024_check_for_missing_platforms.feature +3 -4
- data/features/continuous_integration_support.feature +2 -2
- data/features/step_definitions/cookbook_steps.rb +24 -285
- data/features/support/command_helpers.rb +3 -0
- data/foodcritic.gemspec +12 -6
- data/lib/foodcritic/api.rb +14 -2
- data/lib/foodcritic/command_line.rb +8 -0
- data/lib/foodcritic/linter.rb +1 -1
- data/lib/foodcritic/output.rb +17 -3
- data/lib/foodcritic/rules/fc008.rb +8 -6
- data/lib/foodcritic/rules/fc024.rb +1 -1
- data/lib/foodcritic/rules/fc045.rb +1 -8
- data/lib/foodcritic/rules/fc068.rb +1 -1
- data/lib/foodcritic/rules/fc069.rb +365 -0
- data/lib/foodcritic/rules/fc070.rb +63 -0
- data/lib/foodcritic/rules/fc071.rb +6 -0
- data/lib/foodcritic/rules/fc072.rb +6 -0
- data/lib/foodcritic/rules/fc073.rb +17 -0
- data/lib/foodcritic/rules/fc074.rb +10 -0
- data/lib/foodcritic/rules/fc075.rb +9 -0
- data/lib/foodcritic/version.rb +1 -1
- data/spec/functional/fc001_spec.rb +67 -0
- data/spec/functional/fc008_spec.rb +33 -0
- data/spec/functional/fc011_spec.rb +20 -0
- data/spec/functional/fc012_spec.rb +20 -0
- data/spec/functional/fc016_spec.rb +48 -0
- data/spec/functional/fc028_spec.rb +48 -0
- data/spec/functional/fc029_spec.rb +33 -0
- data/spec/functional/fc031_spec.rb +14 -0
- data/spec/functional/fc042_spec.rb +13 -0
- data/spec/functional/fc045_spec.rb +18 -0
- data/spec/functional/fc052_spec.rb +13 -0
- data/spec/functional/fc053_spec.rb +13 -0
- data/spec/functional/fc055_spec.rb +18 -0
- data/spec/functional/fc056_spec.rb +18 -0
- data/spec/functional/fc061_spec.rb +48 -0
- data/spec/functional/fc062_spec.rb +13 -0
- data/spec/functional/fc063_spec.rb +18 -0
- data/spec/functional/fc064_spec.rb +13 -0
- data/spec/functional/fc065_spec.rb +13 -0
- data/spec/functional/fc066_spec.rb +13 -0
- data/spec/functional/fc067_spec.rb +13 -0
- data/spec/functional/fc068_spec.rb +13 -0
- data/spec/functional/fc069_spec.rb +23 -0
- data/spec/functional/fc070_spec.rb +38 -0
- data/spec/functional/fc071_spec.rb +14 -0
- data/spec/functional/fc072_spec.rb +13 -0
- data/spec/functional/fc073_spec.rb +56 -0
- data/spec/functional/fc074_spec.rb +39 -0
- data/spec/functional/fc075_spec.rb +41 -0
- data/spec/functional/root_aliases_spec.rb +13 -0
- data/spec/regression/cookbooks.txt +0 -2
- data/spec/regression/expected/activemq.txt +5 -0
- data/spec/regression/expected/apparmor.txt +8 -0
- data/spec/regression/expected/apt.txt +12 -0
- data/spec/regression/expected/aws.txt +13 -0
- data/spec/regression/expected/bluepill.txt +6 -0
- data/spec/regression/expected/boost.txt +6 -0
- data/spec/regression/expected/build-essential.txt +6 -0
- data/spec/regression/expected/chef-client.txt +13 -0
- data/spec/regression/expected/chef-server.txt +12 -0
- data/spec/regression/expected/chef.txt +36 -0
- data/spec/regression/expected/chef_handler.txt +7 -0
- data/spec/regression/expected/cron.txt +7 -0
- data/spec/regression/expected/database.txt +13 -0
- data/spec/regression/expected/dmg.txt +12 -0
- data/spec/regression/expected/drbd.txt +25 -0
- data/spec/regression/expected/dynect.txt +29 -0
- data/spec/regression/expected/erlang.txt +4 -0
- data/spec/regression/expected/fail2ban.txt +4 -0
- data/spec/regression/expected/firewall.txt +12 -0
- data/spec/regression/expected/gecode.txt +8 -0
- data/spec/regression/expected/gems.txt +31 -0
- data/spec/regression/expected/gunicorn.txt +9 -0
- data/spec/regression/expected/heartbeat.txt +8 -0
- data/spec/regression/expected/homebrew.txt +8 -0
- data/spec/regression/expected/iis.txt +30 -0
- data/spec/regression/expected/iptables.txt +8 -0
- data/spec/regression/expected/jetty.txt +11 -0
- data/spec/regression/expected/jpackage.txt +8 -0
- data/spec/regression/expected/keepalived.txt +4 -0
- data/spec/regression/expected/kickstart.txt +14 -0
- data/spec/regression/expected/logwatch.txt +4 -0
- data/spec/regression/expected/lvm.txt +12 -0
- data/spec/regression/expected/maradns.txt +13 -0
- data/spec/regression/expected/maven.txt +9 -0
- data/spec/regression/expected/memcached.txt +30 -0
- data/spec/regression/expected/motd-tail.txt +4 -0
- data/spec/regression/expected/mysql.txt +12 -0
- data/spec/regression/expected/ohai.txt +6 -0
- data/spec/regression/expected/openldap.txt +10 -0
- data/spec/regression/expected/openssh.txt +4 -0
- data/spec/regression/expected/openssl.txt +5 -0
- data/spec/regression/expected/partial_search.txt +5 -0
- data/spec/regression/expected/passenger_apache2.txt +29 -0
- data/spec/regression/expected/perl.txt +11 -0
- data/spec/regression/expected/php.txt +9 -0
- data/spec/regression/expected/postfix.txt +6 -0
- data/spec/regression/expected/powershell.txt +8 -0
- data/spec/regression/expected/resolver.txt +6 -0
- data/spec/regression/expected/rsync.txt +10 -0
- data/spec/regression/expected/rsyslog.txt +8 -0
- data/spec/regression/expected/sql_server.txt +4 -0
- data/spec/regression/expected/sqlite.txt +4 -0
- data/spec/regression/expected/ssh_known_hosts.txt +5 -0
- data/spec/regression/expected/stompserver.txt +5 -0
- data/spec/regression/expected/subversion.txt +5 -0
- data/spec/regression/expected/sudo.txt +8 -0
- data/spec/regression/expected/tftp.txt +5 -0
- data/spec/regression/expected/tomcat.txt +8 -0
- data/spec/regression/expected/transmission.txt +10 -0
- data/spec/regression/expected/ubuntu.txt +4 -0
- data/spec/regression/expected/ufw.txt +9 -0
- data/spec/regression/expected/unicorn.txt +6 -0
- data/spec/regression/expected/users.txt +7 -0
- data/spec/regression/expected/vim.txt +6 -0
- data/spec/regression/expected/webpi.txt +7 -0
- data/spec/regression/expected/whitelist-node-attrs.txt +6 -0
- data/spec/regression/expected/windows.txt +57 -0
- data/spec/regression/expected/wix.txt +4 -0
- data/spec/regression/expected/xfs.txt +4 -0
- data/spec/regression/expected/xml.txt +4 -0
- data/spec/regression/expected/yum.txt +17 -0
- data/spec/regression/expected/zlib.txt +4 -0
- data/spec/regression/expected/zsh.txt +4 -0
- data/spec/regression/regression_spec.rb +16 -10
- data/spec/spec_helper.rb +115 -10
- data/spec/{foodcritic → unit}/api_spec.rb +549 -593
- data/spec/{foodcritic → unit}/chef_spec.rb +15 -15
- data/spec/unit/command_line_spec.rb +122 -0
- data/spec/{foodcritic → unit}/domain_spec.rb +12 -12
- data/spec/{foodcritic → unit}/linter_spec.rb +20 -35
- data/spec/{foodcritic → unit}/template_spec.rb +13 -13
- metadata +161 -33
- data/features/001_check_node_access.feature +0 -60
- data/features/008_check_for_boilerplate_metadata.feature +0 -25
- data/features/011_check_for_markdown_readme.feature +0 -20
- data/features/012_check_for_deprecated_readme_format.feature +0 -20
- data/features/016_check_for_no_lwrp_default_action.feature +0 -25
- data/features/028_check_for_incorrect_platform_method.feature +0 -20
- data/features/029_check_for_no_leading_cookbook_name.feature +0 -18
- data/features/031_check_for_metadata_existence.feature +0 -15
- data/features/042_check_for_deprecated_require_recipe.feature +0 -15
- data/features/045_check_for_cookbook_name_in_metadata.feature +0 -20
- data/features/052_check_for_metadata_using_suggests_keyword.feature +0 -15
- data/features/053_check_for_metadata_using_recommends_keyword.feature +0 -15
- data/features/055_check_for_no_maintainer.feature +0 -25
- data/features/056_check_for_no_maintainer_email.feature +0 -25
- data/features/061_valid_cookbook_version_should_be_defined.feature +0 -55
- data/features/062_cookbook_should_have_cookbook_version.feature +0 -50
- data/features/063_cookbook_incorrectly_depends_on_itself.feature +0 -15
- data/features/064_check_for_no_issues_url.feature +0 -25
- data/features/065_check_for_no_source_url.feature +0 -25
- data/features/066_check_for_no_chef_version_metadata.feature +0 -20
- data/features/067_check_for_no_supports_metadata.feature +0 -20
- data/features/068_check_for_no_license_metadata.feature +0 -20
- data/spec/foodcritic/command_line_spec.rb +0 -74
- data/spec/regression/expected-output.txt +0 -355
- data/spec/regression_helpers.rb +0 -37
@@ -0,0 +1,13 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "FC052" do
|
4
|
+
context "with a cookbook with a metadata file that does contain the suggests keyword" do
|
5
|
+
metadata_file "suggests 'runit'"
|
6
|
+
it { is_expected.to violate_rule("FC052") }
|
7
|
+
end
|
8
|
+
|
9
|
+
context "with a cookbook with a metadata file that does not contain the suggests keyword" do
|
10
|
+
metadata_file
|
11
|
+
it { is_expected.to_not violate_rule("FC052") }
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "FC053" do
|
4
|
+
context "with a cookbook with a metadata file that does contain the recommends keyword" do
|
5
|
+
metadata_file "recommends 'runit'"
|
6
|
+
it { is_expected.to violate_rule("FC053") }
|
7
|
+
end
|
8
|
+
|
9
|
+
context "with a cookbook with a metadata file that does not contain the recommends keyword" do
|
10
|
+
metadata_file
|
11
|
+
it { is_expected.to_not violate_rule("FC053") }
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "FC055" do
|
4
|
+
context "with a cookbook with a metadata file that does not specify a maintainer" do
|
5
|
+
metadata_file "name 'my_cookbook'"
|
6
|
+
it { is_expected.to violate_rule("FC055") }
|
7
|
+
end
|
8
|
+
|
9
|
+
context "with a cookbook with a metadata file that specifies a maintainer" do
|
10
|
+
metadata_file "maintainer 'Some Person'"
|
11
|
+
it { is_expected.to_not violate_rule("FC055") }
|
12
|
+
end
|
13
|
+
|
14
|
+
context "with a cookbook with a metadata file that specifies a maintainer as an expression" do
|
15
|
+
metadata_file("maintainer an(expression)")
|
16
|
+
it { is_expected.to_not violate_rule("FC055") }
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "FC056" do
|
4
|
+
context "with a cookbook with a metadata file that does not specify a maintainer_email" do
|
5
|
+
metadata_file
|
6
|
+
it { is_expected.to violate_rule("FC056") }
|
7
|
+
end
|
8
|
+
|
9
|
+
context "with a cookbook with a metadata file that specifies a maintainer_email" do
|
10
|
+
metadata_file "maintainer_email 'foo@example.com'"
|
11
|
+
it { is_expected.to_not violate_rule("FC056") }
|
12
|
+
end
|
13
|
+
|
14
|
+
context "with a cookbook with a metadata file that specifies a maintainer_email as an expression" do
|
15
|
+
metadata_file("maintainer_email an(expression)")
|
16
|
+
it { is_expected.to_not violate_rule("FC056") }
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "FC061" do
|
4
|
+
context "with a cookbook with metadata that includes the version keyword and a valid version string" do
|
5
|
+
metadata_file("version '1.2.3'")
|
6
|
+
it { is_expected.not_to violate_rule("FC061") }
|
7
|
+
end
|
8
|
+
|
9
|
+
context "with a cookbook with metadata that includes the version keyword and a valid version string with double quotes" do
|
10
|
+
metadata_file('version "1.2.3"')
|
11
|
+
it { is_expected.not_to violate_rule("FC061") }
|
12
|
+
end
|
13
|
+
|
14
|
+
context "with a cookbook with metadata that includes the version keyword and a valid x.y version string" do
|
15
|
+
metadata_file("version '1.2'")
|
16
|
+
it { is_expected.not_to violate_rule("FC061") }
|
17
|
+
end
|
18
|
+
|
19
|
+
context "with a cookbook with metadata that does not include a version keyword" do
|
20
|
+
metadata_file("name 'something'")
|
21
|
+
it { is_expected.not_to violate_rule("FC061") }
|
22
|
+
end
|
23
|
+
|
24
|
+
context "with a cookbook with metadata that includes the version keyword and an invalid version string" do
|
25
|
+
metadata_file("version 'one'")
|
26
|
+
it { is_expected.to violate_rule("FC061") }
|
27
|
+
end
|
28
|
+
|
29
|
+
context "with a cookbook metadata that includes the version keyword and an invalid single digit version string" do
|
30
|
+
metadata_file("version '1'")
|
31
|
+
it { is_expected.to violate_rule("FC061") }
|
32
|
+
end
|
33
|
+
|
34
|
+
context "with a cookbook metadata that includes the version keyword and an invalid four digit version string" do
|
35
|
+
metadata_file("version '1.2.3.4'")
|
36
|
+
it { is_expected.to violate_rule("FC061") }
|
37
|
+
end
|
38
|
+
|
39
|
+
context "with a cookbook metadata that includes the version keyword that uses string interpolation" do
|
40
|
+
metadata_file('patch = 3\nversion "1.2.#{patch}"')
|
41
|
+
it { is_expected.not_to violate_rule("FC061") }
|
42
|
+
end
|
43
|
+
|
44
|
+
context "with a cookbook metadata that includes the version keyword that is not a string literal" do
|
45
|
+
metadata_file('v = "1.2.3"\nversion v')
|
46
|
+
it { is_expected.not_to violate_rule("FC061") }
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "FC062" do
|
4
|
+
context "with a cookbook with metadata that includes the version keyword and a valid version string" do
|
5
|
+
metadata_file("version '1.2.3'")
|
6
|
+
it { is_expected.not_to violate_rule("FC062") }
|
7
|
+
end
|
8
|
+
|
9
|
+
context "with a cookbook with metadata that does not include a version keyword" do
|
10
|
+
metadata_file
|
11
|
+
it { is_expected.to violate_rule("FC062") }
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "FC063" do
|
4
|
+
context "with a cookbook with a metadata file that depends on itself" do
|
5
|
+
metadata_file "name 'something'\ndepends 'something'"
|
6
|
+
it { is_expected.to violate_rule("FC063") }
|
7
|
+
end
|
8
|
+
|
9
|
+
context "with a cookbook with a metadata file that depends on a cookbook, but not itself" do
|
10
|
+
metadata_file "name 'something'\ndepends 'another_thing'"
|
11
|
+
it { is_expected.to_not violate_rule("FC063") }
|
12
|
+
end
|
13
|
+
|
14
|
+
context "with a cookbook with a metadata file that doesn't depend on any cookbooks" do
|
15
|
+
metadata_file "name 'something'"
|
16
|
+
it { is_expected.to_not violate_rule("FC063") }
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "FC064" do
|
4
|
+
context "with a cookbook with a metadata file that does not specify issues_url" do
|
5
|
+
metadata_file
|
6
|
+
it { is_expected.to violate_rule("FC064") }
|
7
|
+
end
|
8
|
+
|
9
|
+
context "with a cookbook with a metadata file that specifies a issues_url" do
|
10
|
+
metadata_file "issues_url 'http://wwww.something.com/'"
|
11
|
+
it { is_expected.to_not violate_rule("FC064") }
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "FC065" do
|
4
|
+
context "with a cookbook with a metadata file that does not specify source_url" do
|
5
|
+
metadata_file
|
6
|
+
it { is_expected.to violate_rule("FC065") }
|
7
|
+
end
|
8
|
+
|
9
|
+
context "with a cookbook with a metadata file that specifies a source_url" do
|
10
|
+
metadata_file "source_url 'http://wwww.something.com/'"
|
11
|
+
it { is_expected.to_not violate_rule("FC065") }
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "FC066" do
|
4
|
+
context "with a cookbook with a metadata file that does not specify chef_version" do
|
5
|
+
metadata_file "name 'my_cookbook'"
|
6
|
+
it { is_expected.to violate_rule("FC066") }
|
7
|
+
end
|
8
|
+
|
9
|
+
context "with a cookbook with a metadata file that specifies a chef_version" do
|
10
|
+
metadata_file "chef_version '>= 12.1'"
|
11
|
+
it { is_expected.to_not violate_rule("FC066") }
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "FC067" do
|
4
|
+
context "with a cookbook with a metadata file that does not specify supports" do
|
5
|
+
metadata_file "name 'my_cookbook'"
|
6
|
+
it { is_expected.to violate_rule("FC067") }
|
7
|
+
end
|
8
|
+
|
9
|
+
context "with a cookbook with a metadata file that specifies a supported platform (anything)" do
|
10
|
+
metadata_file "supports 'some_os'"
|
11
|
+
it { is_expected.to_not violate_rule("FC067") }
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "FC068" do
|
4
|
+
context "with a cookbook with a metadata file that does not specify the license" do
|
5
|
+
metadata_file "name 'my_cookbook'"
|
6
|
+
it { is_expected.to violate_rule("FC068") }
|
7
|
+
end
|
8
|
+
|
9
|
+
context "with a cookbook with a metadata file that specifies a license (anything)" do
|
10
|
+
metadata_file "license 'My Super Cool License'"
|
11
|
+
it { is_expected.to_not violate_rule("FC068") }
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "FC069" do
|
4
|
+
context "with a cookbook with a metadata file that specifies a license generated by knife cookbook create" do
|
5
|
+
metadata_file "license 'Apache 2.0'"
|
6
|
+
it { is_expected.to violate_rule("FC069") }
|
7
|
+
end
|
8
|
+
|
9
|
+
context "with a cookbook with a metadata file that specifies a license generated by chef generate cookbook" do
|
10
|
+
metadata_file "license 'apache_2'"
|
11
|
+
it { is_expected.to violate_rule("FC069") }
|
12
|
+
end
|
13
|
+
|
14
|
+
context "with a cookbook with a metadata file that specifies a valid SPDX license" do
|
15
|
+
metadata_file "license 'Apache-2.0'"
|
16
|
+
it { is_expected.to_not violate_rule("FC069") }
|
17
|
+
end
|
18
|
+
|
19
|
+
context "with a cookbook with a metadata file that specifies ChefDK's non-SPDX all rights reserved string" do
|
20
|
+
metadata_file "license 'All Rights Reserved'"
|
21
|
+
it { is_expected.to_not violate_rule("FC069") }
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "FC070" do
|
4
|
+
context "with a cookbook with a metadata file specifying a single valid supports statement" do
|
5
|
+
metadata_file "supports 'ubuntu'"
|
6
|
+
it { is_expected.to_not violate_rule("FC070") }
|
7
|
+
end
|
8
|
+
|
9
|
+
context "with a cookbook with a metadata file specifying multiple valid supports statements" do
|
10
|
+
metadata_file "%w(ubuntu debian fedora).each do |plat|\nsupports plat\nend"
|
11
|
+
it { is_expected.to_not violate_rule("FC070") }
|
12
|
+
end
|
13
|
+
|
14
|
+
context "with a cookbook with a metadata file specifying a single invalid supports statement" do
|
15
|
+
metadata_file "supports 'aws'"
|
16
|
+
it { is_expected.to violate_rule("FC070") }
|
17
|
+
end
|
18
|
+
|
19
|
+
context "with a cookbook with a metadata file specifying multiple invalid supports statements" do
|
20
|
+
metadata_file "%w(aws oel rhel).each do |plat|\nsupports plat\nend"
|
21
|
+
it { is_expected.to violate_rule("FC070") }
|
22
|
+
end
|
23
|
+
|
24
|
+
context "with a cookbook with a metadata file specifying a mix of valid and invalid supports statements" do
|
25
|
+
metadata_file "%w(aws oracle scientific).each do |plat|\nsupports plat\nend"
|
26
|
+
it { is_expected.to violate_rule("FC070") }
|
27
|
+
end
|
28
|
+
|
29
|
+
context "with a cookbook with a metadata file specifying a valid supports platform, but uppercase" do
|
30
|
+
metadata_file "supports 'UBUNTU'"
|
31
|
+
it { is_expected.to violate_rule("FC070") }
|
32
|
+
end
|
33
|
+
|
34
|
+
context "with a cookbook with a metadata file specifying a valid supports platform, but with a version string" do
|
35
|
+
metadata_file "supports 'ubuntu >= 16.04'"
|
36
|
+
it { is_expected.to violate_rule("FC070") }
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "FC071" do
|
4
|
+
context "with a cookbook with a LICENSE file" do
|
5
|
+
metadata_file "name 'mycookbook'"
|
6
|
+
file("LICENSE")
|
7
|
+
it { is_expected.not_to violate_rule("FC071") }
|
8
|
+
end
|
9
|
+
|
10
|
+
context "with a cookbook without a LICENSE file" do
|
11
|
+
metadata_file "name 'mycookbook'"
|
12
|
+
it { is_expected.to violate_rule("FC071") }
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "FC072" do
|
4
|
+
context "with a cookbook with a metadata file that contains an attribute keyword" do
|
5
|
+
metadata_file "attribute 'something/something',\n display_name: 'something tuneable',\n description: 'This tunes something',\n default: 'none'"
|
6
|
+
it { is_expected.to violate_rule("FC072") }
|
7
|
+
end
|
8
|
+
|
9
|
+
context "with a cookbook with a metadata file that doesn't contain an attribute keyword" do
|
10
|
+
metadata_file
|
11
|
+
it { is_expected.not_to violate_rule("FC072") }
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "FC073" do
|
4
|
+
context "with an empty cookbook" do
|
5
|
+
metadata_file
|
6
|
+
it { is_expected.to_not violate_rule("FC073") }
|
7
|
+
end
|
8
|
+
|
9
|
+
context "with only attributes/default.rb" do
|
10
|
+
metadata_file
|
11
|
+
attributes_file
|
12
|
+
it { is_expected.to_not violate_rule("FC073") }
|
13
|
+
end
|
14
|
+
|
15
|
+
context "with only attributes.rb" do
|
16
|
+
metadata_file
|
17
|
+
file "attributes.rb"
|
18
|
+
it { is_expected.to_not violate_rule("FC073") }
|
19
|
+
end
|
20
|
+
|
21
|
+
context "with both attributes.rb and attributes/default.rb" do
|
22
|
+
metadata_file
|
23
|
+
file "attributes.rb"
|
24
|
+
attributes_file
|
25
|
+
it { is_expected.to violate_rule("FC073").in("attributes/default.rb") }
|
26
|
+
end
|
27
|
+
|
28
|
+
context "with only recipes/default.rb" do
|
29
|
+
metadata_file
|
30
|
+
recipe_file
|
31
|
+
it { is_expected.to_not violate_rule("FC073") }
|
32
|
+
end
|
33
|
+
|
34
|
+
context "with only recipe.rb" do
|
35
|
+
metadata_file
|
36
|
+
file "recipe.rb"
|
37
|
+
it { is_expected.to_not violate_rule("FC073") }
|
38
|
+
end
|
39
|
+
|
40
|
+
context "with both recipe.rb and recipes/default.rb" do
|
41
|
+
metadata_file
|
42
|
+
file "recipe.rb"
|
43
|
+
recipe_file
|
44
|
+
it { is_expected.to violate_rule("FC073").in("recipes/default.rb") }
|
45
|
+
end
|
46
|
+
|
47
|
+
context "with all four" do
|
48
|
+
metadata_file
|
49
|
+
file "attributes.rb"
|
50
|
+
file "recipe.rb"
|
51
|
+
attributes_file
|
52
|
+
recipe_file
|
53
|
+
it { is_expected.to violate_rule("FC073").in("attributes/default.rb") }
|
54
|
+
it { is_expected.to violate_rule("FC073").in("recipes/default.rb") }
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "FC074" do
|
4
|
+
|
5
|
+
context "with a cookbook with a LWRP that includes a default_action" do
|
6
|
+
resource_file <<-EOH
|
7
|
+
actions :create, :remove
|
8
|
+
default_action :create
|
9
|
+
|
10
|
+
attribute :name, String, name_attribute: true
|
11
|
+
EOH
|
12
|
+
it { is_expected.to_not violate_rule("FC074") }
|
13
|
+
end
|
14
|
+
|
15
|
+
context "with a cookbook with a LWRP that includes a non-DSL default_action" do
|
16
|
+
resource_file <<-EOH
|
17
|
+
actions :create, :remove,
|
18
|
+
|
19
|
+
def initialize(*args)
|
20
|
+
super
|
21
|
+
@action = :create
|
22
|
+
end
|
23
|
+
|
24
|
+
attribute :name, String, name_attribute: true
|
25
|
+
EOH
|
26
|
+
it { is_expected.to violate_rule("FC074") }
|
27
|
+
end
|
28
|
+
|
29
|
+
context "with a custom resource" do
|
30
|
+
resource_file <<-EOH
|
31
|
+
property :name, String, name_property: true
|
32
|
+
|
33
|
+
action :create do
|
34
|
+
cookbook_file "/etc/something"
|
35
|
+
end
|
36
|
+
EOH
|
37
|
+
it { is_expected.to_not violate_rule("FC074") }
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "FC075" do
|
4
|
+
|
5
|
+
context "with a cookbook with recipe that uses node.save" do
|
6
|
+
recipe_file "node.save"
|
7
|
+
it { is_expected.to violate_rule("FC075") }
|
8
|
+
end
|
9
|
+
|
10
|
+
context "with a cookbook with recipe that doesn't use node.save" do
|
11
|
+
recipe_file
|
12
|
+
it { is_expected.not_to violate_rule("FC075") }
|
13
|
+
end
|
14
|
+
|
15
|
+
context "with a cookbook with recipe that includes node['save']" do
|
16
|
+
recipe_file("node['save']")
|
17
|
+
it { is_expected.not_to violate_rule("FC075") }
|
18
|
+
end
|
19
|
+
|
20
|
+
context "with a cookbook with a library that uses node.save" do
|
21
|
+
library_file <<-EOH
|
22
|
+
module CookbookHelper
|
23
|
+
def some_method
|
24
|
+
node.save
|
25
|
+
end
|
26
|
+
end
|
27
|
+
EOH
|
28
|
+
it { is_expected.to violate_rule("FC075") }
|
29
|
+
end
|
30
|
+
|
31
|
+
context "with a cookbook with a custom resource that uses node.save" do
|
32
|
+
resource_file <<-EOH
|
33
|
+
property :name, String, name_property: true
|
34
|
+
|
35
|
+
action :create do
|
36
|
+
node.save
|
37
|
+
end
|
38
|
+
EOH
|
39
|
+
it { is_expected.to violate_rule("FC075") }
|
40
|
+
end
|
41
|
+
end
|