-
Notifications
You must be signed in to change notification settings - Fork 153
foodcritic is trying to descend into a "spec" directory and treating it as a cookbook? #148
Comments
Yes. I have the same problem. In my case I have ./spec/libraries/libname_spec.rb files. It sees the libraries directory and thinks spec is a cookbook. Oddly enough, this is not a problem using thor because the linter supports -e/explude_paths. The foodcritic bin itself has no -e. :-( renaming my ./spec/libraries directory to ./spec/foop or anything non cookbookish resolved the issue. |
There seems to be #45 for adding the CLI option. But maybe it would be good to set the default |
👍 Was having this same issue last night. I wonder if a white list might be a better idea here though. You really only want to check the standard cookbook directories. For example |
@gregf As I understand it, foodcritic already does that. But as it is recursive, so it matches to e.g. Actually nowadays I always use foodcritic for one cookbook only (normally from a rake/thor task or by guard-foodcritic) and would not want the recursive behavior at all. So the command line UI with "cookbook_paths" is not fitting well to that use case. It should maybe have an option to specify "cookbook_path" (singular) instead. I.e. disable the recursive traversal. |
So the problem would be solved if we modified this? https://github.com/acrmp/foodcritic/blob/master/lib/foodcritic/linter.rb#L188 What use case am I missing by replacing the logic with just: files += (Dir.glob(File.join(dir, cookbook_glob)) - exclusions) ? |
Was there ever a consensus on this issue? I've just ran into this myself. but both this, and #45 seem to have died out half a year ago. |
Same here, I am running into this right now. |
Did this get resolved as a side effect of https://github.com/acrmp/foodcritic/blob/11fca11b32c697333be43309af0a08fec07e2c7a/lib/foodcritic/linter.rb#L210-L233 ? There now appears to be an undocumented 'excludes' option in the linter? |
In 3.0.3 it still descends into When working on single cookbooks it makes the command For guard, I suppose I can add an explicit list of |
Ah, nope. An explicit list doesn't work. BTW: In 3.0.3 you can access the Linter with exclude list by using a rake file:
However, you cannot set arguments like
|
This is still issue in 3.0.3, guess :exclude_paths option should be accepted through CLI options. |
Sorry for the lack of responsiveness. I've merged a modified version of Juanje's pull request to foodcritic master if you'd like to test the Thanks, Andrew. |
Also move unit tests down a level to avoid Foodcritic/foodcritic#148
foodcritic descends into the 'spec' directory and treats it as a cookbook. Details: Foodcritic/foodcritic#148
can we agree on ignoring spec folder by default? |
And ignore the test folder too. I'm seeing it descend into test for some of my cookbooks even when I explicitly This is using foodcritic 8.0.0. edit - it was unclear from the --help output that I needed to exclude |
So, the big issue around this bug, is that is now blows up any pipeline created via chefdk Workaround is to add exceptions to the config.json of the cookbook and have delivery-truck ignore it. |
Unbelievable. What a mess. Foodcritic/foodcritic#148 Otherwise FC complains as follows: > FC011: Missing README in markdown format: spec/README.md:1 > FC031: Cookbook without metadata file: spec/metadata.rb:1 > FC045: Metadata does not contain cookbook name: spec/metadata.rb:1
It feels great to be able to close this one out. By default now Foodcritic excludes the spec and test directories since we know those aren't actual shared cookbooks. Not only does it make the run faster, it prevents these annoying warnings. Enjoy |
Thanks, @tas50! |
Looks like it matches attributes in one of my cookbooks:
Dont know why |
Got this weird error while running Foodcritic on Opscode's Java cookbook within Travis. It looks like it's trying to treat the 'spec' directory as another cookbook. Ideas?
https://travis-ci.org/juliandunn/java/jobs/7971824#L122
The text was updated successfully, but these errors were encountered: