mlawren / githook-perltidy

Run perltidy as a Git pre-commit hook
41 stars 10 forks source link

Perl::Critic support #5

Closed MaddieM4 closed 6 years ago

MaddieM4 commented 10 years ago

It would be great if this was capable of running perlcritic the same way it does perltidy (i.e., only on files being committed). While this is not an immediate need, it would be very nice to have, and I'm actually open to implementing it myself, given a bit of guidance on how best to do it.

mlawren commented 10 years ago

Hi Philip,

It would be great if this was capable of running perlcritic the same way it does perltidy (i.e., only on files being committed). While this is not an immediate need, it would be very nice to have, and I'm actually open to implementing it myself, given a bit of guidance on how best to do it.

I have hardly used perlcritic. If I remember correctly it can be run on individual files by calling a script or through a module interface (Perl::Critic?) and possibly even controlled by a configuration file? (.perlcriticrc or similar?)

If that is the case then adding support is relatively straight forward, provided one understands the details of App / githook_perltidy / pre_commit.pm. It would mostly be a matter of adding "use Perl::Critic" and calling Perl::Critic->whatever on the appropriate Perl-related file types. Exceptions can usually be thrown safely to restore the working tree to its state before the commit was attempted.

I think it would make sense for perlcritic to only be triggered by the presence of some file (.perlcriticrc?) in the repository so that it doesn't surprise current users.

The more tricky part of the task I suspect would be adding tests to make sure it works where it should and breaks when it also should... With code and tests in place I then find the documentation easiest to patch.

If you want to have a go then I'm quite willing to merge and/or massage whatever you can do to add the feature.

Cheers,

Mark.

Mark Lawrence

icydee commented 9 years ago

I am willing to give this a go, but I note that you have version 11.1_5 available (as a developer release) but only 11.1_4 available here on github?

I have cloned your repo, but where would I get 11.1_5 on git please?

mlawren commented 9 years ago

Ok, took me a few cycles but I now see I hadn't pushed the last two commits. Github should be up to date now. I look forward to receiving a pull request!

mlawren commented 6 years ago

Support for Perl::Critic was implemented in the just-released version 0.11.11_2. As soon as I see success reports from CPAN testers I'll release a stable version.

Thanks for the suggestion.