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

FC007 should not be triggered by include_recipe "#{cookbook_name}::blah" #44

Closed
markjreed opened this issue Jun 7, 2012 · 6 comments
Closed
Labels

Comments

@markjreed
Copy link

To include another recipe from the current cookbook, I always use this syntax: include_recipe "#{cookbook_name}::other", to avoid hard-coding the cookbook name in the recipe code. This incorrectly triggers an FC007.

@acrmp
Copy link
Member

acrmp commented Jun 7, 2012

Hi Mark,

Thanks for raising this - I can confirm the bug and will have a look into it this evening.

Cheers,

Andrew.

@markjreed
Copy link
Author

It looks like the included recipe name turns into just "::recipe" by the time the ast is built, so grepping out '^::' works, but I don't understand why that is the case.

@acrmp
Copy link
Member

acrmp commented Jun 7, 2012

The included_recipes method that FC007 uses only recognises literal strings - so the behaviour of the rule should be to ignore any use of include_recipe that includes an embedded expression.
https://github.com/acrmp/foodcritic/blob/v1.3.0/lib/foodcritic/api.rb#L143

There is a test to check that FC007 doesn't wrongly warn on embedded expressions but the scenario is testing with a dynamic recipe_name rather than the cookbook_name.
https://github.com/acrmp/foodcritic/blob/v1.3.0/features/007_check_for_undeclared_recipe_dependencies.feature#L22-25
https://github.com/acrmp/foodcritic/blob/v1.3.0/features/step_definitions/cookbook_steps.rb#L253-267

It would be good to have scenarios to test:

  • "#{cookbook_name}::other"
  • "foo_#{cookbook_name}::other"

We could optionally add specific support for resolving cookbook_name too which might be nice.

If you feel like having a go at making these changes please let me know.

@acrmp
Copy link
Member

acrmp commented Jun 15, 2012

Hi Mark,

The fix for this was released in foodcritic 1.4.0. Can you test and let me know if this is still a problem?

Thanks,

Andrew.

@markjreed
Copy link
Author

Looks good. Thanks!

On Fri, Jun 15, 2012 at 7:14 PM, Andrew Crump <
[email protected]

wrote:

Hi Mark,

The fix for this was released in foodcritic 1.4.0. Can you test and let me
know if this is still a problem?

Thanks,

Andrew.


Reply to this email directly or view it on GitHub:
#44 (comment)

Mark J. Reed [email protected]

@acrmp
Copy link
Member

acrmp commented Jun 18, 2012

Thank you sir.

@acrmp acrmp closed this as completed Jun 18, 2012
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants