Foodcritic / foodcritic

Lint tool for Chef cookbooks.
http://foodcritic.io
MIT License
408 stars 153 forks source link

FC007 false positive when cookbooks are in a thing that 'looks' like a cookbook #738

Open richardc opened 6 years ago

richardc commented 6 years ago

foodcritic -B omnibus/files/embedded-cookbooks/site reports FC007 violations for include_recipe "site::recipe" in site/recipes/default.rb

I've been able to track it down to the behaviour of cookbook_name - it continues to recurse up the stack of possible names for omnibus/files/embedded-cookbooks/site/recipes/default.rb as files is still in the path, so the cookbook is identified as being omnibus, not site.

I have added a failing test to https://github.com/richardc/foodcritic/tree/cookbook_name_bug but the the fix is currently eluding me as the flow of the path walking code is a little confusing to me.