NAME

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

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;

DESCRIPTION

This module provides centralized Perl tidiness checking using perltidy.

METHODS

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)

check

my $is_tidy = $checker->check;

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

errors

my @errors = $checker->errors;

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

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 - undef on failure

AUTHORS

Jonathan Druart <jonathan.druart@bugs.koha-community.org>

COPYRIGHT

Copyright 2026 Koha Development Team

LICENSE

This file is part of Koha.

Koha is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.