Koha-QA

 view release on metacpan or  search on metacpan

lib/Koha/QA/Tidy/Perl.pm  view on Meta::CPAN

package Koha::QA::Tidy::Perl;

use Modern::Perl;
use base 'Koha::QA::Base';
use File::ShareDir qw(dist_file);

=head1 NAME

Koha::QA::Tidy::Perl - Centralized Perl tidiness checking using perltidy

=head1 SYNOPSIS

  use Koha::QA::Tidy::Perl;

  # With a file
  my $checker = Koha::QA::Tidy::Perl->new({file => $file, perltidyrc => $perltidyrc});

  # Or with content directly
  my $checker = Koha::QA::Tidy::Perl->new({content => $file_content, perltidyrc => $perltidyrc});

  my $is_tidy = $checker->check;
  my @errors = $checker->errors;

  # Return the tidy version
  my $success = $checker->fix;

=head1 DESCRIPTION

This module provides centralized Perl tidiness checking using perltidy.

=head1 METHODS

=head2 new

  my $checker = Koha::QA::Tidy::Perl->new({file => $file, perltidyrc => $perltidyrc});

Creates a new Tidy::Perl instance.

Arguments:
  - perltidyrc: Optional path to .perltidyrc file (default: .perltidyrc)

=head2 check

  my $is_tidy = $checker->check;

Checks if a Perl file is tidy by comparing the original content with
the output from perltidy.

=head2 errors

  my @errors = $checker->errors;

Returns array of error hashrefs, each with:
  - error: the error type (tidy_perl, no_perltidyrc, tidy_perl_empty_output, tidy_perl_perltidy_failed)

=head2 fix

  my $output = $checker->fix;

Runs perltidy on the file and returns the tidied content without modifying the file.

Returns:
  - String with tidied content on success



( run in 0.560 second using v1.01-cache-2.11-cpan-eb134014566 )