Make perlcritic happy and add perlcritic test
authorMarius Gavrilescu <marius@ieval.ro>
Sat, 21 May 2016 17:38:37 +0000 (18:38 +0100)
committerMarius Gavrilescu <marius@ieval.ro>
Sat, 21 May 2016 17:38:37 +0000 (18:38 +0100)
MANIFEST
lib/App/MusicExpo.pm
t/perlcritic.t [new file with mode: 0644]
t/perlcriticrc [new file with mode: 0644]

index 96e9c07b46cbbf774d0ad9d1ffe75c8627a9c71a..38903755f632743bf1b65ec8ac10ee5a25f47f21 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -5,6 +5,8 @@ README
 t/App-MusicExpo.t
 t/musicexpo-cache.t
 t/musicexpo.t
+t/perlcritic.t
+t/perlcriticrc
 lib/App/MusicExpo.pm
 musicexpo
 musicexpo.css
index 7cdf6e29441f15fdf2493d1e893c8e966aeb66e6..cf16468be168d69498b4ead9bec69d2a2b308925 100644 (file)
@@ -1,5 +1,5 @@
 package App::MusicExpo;
-use v5.14;
+use 5.014000;
 use strict;
 use warnings;
 
@@ -29,9 +29,9 @@ our $cache='';
 our $template='';
 
 GetOptions (
-       "template:s" => \$template,
-       "prefix:s" => \$prefix,
-       "cache:s" => \$cache,
+       'template:s' => \$template,
+       'prefix:s' => \$prefix,
+       'cache:s' => \$cache,
 );
 
 sub flacinfo{
@@ -54,7 +54,7 @@ sub flacinfo{
 sub mp3info{
        my $file=$_[0];
        my %tag = map { encode 'UTF-8', $_ } %{get_mp3tag $file};
-       my @trkn = split '/', $tag{TRACKNUM} // '';
+       my @trkn = split m#/#s, $tag{TRACKNUM} // '';
 
        freeze +{
                format => 'MP3',
@@ -86,7 +86,7 @@ sub vorbisinfo{
        }
 }
 
-sub mp4_format ($){
+sub mp4_format ($){ ## no critic (ProhibitSubroutinePrototypes)
        my $encoding = $_[0];
        return 'AAC' if $encoding eq 'mp4a';
        return 'ALAC' if $encoding eq 'alac';
@@ -128,9 +128,8 @@ sub normalizer{
 sub make_fragment{ join '-', map { lc =~ y/a-z0-9/_/csr } @_ }
 
 sub run {
-       my %info = %info;
        if ($cache) {
-               tie my %cache, 'DB_File', $cache, O_RDWR|O_CREAT, 0644;
+               tie my %cache, 'DB_File', $cache, O_RDWR|O_CREAT, 0644; ## no critic (ProhibitTie)
                $info{$_} = memoize $info{$_}, INSTALL => undef, NORMALIZER => \&normalizer, LIST_CACHE => 'FAULT', SCALAR_CACHE => [HASH => \%cache] for keys %info;
        }
 
@@ -164,7 +163,7 @@ sub run {
 
        @files = sort { $a->{title} cmp $b->{title} } @files;
        $ht->param(files => \@files, prefix => $prefix);
-       print $ht->output;
+       print $ht->output; ## no critic (RequireCheckedSyscalls)
 }
 
 $default_template = <<'HTML';
diff --git a/t/perlcritic.t b/t/perlcritic.t
new file mode 100644 (file)
index 0000000..79e93dc
--- /dev/null
@@ -0,0 +1,10 @@
+#!/usr/bin/perl
+use v5.14;
+use warnings;
+
+use Test::More;
+
+BEGIN { plan skip_all => '$ENV{RELEASE_TESTING} is false' unless $ENV{RELEASE_TESTING} }
+use Test::Perl::Critic -profile => 't/perlcriticrc';
+
+all_critic_ok 'lib'
diff --git a/t/perlcriticrc b/t/perlcriticrc
new file mode 100644 (file)
index 0000000..40b151e
--- /dev/null
@@ -0,0 +1,41 @@
+severity = 1
+
+[-BuiltinFunctions::ProhibitComplexMappings]
+[-CodeLayout::RequireTidyCode]
+[-ControlStructures::ProhibitPostfixControls]
+[-ControlStructures::ProhibitUnlessBlocks]
+[-Documentation::PodSpelling]
+[-Documentation::RequirePodLinksIncludeText]
+[-InputOutput::RequireBracedFileHandleWithPrint]
+[-Modules::ProhibitAutomaticExportation]
+[-References::ProhibitDoubleSigils]
+[-RegularExpressions::ProhibitEnumeratedClasses]
+[-RegularExpressions::ProhibitUnusualDelimiters]
+[-RegularExpressions::RequireBracesForMultiline]
+[-RegularExpressions::RequireLineBoundaryMatching]
+[-Subroutines::RequireFinalReturn]
+[-ValuesAndExpressions::ProhibitConstantPragma]
+[-ValuesAndExpressions::ProhibitEmptyQuotes]
+[-ValuesAndExpressions::ProhibitLeadingZeros]
+[-ValuesAndExpressions::ProhibitMagicNumbers]
+[-ValuesAndExpressions::ProhibitNoisyQuotes]
+[-Variables::ProhibitLocalVars]
+[-Variables::ProhibitPackageVars]
+[-Variables::ProhibitPunctuationVars]
+
+[BuiltinFunctions::ProhibitStringyEval]
+allow_includes = 1
+
+[RegularExpressions::RequireExtendedFormatting]
+minimum_regex_length_to_complain_about = 20
+
+[Documentation::RequirePodSections]
+lib_sections = NAME | SYNOPSIS | DESCRIPTION | AUTHOR | COPYRIGHT AND LICENSE
+script_sections = NAME | SYNOPSIS | DESCRIPTION | AUTHOR | COPYRIGHT AND LICENSE
+
+[Subroutines::RequireArgUnpacking]
+short_subroutine_statements = 5
+allow_subscripts = 1
+
+[TestingAndDebugging::ProhibitNoWarnings]
+allow_with_category_restriction = 1
This page took 0.014137 seconds and 4 git commands to generate.