summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.circleci/config.yml2
-rw-r--r--.perlcriticrc42
-rw-r--r--Dockerfile3
-rwxr-xr-xMakefile.PL11
-rw-r--r--t/.perlcritic-history147
-rw-r--r--t/002goodperl.t12
-rw-r--r--t/critic.t17
-rw-r--r--t/docker.t52
8 files changed, 274 insertions, 12 deletions
diff --git a/.circleci/config.yml b/.circleci/config.yml
index 18577fadb..30bc162c8 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -7,7 +7,7 @@ version: 2
defaults:
bmo_slim_image: &bmo_slim_image
- image: mozillabteam/bmo-slim:20170824.1
+ image: mozillabteam/bmo-slim:20170927.1
user: app
mysql_image: &mysql_image
diff --git a/.perlcriticrc b/.perlcriticrc
new file mode 100644
index 000000000..b61acbbc5
--- /dev/null
+++ b/.perlcriticrc
@@ -0,0 +1,42 @@
+theme = freenode || core || certrec || certrule || performance || security
+severity = 1
+
+[-BuiltinFunctions::ProhibitUselessTopic]
+[-ControlStructures::ProhibitCascadingIfElse]
+[-ControlStructures::ProhibitPostfixControls]
+[-ControlStructures::ProhibitUnlessBlocks]
+[-Documentation::RequirePodLinksIncludeText]
+[-Documentation::RequirePodSections]
+[-ErrorHandling::RequireCarping]
+[-Modules::RequireVersionVar]
+[-References::ProhibitDoubleSigils]
+[-RegularExpressions::ProhibitComplexRegexes]
+[-RegularExpressions::RequireExtendedFormatting]
+[-Subroutines::ProhibitExcessComplexity]
+[-ValuesAndExpressions::ProhibitConstantPragma]
+[-ValuesAndExpressions::ProhibitEmptyQuotes]
+[-ValuesAndExpressions::ProhibitMagicNumbers]
+[-ValuesAndExpressions::ProhibitVersionStrings]
+[-Variables::ProhibitLocalVars]
+[-Variables::ProhibitPackageVars]
+
+# this policy is broken currently
+[-Freenode::PackageMatchesFilename]
+
+# This is not a good policy.
+# Non-explicit return is often easier to read.
+# think of javascript arrow functions.
+[-Subroutines::RequireFinalReturn]
+
+# I don't agree with this policy because
+# a bare return can actually cause more problems.
+[-Subroutines::ProhibitExplicitReturnUndef]
+
+[Variables::RequireLocalizedPunctuationVars]
+allow = @ARGV $ARGV %ENV %SIG
+
+[Variables::ProhibitPunctuationVars]
+allow = $@ $! $/ $^O $^V
+
+
+
diff --git a/Dockerfile b/Dockerfile
index 01a846bc7..ef226da56 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,5 +1,4 @@
-FROM mozillabteam/bmo-slim:20170824.1
-MAINTAINER Dylan William Hardison <dylan@mozilla.com>
+FROM mozillabteam/bmo-slim:20170927.1
ENV BUNDLE=https://s3.amazonaws.com/moz-devservices-bmocartons/bmo/vendor.tar.gz
ENV PORT=8000
diff --git a/Makefile.PL b/Makefile.PL
index fc42b32da..dbf42fd1c 100755
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -53,7 +53,7 @@ my %requires = (
'JSON::XS' => '2.01',
'LWP::Protocol::https' => '6.07',
'LWP::UserAgent' => '6.26',
- 'List::MoreUtils' => $^V > v5.10.1 ? '0.418' : '0.22',
+ 'List::MoreUtils' => '0.418',
'Math::Random::ISAAC' => '1.0.1',
'Module::Metadata' => '1.000033',
'Module::Runtime' => 0,
@@ -71,9 +71,12 @@ my %build_requires = (
'ExtUtils::MakeMaker' => '7.22',
);
my %test_requires = (
- 'Test::More' => 0,
- 'Pod::Coverage' => 0,
- 'Test::WWW::Selenium' => 0,
+ 'Test::More' => 0,
+ 'Pod::Coverage' => 0,
+ 'Test::WWW::Selenium' => 0,
+ 'Test::Selenium::Firefox' => 0,
+ 'Test::Perl::Critic::Progressive' => 0,
+ 'Perl::Critic::Freenode' => 0,
);
my %recommends = ( Safe => '2.30' );
diff --git a/t/.perlcritic-history b/t/.perlcritic-history
new file mode 100644
index 000000000..8d21a03b6
--- /dev/null
+++ b/t/.perlcritic-history
@@ -0,0 +1,147 @@
+$VAR1 = [
+ {
+ 'Perl::Critic::Policy::ValuesAndExpressions::ProhibitNoisyQuotes' => 29,
+ 'Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage' => 0,
+ 'Perl::Critic::Policy::ValuesAndExpressions::ProhibitLongChainsOfMethodCalls' => 0,
+ 'Perl::Critic::Policy::BuiltinFunctions::ProhibitComplexMappings' => 0,
+ 'Perl::Critic::Policy::ControlStructures::ProhibitLabelsWithSpecialBlockNames' => 0,
+ 'Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace' => 0,
+ 'Perl::Critic::Policy::Variables::ProhibitUnusedVariables' => 0,
+ 'Perl::Critic::Policy::Documentation::RequirePackageMatchesPodName' => 0,
+ 'Perl::Critic::Policy::BuiltinFunctions::ProhibitUniversalCan' => 0,
+ 'Perl::Critic::Policy::InputOutput::ProhibitJoinedReadline' => 0,
+ 'Perl::Critic::Policy::Variables::ProhibitReusedNames' => 7,
+ 'Perl::Critic::Policy::BuiltinFunctions::ProhibitStringySplit' => 1,
+ 'Perl::Critic::Policy::Subroutines::ProhibitNestedSubs' => 0,
+ 'Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions' => 0,
+ 'Perl::Critic::Policy::Variables::ProhibitPerl4PackageNames' => 0,
+ 'Perl::Critic::Policy::ControlStructures::ProhibitYadaOperator' => 0,
+ 'Perl::Critic::Policy::Freenode::Each' => 0,
+ 'Perl::Critic::Policy::Modules::ProhibitConditionalUseStatements' => 0,
+ 'Perl::Critic::Policy::Freenode::OpenArgs' => 2,
+ 'Perl::Critic::Policy::TestingAndDebugging::RequireUseWarnings' => 0,
+ 'Perl::Critic::Policy::Miscellanea::ProhibitTies' => 0,
+ 'Perl::Critic::Policy::Modules::ProhibitEvilModules' => 0,
+ 'Perl::Critic::Policy::Subroutines::ProhibitManyArgs' => 0,
+ 'Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators' => 0,
+ 'Perl::Critic::Policy::Freenode::POSIXImports' => 0,
+ 'Perl::Critic::Policy::Freenode::DollarAB' => 0,
+ 'Perl::Critic::Policy::ValuesAndExpressions::RequireQuotedHeredocTerminator' => 29,
+ 'Perl::Critic::Policy::InputOutput::ProhibitOneArgSelect' => 0,
+ 'Perl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation' => 16,
+ 'Perl::Critic::Policy::Freenode::ModPerl' => 0,
+ 'Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings' => 1,
+ 'Perl::Critic::Policy::Freenode::IndirectObjectNotation' => 0,
+ 'Perl::Critic::Policy::Subroutines::ProhibitAmpersandSigils' => 0,
+ 'Perl::Critic::Policy::ControlStructures::ProhibitUnreachableCode' => 0,
+ 'Perl::Critic::Policy::Subroutines::ProhibitSubroutinePrototypes' => 5,
+ 'Perl::Critic::Policy::BuiltinFunctions::RequireBlockMap' => 0,
+ 'Perl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions' => 1,
+ 'Perl::Critic::Policy::ErrorHandling::RequireCheckingReturnValueOfEval' => 3,
+ 'Perl::Critic::Policy::InputOutput::ProhibitBacktickOperators' => 0,
+ 'Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars' => 7,
+ 'Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines' => 0,
+ 'Perl::Critic::Policy::Miscellanea::ProhibitUselessNoCritic' => 0,
+ 'Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict' => 1,
+ 'Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval' => 1,
+ 'Perl::Critic::Policy::BuiltinFunctions::ProhibitUniversalIsa' => 0,
+ 'Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists' => 0,
+ 'Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames' => 0,
+ 'Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations' => 0,
+ 'Perl::Critic::Policy::InputOutput::ProhibitExplicitStdin' => 1,
+ 'Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals' => 272,
+ 'Perl::Critic::Policy::Freenode::Wantarray' => 0,
+ 'Perl::Critic::Policy::ValuesAndExpressions::ProhibitMismatchedOperators' => 0,
+ 'Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint' => 15,
+ 'Perl::Critic::Policy::CodeLayout::RequireTidyCode' => 50,
+ 'Perl::Critic::Policy::Subroutines::ProhibitBuiltinHomonyms' => 0,
+ 'Perl::Critic::Policy::Modules::RequireExplicitPackage' => 0,
+ 'Perl::Critic::Policy::CodeLayout::ProhibitHardTabs' => 0,
+ 'Perl::Critic::Policy::BuiltinFunctions::ProhibitLvalueSubstr' => 0,
+ 'Perl::Critic::Policy::Freenode::OverloadOptions' => 0,
+ 'Perl::Critic::Policy::TestingAndDebugging::ProhibitProlongedStrictureOverride' => 0,
+ 'Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros' => 0,
+ 'Perl::Critic::Policy::CodeLayout::RequireTrailingCommas' => 3,
+ 'Perl::Critic::Policy::Miscellanea::ProhibitUnrestrictedNoCritic' => 0,
+ 'Perl::Critic::Policy::BuiltinFunctions::ProhibitSleepViaSelect' => 0,
+ 'Perl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters' => 3,
+ 'Perl::Critic::Policy::NamingConventions::Capitalization' => 0,
+ 'Perl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish' => 1,
+ 'Perl::Critic::Policy::RegularExpressions::RequireLineBoundaryMatching' => 37,
+ 'Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer' => 1,
+ 'Perl::Critic::Policy::BuiltinFunctions::ProhibitVoidGrep' => 0,
+ 'Perl::Critic::Policy::ValuesAndExpressions::RequireUpperCaseHeredocTerminator' => 0,
+ 'Perl::Critic::Policy::Miscellanea::ProhibitFormats' => 0,
+ 'Perl::Critic::Policy::Variables::RequireInitializationForLocalVars' => 0,
+ 'Perl::Critic::Policy::CodeLayout::ProhibitParensWithBuiltins' => 83,
+ 'Perl::Critic::Policy::RegularExpressions::ProhibitEnumeratedClasses' => 0,
+ 'Perl::Critic::Policy::ValuesAndExpressions::ProhibitCommaSeparatedStatements' => 0,
+ 'Perl::Critic::Policy::BuiltinFunctions::RequireBlockGrep' => 4,
+ 'Perl::Critic::Policy::Freenode::AmpersandSubCalls' => 0,
+ 'Perl::Critic::Policy::Modules::RequireEndWithOne' => 0,
+ 'Perl::Critic::Policy::InputOutput::ProhibitTwoArgOpen' => 2,
+ 'Perl::Critic::Policy::ValuesAndExpressions::RequireConstantVersion' => 0,
+ 'Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls' => 168,
+ 'Perl::Critic::Policy::ValuesAndExpressions::RequireInterpolationOfMetachars' => 0,
+ 'Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict' => 0,
+ 'Perl::Critic::Policy::ControlStructures::ProhibitUntilBlocks' => 0,
+ 'Perl::Critic::Policy::Freenode::ArrayAssignAref' => 0,
+ 'Perl::Critic::Policy::Freenode::ConditionalDeclarations' => 0,
+ 'Perl::Critic::Policy::Objects::ProhibitIndirectSyntax' => 22,
+ 'Perl::Critic::Policy::BuiltinFunctions::RequireGlobFunction' => 0,
+ 'Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels' => 0,
+ 'Perl::Critic::Policy::ClassHierarchies::ProhibitExplicitISA' => 0,
+ 'Perl::Critic::Policy::Modules::ProhibitExcessMainComplexity' => 6,
+ 'Perl::Critic::Policy::ValuesAndExpressions::ProhibitEscapedCharacters' => 1,
+ 'Perl::Critic::Policy::Freenode::WarningsSwitch' => 19,
+ 'Perl::Critic::Policy::RegularExpressions::ProhibitCaptureWithoutTest' => 0,
+ 'Perl::Critic::Policy::Variables::ProhibitPunctuationVars' => 14,
+ 'Perl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches' => 2,
+ 'Perl::Critic::Policy::ClassHierarchies::ProhibitOneArgBless' => 0,
+ 'Perl::Critic::Policy::BuiltinFunctions::RequireSimpleSortBlock' => 0,
+ 'Perl::Critic::Policy::InputOutput::RequireCheckedOpen' => 0,
+ 'Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters' => 1,
+ 'Perl::Critic::Policy::RegularExpressions::ProhibitUselessTopic' => 0,
+ 'Perl::Critic::Policy::Variables::ProhibitAugmentedAssignmentInDeclaration' => 1,
+ 'Perl::Critic::Policy::ValuesAndExpressions::RequireNumberSeparators' => 1,
+ 'Perl::Critic::Policy::Freenode::DiscouragedModules' => 5,
+ 'Perl::Critic::Policy::Subroutines::ProtectPrivateSubs' => 1,
+ 'Perl::Critic::Policy::ValuesAndExpressions::ProhibitComplexVersion' => 0,
+ 'Perl::Critic::Policy::ValuesAndExpressions::ProhibitSpecialLiteralHeredocTerminator' => 0,
+ 'Perl::Critic::Policy::Modules::ProhibitMultiplePackages' => 0,
+ 'Perl::Critic::Policy::Variables::ProhibitMatchVars' => 0,
+ 'Perl::Critic::Policy::Variables::RequireLexicalLoopIterators' => 0,
+ 'Perl::Critic::Policy::BuiltinFunctions::ProhibitVoidMap' => 0,
+ 'Perl::Critic::Policy::ValuesAndExpressions::ProhibitImplicitNewlines' => 55,
+ 'Perl::Critic::Policy::Modules::RequireBarewordIncludes' => 0,
+ 'Perl::Critic::Policy::InputOutput::ProhibitBarewordFileHandles' => 2,
+ 'Perl::Critic::Policy::InputOutput::RequireCheckedClose' => 1,
+ 'Perl::Critic::Policy::ControlStructures::ProhibitDeepNests' => 0,
+ 'Perl::Critic::Policy::ControlStructures::ProhibitCStyleForLoops' => 2,
+ 'Perl::Critic::Policy::InputOutput::ProhibitReadlineInForLoop' => 0,
+ 'Perl::Critic::Policy::Freenode::WhileDiamondDefaultAssignment' => 0,
+ 'Perl::Critic::Policy::RegularExpressions::ProhibitUnusedCapture' => 0,
+ 'Perl::Critic::Policy::InputOutput::ProhibitInteractiveTest' => 1,
+ 'Perl::Critic::Policy::Modules::ProhibitAutomaticExportation' => 0,
+ 'Perl::Critic::Policy::RegularExpressions::RequireDotMatchAnything' => 38,
+ 'Perl::Critic::Policy::Subroutines::RequireArgUnpacking' => 2,
+ 'Perl::Critic::Policy::RegularExpressions::RequireBracesForMultiline' => 0,
+ 'Perl::Critic::Policy::Subroutines::ProhibitUnusedPrivateSubroutines' => 0,
+ 'Perl::Critic::Policy::Documentation::RequirePodAtEnd' => 4,
+ 'Perl::Critic::Policy::Freenode::StrictWarnings' => 0,
+ 'Perl::Critic::Policy::Variables::ProtectPrivateVars' => 0,
+ 'Perl::Critic::Policy::Freenode::DeprecatedFeatures' => 0,
+ 'Perl::Critic::Policy::BuiltinFunctions::ProhibitBooleanGrep' => 6,
+ 'Perl::Critic::Policy::Freenode::Prototypes' => 5,
+ 'Perl::Critic::Policy::Freenode::ConditionalImplicitReturn' => 0,
+ 'Perl::Critic::Policy::BuiltinFunctions::ProhibitReverseSortBlock' => 0,
+ 'Perl::Critic::Policy::Freenode::EmptyReturn' => 0,
+ 'Perl::Critic::Policy::ClassHierarchies::ProhibitAutoloading' => 0,
+ 'Perl::Critic::Policy::Freenode::Threads' => 0,
+ 'Perl::Critic::Policy::Freenode::BarewordFilehandles' => 2,
+ 'Perl::Critic::Policy::Subroutines::ProhibitReturnSort' => 0,
+ 'Perl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters' => 0,
+ 'Perl::Critic::Policy::Variables::RequireNegativeIndices' => 0,
+ 'Perl::Critic::Policy::InputOutput::RequireBriefOpen' => 4
+ }
+ ];
diff --git a/t/002goodperl.t b/t/002goodperl.t
index d770b7b4f..5f201160b 100644
--- a/t/002goodperl.t
+++ b/t/002goodperl.t
@@ -54,6 +54,8 @@ foreach my $file (@testitems) {
} elsif ($ext eq "cgi") {
# cgi files must be taint checked
$flags = 'T';
+ } elsif ($ext eq 't') {
+ $flags = '';
} else {
ok(0, "$file has shebang but unknown extension");
next;
@@ -129,20 +131,20 @@ foreach my $file (@testitems) {
}
my $lineno = 0;
my $error = 0;
-
+
while (!$error && (my $file_line = <FILE>)) {
$lineno++;
if ($file_line =~ /Throw.*Error\("(.*?)"/) {
if ($1 =~ /\s/) {
- ok(0,"$file has a Throw*Error call on line $lineno
+ ok(0,"$file has a Throw*Error call on line $lineno
which doesn't use a tag --ERROR");
- $error = 1;
+ $error = 1;
}
}
}
-
+
ok(1,"$file uses Throw*Error calls correctly") if !$error;
-
+
close(FILE);
}
diff --git a/t/critic.t b/t/critic.t
new file mode 100644
index 000000000..6e37cc0df
--- /dev/null
+++ b/t/critic.t
@@ -0,0 +1,17 @@
+#!/usr/bin/perl
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
+use 5.10.1;
+use strict;
+use warnings;
+use lib qw(. lib local/lib/perl5);
+use Test::More;
+
+my $ok = eval { require Test::Perl::Critic::Progressive };
+plan skip_all => 'T::P::C::Progressive required for this test' unless $ok;
+
+Test::Perl::Critic::Progressive::progressive_critic_ok(); \ No newline at end of file
diff --git a/t/docker.t b/t/docker.t
new file mode 100644
index 000000000..3c8cd055b
--- /dev/null
+++ b/t/docker.t
@@ -0,0 +1,52 @@
+#!/usr/bin/perl
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
+use 5.10.1;
+use strict;
+use warnings;
+use autodie;
+use lib qw(. lib local/lib/perl5);
+use IO::Handle;
+use Test::More;
+
+my $dockerfile = 'Dockerfile';
+my $ci_config = '.circleci/config.yml';
+
+my $base;
+open my $dockerfile_fh, '<', $dockerfile;
+while (my $line = readline $dockerfile_fh) {
+ chomp $line;
+ if ($line =~ /^FROM\s+(\S+)/ms) {
+ $base = $1;
+ last;
+ }
+}
+close $dockerfile_fh;
+
+my ($image, $version) = split(/:/ms, $base, 2);
+is($image, 'mozillabteam/bmo-slim', "base image is mozillabteam/bmo-slim");
+like($version, qr/\d{4}\d{2}\d{2}\.\d+/ms, "version is YYYYMMDD.x");
+
+my $regex = qr{
+ \Q$image\E
+ :
+ (?!\Q$version\E)
+ (\d{4}\d{2}\d{2}\.\d+)
+}msx;
+
+open my $ci_config_fh, '<', $ci_config;
+while (my $line = readline $ci_config_fh) {
+ chomp $line;
+ if ($line =~ /($regex)/ms) {
+ my $ln = $ci_config_fh->input_line_number;
+ fail("found docker image $1, expected $base in $ci_config line $ln");
+ }
+ pass("Forbidden version not found");
+}
+close $ci_config_fh;
+
+done_testing; \ No newline at end of file