Koha/t/00-testcritic.t
Frédéric Demians c7ec79b839 Bug 15258: Prevent unused declared variables
Add a perlcritic rule to 00-perlcritic.t to prevent unused declared
variable.

TO TEST:

- Apply the 1st patch (unit test)
- Run the UT:
  prove -v t/00-testcritic.t
- Note that several Perl script fail
- Apply the 2nd patch
- Run the UT, and confirm it passes.

Signed-off-by: Hector Castro <hector.hecaxmmx@gmail.com>
All tests pass successful.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Jesse Weaver <jweaver@bywatersolutions.com>
2015-12-30 17:24:30 -07:00

52 lines
1.1 KiB
Perl
Executable file

#!/usr/bin/env perl
# This script can be used to run perlcritic on perl files in koha
# It calls its own custom perlcriticrc
# The script is purely optional requiring Test::Perl::Critic to be installed
# and the environment variable TEST_QA to be set
# At present only the directories in @dirs will pass the tests in 'Gentle' mode
use Modern::Perl;
use File::Spec;
use Test::More;
use English qw(-no_match_vars);
my @dirs = qw(
acqui
admin
authorities
basket
catalogue
cataloguing
circ
debian
errors
labels
members
offline_circ
reserve
reviews
rotating_collections
serials
sms
virtualshelves
Koha
C4/SIP
);
if ( not $ENV{TEST_QA} ) {
my $msg = 'Author test. Set $ENV{TEST_QA} to a true value to run';
plan( skip_all => $msg );
}
eval { require Test::Perl::Critic; };
if ( $EVAL_ERROR ) {
my $msg = 'Test::Perl::Critic required to criticise code,';
plan( skip_all => $msg );
}
my $rcfile = File::Spec->catfile( 't', 'perlcriticrc' );
Test::Perl::Critic->import( -profile => $rcfile);
all_critic_ok(@dirs);