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

Commit

Permalink
Merge pull request #526 from acrmp/shorthand_include
Browse files Browse the repository at this point in the history
Don’t trigger FC007 on a shorthand recipe includes
  • Loading branch information
tas50 authored Mar 29, 2017
2 parents fb5b28a + 3aded65 commit 89d4703
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
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

0 comments on commit 89d4703

Please sign in to comment.