Skip to content
This repository has been archived by the owner on Sep 19, 2020. It is now read-only.

Don’t trigger FC007 on a shorthand recipe includes #526

Merged
merged 1 commit into from
Mar 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions features/007_check_for_undeclared_recipe_dependencies.feature
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,8 @@ Feature: Check for undeclared recipe dependencies
Given a cookbook that does not have defined metadata
When I check the cookbook
Then the undeclared dependency warning 007 should not be displayed

Scenario: Cookbook uses the include_recipe shorthand syntax
Given a cookbook that uses the include_recipe shorthand syntax
When I check the cookbook
Then the undeclared dependency warning 007 should not be displayed
6 changes: 6 additions & 0 deletions features/step_definitions/cookbook_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,12 @@
}
end

Given "a cookbook that uses the include_recipe shorthand syntax" do
write_recipe %q{
include_recipe "::some_recipe"
}
end

Given /^a cookbook recipe that includes several declared recipe dependencies - (brace|block)$/ do |brace_or_block|
cookbook_declares_dependencies(brace_or_block.to_sym)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/foodcritic/rules/fc007.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
next unless File.exist? metadata_path
actual_included = included_recipes(ast, with_partial_names: false)
undeclared = actual_included.keys.map do |recipe|
recipe.split("::").first
end - [cookbook_name(filename)] -
recipe.split("::").first unless recipe =~ /^::/ # skip shorthand included recipes. They're local
end.compact - [cookbook_name(filename)] -
declared_dependencies(read_ast(metadata_path))
actual_included.map do |recipe, include_stmts|
if undeclared.include?(recipe) ||
Expand Down