Skip to content

Add --ignore-paths and --extensions options#53

Merged
redbeardcreator merged 5 commits intomasterfrom
unknown repository
Jan 16, 2015
Merged

Add --ignore-paths and --extensions options#53
redbeardcreator merged 5 commits intomasterfrom
unknown repository

Conversation

@hanneskod
Copy link
Contributor

Add the possibility to ignore paths and specify file extensions to parse. Basically enhances the behaviour of FileIterator.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why you're using array_filter() here. Are you expecting it to remove empty values? If so, that's fine, but it's a little obscure. I didn't realize it was usable like that until I just looked it up. I'd be tempted to refactor that bit (array_filter(explode(...))) into a separate method and document this use of array_filter(). But also see my other comments.

@redbeardcreator
Copy link
Contributor

This looks great! I haven't tested yet, but a visual inspection looks good.

I did have a minor question, but I think I answered it. Just in case I misread the second time, here it is.

Why does --ignore-paths take a comma separated list but the path used InputArgument::IS_ARRAY? I believe it's because I misread it thinking that it was a --path option, not an argument. I was just wondering if they should be more consistent. But I totally get the usage now. That said, could you use InputOption::VALUE_IS_ARRAY instead of parsing it yourself? I'm not familiar enough with Symfony Console.

@hanneskod
Copy link
Contributor Author

The reason to use array_filter is that explode(",", "") === [""] and not [] as one might expect. It is used in many places, so puting it in a method of its own sounds like a good idea. Done.

InputOption::VALUE_IS_ARRAY maked it possible to specify an option multiple times. So that instead of

scan src --ignore-paths=dir1,dir2

one would use

scan src --ignore-path=dir1 --ignore-path=dir2

The csv solution was already in place with include-rules and exclude-rules, thats why I opted for it here as well.

The latest commit removes the ignore-path and extension checks when the added path is a file name (as oposed to the result of a directory iteration). If you specify a file name to scan you simply want that file scanned...

@hanneskod
Copy link
Contributor Author

If there are no more suggested changes I feel this is ready to merge.

redbeardcreator added a commit that referenced this pull request Jan 16, 2015
Add --ignore-paths and --extensions options

Looks good to me.
@redbeardcreator redbeardcreator merged commit ee73720 into psecio:master Jan 16, 2015
@hanneskod hanneskod deleted the ignore-path branch January 16, 2015 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants