App-GitHooks-Plugin-PerlCritic

 view release on metacpan or  search on metacpan

lib/App/GitHooks/Plugin/PerlCritic.pm  view on Meta::CPAN

package App::GitHooks::Plugin::PerlCritic;

use strict;
use warnings;

use base 'App::GitHooks::Plugin';

# External dependencies.
use Perl::Critic;
use Perl::Critic::Git;
use Try::Tiny;

# Internal dependencies.
use App::GitHooks::Constants qw( :PLUGIN_RETURN_CODES );


=head1 NAME

App::GitHooks::Plugin::PerlCritic - Verify that all changes and addition to the Perl files pass PerlCritic checks.


=head1 DESCRIPTION

PerlCritic is a static source code analysis tool. This plugin calls PerlCritic
and verifies that the staged modifications do not trigger any violations.

Note that if you stage half of a file for committing, this plugin will
correctly only check for code violations in the staged half.


=head1 VERSION

Version 1.1.0

=cut

our $VERSION = '1.1.0';

# Tweak the format of the violations reported by PerlCritic.
# Note: the PerlCritic package unfortunately doesn't honor .perlcriticrc,
# unlike the perlcritic executable.
Perl::Critic::Violation::set_format( "%m at line %l column %c.  %e.  (Severity: %s, %p)\n" );


=head1 METHODS

=head2 get_file_pattern()

Return a pattern to filter the files this plugin should analyze.

	my $file_pattern = App::GitHooks::Plugin::PerlCritic->get_file_pattern(
		app => $app,
	);

=cut

sub get_file_pattern
{
	return qr/\.(?:pl|pm|t|cgi)$/x;
}


=head2 get_file_check_description()

Return a description of the check performed on files by the plugin and that
will be displayed to the user, if applicable, along with an indication of the
success or failure of the plugin.

	my $description = App::GitHooks::Plugin::PerlCritic->get_file_check_description();

=cut



( run in 2.055 seconds using v1.01-cache-2.11-cpan-6de40a662fe )