From a3ee1c39ae471ebb490dbca1740164b92479928b Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Sat, 21 Feb 2015 23:19:15 +0200 Subject: [PATCH] Add perlcritic tests and make code comply --- MANIFEST | 2 ++ lib/POE/Component/IRC/Plugin/Hello.pm | 4 +-- t/perlcritic.t | 10 ++++++++ t/perlcriticrc | 36 +++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 t/perlcritic.t create mode 100644 t/perlcriticrc diff --git a/MANIFEST b/MANIFEST index ce246a4..7f92099 100644 --- a/MANIFEST +++ b/MANIFEST @@ -3,4 +3,6 @@ Makefile.PL MANIFEST README t/POE-Component-IRC-Plugin-Hello.t +t/perlcritic.t +t/perlcriticrc lib/POE/Component/IRC/Plugin/Hello.pm diff --git a/lib/POE/Component/IRC/Plugin/Hello.pm b/lib/POE/Component/IRC/Plugin/Hello.pm index f559fd2..9b03e47 100644 --- a/lib/POE/Component/IRC/Plugin/Hello.pm +++ b/lib/POE/Component/IRC/Plugin/Hello.pm @@ -24,7 +24,7 @@ sub new { saluton allo moin aloha namaste shalom ciào ciao servus salve ave merhaba witaj hei hola selam sawubona geodemorgen hoi καλημέρα/, - "what's up", 'que tal', 'こんにちは', '你好', 'ni hao', + 'what\'s up', 'que tal', 'こんにちは', '你好', 'ni hao', 'добро јутро', 'γεια σας', 'bom dia', 'hyvää huomenta'], @_ }; @@ -47,7 +47,7 @@ sub S_public{ my $message = NFC decode 'UTF-8', $$rmessage; my @hello = @{$self->{greetings}}; - my $match = first { $message =~ /^\s*(?:$mynick(?:)[:,])?\s*$_\s*[.!]?\s*$/i } @hello; + my $match = first { $message =~ /^\s*(?:$mynick(?:)[:,])?\s*$_\s*[.!]?\s*$/is } @hello; my $randhello = encode 'UTF-8', $hello[int rand $#hello]; $irc->yield(privmsg => $$rchannels->[0] => "$randhello, $nick") if $match; PCI_EAT_NONE diff --git a/t/perlcritic.t b/t/perlcritic.t new file mode 100644 index 0000000..51bad9d --- /dev/null +++ b/t/perlcritic.t @@ -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 diff --git a/t/perlcriticrc b/t/perlcriticrc new file mode 100644 index 0000000..cc51fca --- /dev/null +++ b/t/perlcriticrc @@ -0,0 +1,36 @@ +severity = 1 + +[-BuiltinFunctions::ProhibitComplexMappings] +[-CodeLayout::RequireTidyCode] +[-ControlStructures::ProhibitPostfixControls] +[-ControlStructures::ProhibitUnlessBlocks] +[-Documentation::PodSpelling] +[-Documentation::RequirePodLinksIncludeText] +[-InputOutput::RequireBracedFileHandleWithPrint] +[-References::ProhibitDoubleSigils] +[-RegularExpressions::ProhibitEnumeratedClasses] +[-RegularExpressions::RequireExtendedFormatting] +[-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 + +[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 + +[NamingConventions::Capitalization] +subroutines = :no_restriction -- 2.39.2