diff --git a/.tidyallrc b/.tidyallrc index 1367909a63..a259152da3 100644 --- a/.tidyallrc +++ b/.tidyallrc @@ -9,3 +9,6 @@ select = .gitignore [JSBeautify] select = root/static/js/cpan.js argv = --indent-size 4 --end_with_newline + +[Test::Vars] +select = {lib,t}/**/*.pm diff --git a/.travis.yml b/.travis.yml index 0f46fc6c47..d96508dcf2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,18 +3,23 @@ perl: - "5.22" matrix: + fast_finish: true allow_failures: - - perl: "5.22" - env: USE_CPANFILE_SNAPSHOT=false - + - env: COVERAGE=1 USE_CPANFILE_SNAPSHOT=true + - env: USE_CPANFILE_SNAPSHOT=false HARNESS_VERBOSE=1 env: global: # Carton --deployment only works on the same version of perl # that the snapshot was built from. - DEPLOYMENT_PERL_VERSION=5.22 + - DEVEL_COVER_OPTIONS="-ignore,^local/" matrix: + + # Get one passing run with coverage and one passing run with Test::Vars + # checks. If run together they more than double the build time. - COVERAGE=1 USE_CPANFILE_SNAPSHOT=true - - USE_CPANFILE_SNAPSHOT=false + - USE_CPANFILE_SNAPSHOT=false HARNESS_VERBOSE=1 + - USE_CPANFILE_SNAPSHOT=true before_install: - git clone git://github.com/travis-perl/helpers ~/travis-perl-helpers diff --git a/cpanfile b/cpanfile index b15474325a..5fe4340ef5 100644 --- a/cpanfile +++ b/cpanfile @@ -101,12 +101,13 @@ requires 'XML::Simple'; test_requires 'App::Prove'; test_requires 'Code::TidyAll', '>= 0.47'; +test_requires 'Code::TidyAll::Plugin::Test::Vars', '0.04'; test_requires 'Path::Iterator::Rule', '1.008'; +test_requires 'Perl::Critic', '1.124'; test_requires 'Perl::Tidy'; test_requires 'Test::Code::TidyAll'; test_requires 'Test::MockObject','1.09'; test_requires 'Test::More', '0.96'; -test_requires 'Perl::Critic', '1.124'; test_requires 'Test::Perl::Critic'; test_requires 'Test::XPath', '0.15'; diff --git a/cpanfile.snapshot b/cpanfile.snapshot index 45939d020d..240fccf80b 100644 --- a/cpanfile.snapshot +++ b/cpanfile.snapshot @@ -264,6 +264,13 @@ DISTRIBUTIONS perl 5.006 strict 0 warnings 0 + Carp-Always-0.13 + pathname: F/FE/FERREIRA/Carp-Always-0.13.tar.gz + provides: + Carp::Always 0.13 + requirements: + Carp 0 + ExtUtils::MakeMaker 0 Carp-Assert-0.21 pathname: N/NE/NEILB/Carp-Assert-0.21.tar.gz provides: @@ -758,38 +765,39 @@ DISTRIBUTIONS strict 0 vars 0 warnings 0 - Code-TidyAll-0.47 - pathname: D/DR/DROLSKY/Code-TidyAll-0.47.tar.gz - provides: - Code::TidyAll 0.47 - Code::TidyAll::Cache 0.47 - Code::TidyAll::CacheModel 0.47 - Code::TidyAll::CacheModel::Shared 0.47 - Code::TidyAll::Config::INI::Reader 0.47 - Code::TidyAll::Git::Precommit 0.47 - Code::TidyAll::Git::Prereceive 0.47 - Code::TidyAll::Git::Util 0.47 - Code::TidyAll::Plugin 0.47 - Code::TidyAll::Plugin::CSSUnminifier 0.47 - Code::TidyAll::Plugin::JSBeautify 0.47 - Code::TidyAll::Plugin::JSHint 0.47 - Code::TidyAll::Plugin::JSLint 0.47 - Code::TidyAll::Plugin::JSON 0.47 - Code::TidyAll::Plugin::MasonTidy 0.47 - Code::TidyAll::Plugin::PHPCodeSniffer 0.47 - Code::TidyAll::Plugin::PerlCritic 0.47 - Code::TidyAll::Plugin::PerlTidy 0.47 - Code::TidyAll::Plugin::PerlTidySweet 0.47 - Code::TidyAll::Plugin::PodChecker 0.47 - Code::TidyAll::Plugin::PodSpell 0.47 - Code::TidyAll::Plugin::PodTidy 0.47 - Code::TidyAll::Plugin::SortLines 0.47 - Code::TidyAll::Result 0.47 - Code::TidyAll::Role::Tempdir 0.47 - Code::TidyAll::SVN::Precommit 0.47 - Code::TidyAll::SVN::Util 0.47 - Code::TidyAll::Util::Zglob 0.47 - Test::Code::TidyAll 0.47 + Code-TidyAll-0.59 + pathname: D/DR/DROLSKY/Code-TidyAll-0.59.tar.gz + provides: + Code::TidyAll 0.59 + Code::TidyAll::Cache 0.59 + Code::TidyAll::CacheModel 0.59 + Code::TidyAll::CacheModel::Shared 0.59 + Code::TidyAll::Config::INI::Reader 0.59 + Code::TidyAll::Git::Precommit 0.59 + Code::TidyAll::Git::Prereceive 0.59 + Code::TidyAll::Git::Util 0.59 + Code::TidyAll::Plugin 0.59 + Code::TidyAll::Plugin::CSSUnminifier 0.59 + Code::TidyAll::Plugin::JSBeautify 0.59 + Code::TidyAll::Plugin::JSHint 0.59 + Code::TidyAll::Plugin::JSLint 0.59 + Code::TidyAll::Plugin::JSON 0.59 + Code::TidyAll::Plugin::MasonTidy 0.59 + Code::TidyAll::Plugin::PHPCodeSniffer 0.59 + Code::TidyAll::Plugin::PerlCritic 0.59 + Code::TidyAll::Plugin::PerlTidy 0.59 + Code::TidyAll::Plugin::PerlTidySweet 0.59 + Code::TidyAll::Plugin::PodChecker 0.59 + Code::TidyAll::Plugin::PodSpell 0.59 + Code::TidyAll::Plugin::PodTidy 0.59 + Code::TidyAll::Plugin::SortLines 0.59 + Code::TidyAll::Result 0.59 + Code::TidyAll::Role::HasIgnore 0.59 + Code::TidyAll::Role::Tempdir 0.59 + Code::TidyAll::SVN::Precommit 0.59 + Code::TidyAll::SVN::Util 0.59 + Code::TidyAll::Util::Zglob 0.59 + Test::Code::TidyAll 0.59 requirements: Capture::Tiny 0 Config::INI::Reader 0 @@ -803,8 +811,7 @@ DISTRIBUTIONS File::Find 0 File::Path 0 File::Slurp::Tiny 0 - File::Spec::Functions 0 - File::Temp 0 + File::Spec 0 File::Which 0 File::Zglob 0 Getopt::Long 0 @@ -814,9 +821,16 @@ DISTRIBUTIONS List::Compare 0 List::SomeUtils 0 Log::Any 0 - Moo 0 + Moo 2.000000 Moo::Role 0 + Path::Tiny 0.098 Scalar::Util 0 + Specio 0.30 + Specio::Declare 0 + Specio::Library::Builtins 0 + Specio::Library::Numeric 0 + Specio::Library::Path::Tiny 0.04 + Specio::Library::String 0 Test::Builder 0 Text::Diff 1.44 Text::Diff::Table 0 @@ -826,7 +840,22 @@ DISTRIBUTIONS base 0 constant 0 strict 0 - vars 0 + warnings 0 + Code-TidyAll-Plugin-Test-Vars-0.04 + pathname: M/MA/MAXMIND/Code-TidyAll-Plugin-Test-Vars-0.04.tar.gz + provides: + Code::TidyAll::Plugin::Test::Vars 0.04 + requirements: + Code::TidyAll 0.50 + Code::TidyAll::Plugin 0 + ExtUtils::MakeMaker 0 + Moo 0 + PPI::Document 0 + Path::Tiny 0 + Test::Vars 0.008 + autodie 0 + perl 5.006 + strict 0 warnings 0 Config-Any-0.27 pathname: B/BR/BRICAS/Config-Any-0.27.tar.gz @@ -902,6 +931,19 @@ DISTRIBUTIONS perl v5.8.1 strict 0 utf8 0 + Const-Fast-0.014 + pathname: L/LE/LEONT/Const-Fast-0.014.tar.gz + provides: + Const::Fast 0.014 + requirements: + Carp 0 + Module::Build::Tiny 0.021 + Scalar::Util 0 + Storable 0 + Sub::Exporter::Progressive 0.001007 + perl 5.008 + strict 0 + warnings 0 Cookie-Baker-0.06 pathname: K/KA/KAZEBURO/Cookie-Baker-0.06.tar.gz provides: @@ -4158,11 +4200,11 @@ DISTRIBUTIONS strict 0 warnings 0 warnings::register 0 - Path-Tiny-0.094 - pathname: D/DA/DAGOLDEN/Path-Tiny-0.094.tar.gz + Path-Tiny-0.104 + pathname: D/DA/DAGOLDEN/Path-Tiny-0.104.tar.gz provides: - Path::Tiny 0.094 - Path::Tiny::Error 0.094 + Path::Tiny 0.104 + Path::Tiny::Error 0.104 requirements: Carp 0 Cwd 0 @@ -4890,6 +4932,90 @@ DISTRIBUTIONS requirements: ExtUtils::MakeMaker 0 perl 5 + Specio-0.37 + pathname: D/DR/DROLSKY/Specio-0.37.tar.gz + provides: + Specio 0.37 + Specio::Coercion 0.37 + Specio::Constraint::AnyCan 0.37 + Specio::Constraint::AnyDoes 0.37 + Specio::Constraint::AnyIsa 0.37 + Specio::Constraint::Enum 0.37 + Specio::Constraint::Intersection 0.37 + Specio::Constraint::ObjectCan 0.37 + Specio::Constraint::ObjectDoes 0.37 + Specio::Constraint::ObjectIsa 0.37 + Specio::Constraint::Parameterizable 0.37 + Specio::Constraint::Parameterized 0.37 + Specio::Constraint::Role::CanType 0.37 + Specio::Constraint::Role::DoesType 0.37 + Specio::Constraint::Role::Interface 0.37 + Specio::Constraint::Role::IsaType 0.37 + Specio::Constraint::Simple 0.37 + Specio::Constraint::Structurable 0.37 + Specio::Constraint::Structured 0.37 + Specio::Constraint::Union 0.37 + Specio::Declare 0.37 + Specio::DeclaredAt 0.37 + Specio::Exception 0.37 + Specio::Exporter 0.37 + Specio::Helpers 0.37 + Specio::Library::Builtins 0.37 + Specio::Library::Numeric 0.37 + Specio::Library::Perl 0.37 + Specio::Library::String 0.37 + Specio::Library::Structured 0.37 + Specio::Library::Structured::Dict 0.37 + Specio::Library::Structured::Map 0.37 + Specio::Library::Structured::Tuple 0.37 + Specio::OO 0.37 + Specio::PartialDump 0.37 + Specio::Registry 0.37 + Specio::Role::Inlinable 0.37 + Specio::Subs 0.37 + Specio::TypeChecks 0.37 + Test::Specio 0.37 + requirements: + B 0 + Carp 0 + Devel::StackTrace 0 + Eval::Closure 0 + Exporter 0 + ExtUtils::MakeMaker 0 + IO::File 0 + List::Util 1.33 + MRO::Compat 0 + Module::Runtime 0 + Role::Tiny 1.003003 + Role::Tiny::With 0 + Scalar::Util 0 + Storable 0 + Test::Fatal 0 + Test::More 0.96 + overload 0 + parent 0 + perl 5.008 + re 0 + strict 0 + version 0.83 + warnings 0 + Specio-Library-Path-Tiny-0.04 + pathname: D/DR/DROLSKY/Specio-Library-Path-Tiny-0.04.tar.gz + provides: + Specio::Library::Path::Tiny 0.04 + requirements: + ExtUtils::MakeMaker 0 + Path::Tiny 0.087 + Scalar::Util 0 + Specio 0.29 + Specio::Declare 0 + Specio::Exporter 0 + Specio::Library::Builtins 0 + Specio::PartialDump 0 + overload 0 + parent 0 + strict 0 + warnings 0 Spiffy-0.46 pathname: I/IN/INGY/Spiffy-0.46.tar.gz provides: @@ -5423,6 +5549,18 @@ DISTRIBUTIONS Test::SharedFork 0.29 Time::HiRes 0 perl 5.008001 + Test-Vars-0.014 + pathname: D/DR/DROLSKY/Test-Vars-0.014.tar.gz + provides: + Test::Vars 0.014 + requirements: + B 0 + ExtUtils::MakeMaker 6.59 + List::Util 1.33 + Module::Build::Tiny 0.035 + Test::More 0.88 + parent 0 + perl 5.010000 Test-WWW-Mechanize-1.44 pathname: P/PE/PETDANCE/Test-WWW-Mechanize-1.44.tar.gz provides: diff --git a/lib/MetaCPAN/Sitemap.pm b/lib/MetaCPAN/Sitemap.pm index f63f83e39d..7fe589f798 100644 --- a/lib/MetaCPAN/Sitemap.pm +++ b/lib/MetaCPAN/Sitemap.pm @@ -106,7 +106,7 @@ sub process { $_ = $_ . q{ } for @urls; $self->{size} = @urls; - my $xml = XMLout( + XMLout( { 'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', diff --git a/lib/MetaCPAN/Web/Controller/Account/Favorite.pm b/lib/MetaCPAN/Web/Controller/Account/Favorite.pm index 7701e43bac..f54ff9768f 100644 --- a/lib/MetaCPAN/Web/Controller/Account/Favorite.pm +++ b/lib/MetaCPAN/Web/Controller/Account/Favorite.pm @@ -59,8 +59,6 @@ sub list_as_json : Local : Args(0) { $self->_add_fav_list_to_stash( $c, 1_000 ); - my $user = $c->stash->{user}; - $c->add_surrogate_key( $self->_cache_key_for_user($c) ); $c->cdn_max_age('30d'); diff --git a/lib/MetaCPAN/Web/Controller/Pod.pm b/lib/MetaCPAN/Web/Controller/Pod.pm index 31ccecfec9..bf23d05cfd 100644 --- a/lib/MetaCPAN/Web/Controller/Pod.pm +++ b/lib/MetaCPAN/Web/Controller/Pod.pm @@ -167,7 +167,9 @@ sub view : Private { ul => [ { id => qr/^index$/ } ], }, replace_img => sub { - my ( $tagname, $attrs, $text ) = @_; + + # last arg is $text, which we don't need + my ( $tagname, $attrs, undef ) = @_; my $tag = 'recv; + my ($response) = $cv->recv; if ( !$response ) { $req->croak( "bad response when requesting " . $request->uri ); diff --git a/lib/MetaCPAN/Web/Model/API/Lab.pm b/lib/MetaCPAN/Web/Model/API/Lab.pm index 70967d5b2e..05756e272e 100644 --- a/lib/MetaCPAN/Web/Model/API/Lab.pm +++ b/lib/MetaCPAN/Web/Model/API/Lab.pm @@ -55,15 +55,13 @@ sub _handle_module { } # get the distribution that provides this module - my $cv = $self->cv; my $rm = $self->request("/module/$module")->recv; my %dep = ( dist => $rm->{distribution}, date => $rm->{date}, ); - my $cv2 = $self->cv; - my $rd = $self->request("/release/$rm->{distribution}")->recv; + my $rd = $self->request("/release/$rm->{distribution}")->recv; $dep{license} = $rd->{license}; @@ -75,8 +73,7 @@ sub _handle_module { sub fetch_latest_distros { my ( $self, $size, $pauseid ) = @_; - my $cv = $self->cv; - my $r = $self->request( + my $r = $self->request( '/release/_search', { query => { @@ -104,7 +101,6 @@ sub fetch_latest_distros { foreach my $d ( @{ $r->{hits}{hits} } ) { my $license = $d->{_source}{license}[0]; my $distro = $d->{_source}{distribution}; - my $author = $d->{_source}{author}; my $repo = $d->{_source}{'resources.repository'}; next if $distros{$distro}; # show the first one diff --git a/lib/MetaCPAN/Web/Model/API/Module.pm b/lib/MetaCPAN/Web/Model/API/Module.pm index 537ce54d8f..d9750f2da1 100644 --- a/lib/MetaCPAN/Web/Model/API/Module.pm +++ b/lib/MetaCPAN/Web/Model/API/Module.pm @@ -78,7 +78,7 @@ sub first { } sub requires { - my ( $self, $module, $page, $page_size, $sort ) = @_; + my ( $self, $module, $page, $page_size ) = @_; my $data = $self->request( "/release/requires/$module", diff --git a/lib/MetaCPAN/Web/Model/API/Permission.pm b/lib/MetaCPAN/Web/Model/API/Permission.pm index 6d5699fd83..3acbc67188 100644 --- a/lib/MetaCPAN/Web/Model/API/Permission.pm +++ b/lib/MetaCPAN/Web/Model/API/Permission.pm @@ -53,10 +53,6 @@ sub _get_modules_in_distribution { my $name = shift; return undef unless $name; - # ugh. Can't see a better way to get a model. - my $model = MetaCPAN::Web::Model::API::Release->new( - api_secure => $self->{api_secure} ); - my $res = $self->request("/package/modules/$name")->recv; my @modules = $res->{modules} ? @{ $res->{modules} } : undef; diff --git a/lib/MetaCPAN/Web/Model/API/Release.pm b/lib/MetaCPAN/Web/Model/API/Release.pm index 2d252d9eb4..b932274102 100644 --- a/lib/MetaCPAN/Web/Model/API/Release.pm +++ b/lib/MetaCPAN/Web/Model/API/Release.pm @@ -345,6 +345,11 @@ sub versions { return ( $data->{releases} || [] ); } +sub favorites { + my $self = shift; + $self->request( '/favorite/_search', {} ); +} + sub topuploaders { my ( $self, $range ) = @_; my $range_filter = { diff --git a/lib/MetaCPAN/Web/Test.pm b/lib/MetaCPAN/Web/Test.pm index a2723d49b6..0d48514f31 100644 --- a/lib/MetaCPAN/Web/Test.pm +++ b/lib/MetaCPAN/Web/Test.pm @@ -4,6 +4,9 @@ package MetaCPAN::Web::Test; use strict; use warnings; + +use lib '.'; # require app.psgi under 5.26 + use Plack::Test; use HTTP::Request::Common; use HTTP::Message::PSGI; diff --git a/lib/Plack/Middleware/Assets/FileCached.pm b/lib/Plack/Middleware/Assets/FileCached.pm index c5d2227d72..2df1af94f9 100644 --- a/lib/Plack/Middleware/Assets/FileCached.pm +++ b/lib/Plack/Middleware/Assets/FileCached.pm @@ -79,7 +79,6 @@ sub _build_wrapped { my $file_app = Plack::App::File->new( root => "$cache_dir" )->to_app; my $static_app = sub { - my ($env) = @_; my $res = &$file_app; push @{ $res->[1] }, 'Cache-Control', 'max-age=31556926'; return $res; diff --git a/t/testrules.yml b/t/testrules.yml new file mode 100644 index 0000000000..346e3d549c --- /dev/null +++ b/t/testrules.yml @@ -0,0 +1,5 @@ +--- +seq: + - seq: t/tidyall.t + - par: + - t/**.t diff --git a/t/tidyall.t b/t/tidyall.t index 6357b39952..8e6e526795 100644 --- a/t/tidyall.t +++ b/t/tidyall.t @@ -3,5 +3,13 @@ use strict; use warnings; +# This test is _really_ slow on Travis with Devel::Cover running. Also, +# there's really no reason to run this when coverage tests are running, since +# it's not bringing anything to the table. + use Test::Code::TidyAll; +use Test::More + do { $ENV{COVERAGE} ? ( skip_all => 'skip under Devel::Cover' ) : () }; tidyall_ok( verbose => $ENV{TEST_VERBOSE} ); + +done_testing();