Koha-QA
view release on metacpan or search on metacpan
lib/Koha/QA/PerlSyntax.pm view on Meta::CPAN
package Koha::QA::PerlSyntax;
use Modern::Perl;
use base 'Koha::QA::Base';
=head1 NAME
Koha::QA::PerlSyntax - Centralized Perl syntax checking
=head1 SYNOPSIS
use Koha::QA::PerlSyntax;
# With a file
my $checker = Koha::QA::PerlSyntax->new({file => $file_path});
# Or with content directly
my $checker = Koha::QA::PerlSyntax->new({content => $file_content});
my $is_valid = $checker->check;
my @errors = $checker->errors;
=head1 DESCRIPTION
This module provides centralized Perl syntax checking using C<perl -cw>.
=head1 METHODS
=head2 new
my $checker = Koha::QA::PerlSyntax->new({file => $file_path});
Creates a new Perl syntax checker instance.
=head2 check
my $is_valid = $checker->check;
Checks a Perl file for syntax errors and warnings using C<perl -cw>.
=head2 errors
my @errors = $checker->errors;
Returns array of error hashrefs, each with:
- error: Type of error ('perl_syntax_compil_error', 'perl_syntax_compil_aborted' or 'perl_syntax_warning')
- message: Human-friendly error message
=cut
use IPC::Run3;
sub check {
my ($self) = @_;
my $file = $self->file;
my @exceptions = @{ $self->{exceptions} || [] };
# Run perl -cw to check syntax
my ( $stdout, $stderr );
run3( [ 'perl', '-cw', $file ], undef, \$stdout, \$stderr );
( run in 1.076 second using v1.01-cache-2.11-cpan-eb134014566 )