New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PRC] - Added check for invalid arguments. #7

Merged
merged 2 commits into from May 5, 2018

Conversation

Projects
None yet
3 participants
@manwar
Contributor

manwar commented May 5, 2018

Hi @guillaumeaubert,

As a part of CPAN PRC, I propose the above PR.
Please review it.

Many Thanks.
Best Regards,
Mohammad S Anwar

@coveralls

This comment has been minimized.

coveralls commented May 5, 2018

Coverage Status

Coverage remained the same at 100.0% when pulling 8da8411 on manwar:add-negative-test into 25af4e5 on guillaumeaubert:master.

@guillaumeaubert

Nice catch, and thank you for submitting this pull request @manwar! See below for a small tweak.

Also, there's an opportunity to do this for the other functions in this module, if you're interested ;)

foreach my $key (keys %args) {
croak "Argument '$key' is invalid to create a Perl::Critic::Git object"
unless ($key =~ /^file|level$/);

This comment has been minimized.

@guillaumeaubert

guillaumeaubert May 5, 2018

Owner

Since the variable assignments for the arguments (lines 80-81) delete the corresponding key from the arguments hash, a simpler and less fragile pattern is to check if %args is empty afterwards.

See https://github.com/guillaumeaubert/App-GitHooks/blob/b00c813364aac164462faae7c4b167b88483cb04/lib/App/GitHooks/CommitMessage.pm#L64 for an example of this.

@@ -14,7 +14,7 @@ use Test::More;
# Check there is a git binary available, or skip all.
test_requires_git();
plan( tests => 8 );
plan( tests => 9 );

This comment has been minimized.

@guillaumeaubert

guillaumeaubert May 5, 2018

Owner

Thank you so much for adding a test! 👍

@manwar

This comment has been minimized.

Contributor

manwar commented May 5, 2018

Hi @guillaumeaubert

Updated invalid argument check as per your suggestion.
If you approve this approach then I would apply the same to others as well.

Best Regards,
Mohammad S Anwar

@guillaumeaubert

This comment has been minimized.

Owner

guillaumeaubert commented May 5, 2018

Looks good to me! :)

@guillaumeaubert guillaumeaubert merged commit 0d313dc into guillaumeaubert:master May 5, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage remained the same at 100.0%
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment