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

Foodcritic 13.x.x - Traversed in recipe folder thinking it is another cookbook when recipe named attributes.rb exists #760

Open
knightorc opened this issue May 16, 2018 · 8 comments

Comments

@knightorc
Copy link

Hit a weird issue today after updating to Foodcritic 13.x.x from 12.3.0

We have a cookbook that defines attributes at the recipe level.
The recipe is called attributes.rb
Foodcritic when testing the cookbook treats the recipes folder as a nested cookbook.
Simply renaming the recipe to foo_attributes.rb causes the cookbook to test fine.

Structure while failing:

> foodcritic -V
foodcritic 13.1.1
> foodcritic -P -B .
Checking 5 files
x..x.
FC011: Missing README in markdown format: recipes/README.md:1
FC031: Cookbook without metadata.rb file: recipes/metadata.rb:1
FC071: Missing LICENSE file: recipes/LICENSE:1
FC078: Ensure cookbook shared under an OSI-approved open source license: ./metadata.rb:1
> find .
.
./.kitchen.local.yml
./.kitchen.yml
./CHANGELOG.md
./Berksfile
./.kill_older
./README.md
./recipes
./recipes/vci-repo.rb
./recipes/default.rb
./recipes/attributes.rb
./metadata.rb

Structure working:

> find .
.
./.kitchen.local.yml
./.kitchen.yml
./CHANGELOG.md
./Berksfile
./.kill_older
./README.md
./recipes
./recipes/vci-repo.rb
./recipes/default.rb
./recipes/repo_attributes.rb
./metadata.rb
> foodcritic -V
foodcritic 13.1.1
> foodcritic -P -B .
Checking 4 files
x...
FC078: Ensure cookbook shared under an OSI-approved open source license: ./metadata.rb:1
@uqwhsu
Copy link

uqwhsu commented May 24, 2018

Same issue for "templates" folder name nested under templates folder

example:
./templates/default/foldername/templates

results in FC011 FC031 FC071 for foldername folder

@frezbo
Copy link

frezbo commented May 30, 2018

whoa @knightorc you are right, I had an attributes.rb file in attributes directory, hmm wierd bug.

@tas50
Copy link
Contributor

tas50 commented May 30, 2018

This bug was introduced when I attempted to fix Foodcritic not finding mycookbook/recipe.rb or mycookbook/attribute.rb. I'm going to have to clean up that logic and I have several new failure states to add specs for so I can make sure we always detect the right thing without casting our net too wide. It's surprisingly difficult to get this right.

@knightorc
Copy link
Author

@tas50 We're not blocked, as our solution was to rename the recipe in our case. Thanks for all your efforts. It is appreciated.

@frezbo
Copy link

frezbo commented May 30, 2018

Glad to know this is being looked upon, I also followed the approach @knightorc mentioned to get around this. 👍

@joe4dev
Copy link

joe4dev commented Aug 18, 2018

Confirm, same issue here with an recipe/attributes.rb recipe file present:

foodcritic -V
foodcritic 14.0.0
FC011: Missing README in markdown format: recipes/README.md:1
FC031: Cookbook without metadata.rb file: recipes/metadata.rb:1
FC069: Ensure standardized license defined in metadata: ./metadata.rb:1
FC071: Missing LICENSE file: recipes/LICENSE:1
FC078: Ensure cookbook shared under an OSI-approved open source license: ./metadata.rb:1

Renaming fixed the issue as workaround

joe4dev added a commit to sealuzh/cwb-chef-repo that referenced this issue Aug 18, 2018
Problem: `recipe/attributes.rb` causes false positive warnings
Solution: rename recipe

See: Foodcritic/foodcritic#760
@djessich
Copy link

I have the same issue with Foodcritic 15.1.0. I have an attributes recipe in my cookbooks recipe folder. With renaming the recipe, Foodcritic works as expected. I can confirm, that the workaround from @joe4dev works properly.

@rbgurav87
Copy link

This is applicale for attributes/attributes.rb as well

foodcritic 15.1.0
we faced similar issue for attributes/attributes.rb as well. after renaming the attributes.rb to default.rb it started working.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants