]> iEval git - app-statsbot.git/commitdiff
Add perlcritic test and make code comply
authorMarius Gavrilescu <marius@ieval.ro>
Sat, 7 Nov 2015 17:43:19 +0000 (17:43 +0000)
committerMarius Gavrilescu <marius@ieval.ro>
Sat, 7 Nov 2015 17:43:19 +0000 (17:43 +0000)
MANIFEST
lib/App/Statsbot.pm
t/perlcritic.t [new file with mode: 0644]
t/perlcriticrc [new file with mode: 0644]

index f99e1853583ca2c5cd4f25670166f785f19bd4a6..c42a07f11d2c55e8c0e6f0a62265fa4276423aac 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -3,5 +3,7 @@ Makefile.PL
 MANIFEST
 README
 t/App-Statsbot.t
+t/perlcritic.t
+t/perlcriticrc
 lib/App/Statsbot.pm
 statsbot
index 5c0ab080450ad064fdc6f0339c941a719177a167..8db29f01f7ccd0d728289cb51e837a991253f1f7 100644 (file)
@@ -127,10 +127,10 @@ sub on_public{
        my ($targets,$message)=@_[ARG1,ARG2];
        my $botnick = _nick_name;
 
-       if ($message =~ /(?:$botnick[:,])?\s*!?help\s*(.*)/) {
-               _yield(privmsg => $targets, "Try !presence username interval [truncate]");
-               _yield(privmsg => $targets, "For example, !presence mgv '2 days'");
-               _yield(privmsg => $targets, "or !presence mgv '1 year' 4");
+       if ($message =~ /(?:$botnick[:,])?\s*!?help\s*(.*)/sx) {
+               _yield(privmsg => $targets, 'Try !presence username interval [truncate]');
+               _yield(privmsg => $targets, q/For example, !presence mgv '2 days'/);
+               _yield(privmsg => $targets, q/or !presence mgv '1 year' 4/);
                return;
        }
 
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.027614 seconds and 4 git commands to generate.