Add the option :exclude_paths, that already exists, to the command line options.
Thanks Juanje. That was fast.
Can you add some tests for the command-line as well?
I was looking for test for other command-line options and I didn't find. I found integration test for having help for the command-line options and a specs for the methods at lib/foodcritic/command-line.rb, but not for calling the options or testing the options.
Are there any way I missed or should I just add to the spec or the features?
The feature mappings for the command-line options aren't that obvious, listing them below here for reference:
-r, --[no-]repl Drop into a REPL for interactive rule editing.
-t, --tags TAGS Only check against rules with the specified tags.
-f, --epic-fail TAGS Fail the build if any of the specified tags are matched.
-c, --chef-version VERSION Only check against rules valid for this version of Chef.
-C, --[no-]context Show lines matched against rather than the default summary.
-I, --include PATH Additional rule file path(s) to load.
-S, --search-grammar PATH Specify grammar to use when validating search syntax.
-V, --version Display the foodcritic version.
Then I'll add a new one for this.
Add :exclude_paths to the comman line options
Fix exclusions's glob at files_to_process()
Add tests for the exclude command line option
I've addded the tests and also fix a bug in the exclusion of the files at files_to_process(). The glob was looking just at the passed path level, but not checking for attributes/*.rb, etc.
I'm not sure if you like the tests and the changes I proposed. Please, have a look and tell me if you preffer something in another way, so I'll get it changed.
Thanks Juanje. This is looking good.
The issue you are having with exclusions is because the rake task currently assumes that you are passing the full glob in for the excluded paths.
This is fairly normal for rake tasks, but it may make less sense to pass the exclusion through as a glob on the command line as there is potential for confusion with shell globbing. What do you think?
The tests helpers you've added in juanje/foodcritic@03c78eb mean we have three copies of the logic for identifying test warnings which isn't great. Can we remove the duplication here?
I realise we let this one stall. This would still be really useful - what can I do to help move this forward?
Oh, Andrew, I'm so sorry :-/
I got into some new projects and I forgot to finish this issue.
I'll have to test this code with the master. Probably I'll have to change something.
I agree about the duplication, but it felt to me that the code I resuse was WIP and I didn't want to move it. At the same time, it was out of the scope and I need it there. That's the reason to copy there.
Maybe, as you have the big picture, you can see the better place for placing the code that identify test warnings so I can use it from here without duplication.
Thanks for ping me and sorry for the delay...
+1 this would be great, as foodcritic is currently incorrectly picking up test directories and finding false positives. @acrmp / @juanje , what's the state of play here? Anything I can do to help?
Exclude paths at the command line.
Refs #45, #148, #207.
Merged this with a couple of tweaks. Thanks again Juanje!
@acrmp Seems to work great! Cool!
So if I want to exclude two cookbooks I need to do --exclude cookbookA --exclude cookbookB? Is there a way to exclude both these cookbooks with only one --exclude? For example maybe it accepts a delimiter (ie. --exclude cookbookA,cookbookB)? Could this be added?
It doesn't look like it. The values are stored and evaluated with the assumption that you're not providing a comma-separated list.
yeah, I tested and it doesn't work. It's okay just wondering if that would be a nice addition?
Can we close this PR now, since a version of this has been merged?
Closing this since that feature was merged, see 82cd0ef.