]> iEval git - gruntmaster-data.git/commitdiff
Use perlcritic
authorMarius Gavrilescu <marius@ieval.ro>
Sat, 6 Dec 2014 22:45:28 +0000 (00:45 +0200)
committerMarius Gavrilescu <marius@ieval.ro>
Sat, 6 Dec 2014 22:54:14 +0000 (00:54 +0200)
MANIFEST
lib/Gruntmaster/Data.pm
t/perlcritic.t [new file with mode: 0644]
t/perlcriticrc [new file with mode: 0644]

index c3bc28456ce1600a23bb88bc44b306dfdc39102a..618fefa4a258a602975b4d21b1eb0e7e9d8e89ee 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -15,3 +15,5 @@ MANIFEST
 README
 t/Gruntmaster-Data.t
 t/tools.t
+t/perlcritic.t
+t/perlcriticrc
index b27444335bbc301b7cdd004031e146db0ecad686..694fc8e688eba12567f33bbe449b07888cf22a56 100644 (file)
@@ -29,14 +29,14 @@ use constant JOBS_PER_PAGE => 10;
 
 sub dynsub{
        our ($name, $sub) = @_;
-       no strict 'refs';
+       no strict 'refs'; ## no critic (Strict)
        *$name = subname $name => $sub
 }
 
 BEGIN {
        for my $rs (qw/contest contest_problem job open problem user/) {
                my $rsname = ucfirst $rs;
-               $rsname =~ s/_([a-z])/\u$1/g;
+               $rsname =~ s/_([a-z])/\u$1/gs;
                dynsub PL_N($rs) => sub { $_[0]->resultset($rsname)              };
                dynsub      $rs  => sub { $_[0]->resultset($rsname)->find($_[1]) };
        }
@@ -66,15 +66,15 @@ sub standings {
                        next if $time < 0;
                        my $value = $job->problem->value;
                        my $factor = $job->result ? 0 : 1;
-                       $factor = $1 / 100 if $job->result_text =~ /^(\d+ )/;
+                       $factor = $1 / 100 if $job->result_text =~ /^(\d+ )/s;
                        $scores{$job->owner->id}{$job->problem->id} = int ($factor * calc_score ($value, $time, $tries{$job->owner->id}{$job->problem->id}++, $ct->stop - $ct->start));
                } else {
-                       no warnings 'numeric';
+                       no warnings 'numeric'; ## no critic (ProhibitNoWarnings)
                        $scores{$job->owner->id}{$job->problem->id} = 0 + $job->result_text || ($job->result ? 0 : 100)
                }
        }
 
-       my @st = sort { $b->{score} <=> $a->{score} or $a->{user}->id cmp $b->{user}->id} map {
+       my @st = sort { $b->{score} <=> $a->{score} or $a->{user}->id cmp $b->{user}->id} map { ## no critic (ProhibitReverseSortBlock)
                my $user = $_;
                +{
                        user => $self->user($user),
@@ -91,7 +91,7 @@ sub standings {
 
 sub user_list {
        my $rs = $_[0]->users->search(undef, {order_by => 'name', columns => USER_PUBLIC_COLUMNS});
-       [ map +{ $_->get_columns }, $rs->all ]
+       [ map { { $_->get_columns } } $rs->all ]
 }
 
 sub user_entry {
@@ -118,7 +118,7 @@ sub problem_entry {
        my ($self, $id, $contest, $user) = @_;
        my $pb = $self->problems->find($id, {columns => PROBLEM_PUBLIC_COLUMNS, prefetch => 'owner'});
        my $running = $contest && $self->contest($contest)->is_running;
-       eval {
+       eval { ## no critic (RequireCheckingReturnValueOfEval)
                $self->opens->create({
                        contest => $contest,
                        problem => $id,
diff --git a/t/perlcritic.t b/t/perlcritic.t
new file mode 100644 (file)
index 0000000..1a4ac7a
--- /dev/null
@@ -0,0 +1,12 @@
+#!/usr/bin/perl
+use v5.14;
+use warnings;
+
+use Test::More;
+
+BEGIN { plan skip_all => '$ENV{RELEASE_TESTING} is false' unless $ENV{RELEASE_TESTING} }
+plan tests => 1;
+
+use Test::Perl::Critic -profile => 't/perlcriticrc';
+
+critic_ok 'lib/Gruntmaster/Data.pm';
diff --git a/t/perlcriticrc b/t/perlcriticrc
new file mode 100644 (file)
index 0000000..c80009c
--- /dev/null
@@ -0,0 +1,32 @@
+severity = 1
+
+[-BuiltinFunctions::ProhibitComplexMappings]
+[-CodeLayout::RequireTidyCode]
+[-ControlStructures::ProhibitPostfixControls]
+[-ControlStructures::ProhibitUnlessBlocks]
+[-Documentation::PodSpelling]
+[-Documentation::RequirePodLinksIncludeText]
+[-InputOutput::RequireBracedFileHandleWithPrint]
+[-Modules::RequireExplicitPackage]
+[-References::ProhibitDoubleSigils]
+[-RegularExpressions::ProhibitEnumeratedClasses]
+[-RegularExpressions::RequireLineBoundaryMatching]
+[-Subroutines::RequireFinalReturn]
+[-ValuesAndExpressions::ProhibitConstantPragma]
+[-ValuesAndExpressions::ProhibitEmptyQuotes]
+[-ValuesAndExpressions::ProhibitMagicNumbers]
+[-ValuesAndExpressions::ProhibitNoisyQuotes]
+[-Variables::ProhibitLocalVars]
+[-Variables::ProhibitPackageVars]
+[-Variables::ProhibitPunctuationVars]
+
+[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
This page took 0.032379 seconds and 4 git commands to generate.