Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply perlimports to ./t #1244

Merged
merged 4 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,4 @@ requires 'Test::Vars', '0.015';

# author requirements
requires 'Plack::Middleware::Rewrite';
requires 'App::perlimports';
25 changes: 25 additions & 0 deletions perlimports.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Valid log levels are:
# debug, info, notice, warning, error, critical, alert, emergency
# critical, alert and emergency are not currently used.
#
# Please use boolean values in this config file. Negated options (--no-*) are
# not permitted here. Explicitly set options to true or false.
#
# Some of these values deviate from the regular perlimports defaults. In
# particular, you're encouraged to leave preserve_duplicates and
# preserve_unused disabled.

cache = false # setting this to true is currently discouraged
ignore_modules = ["Catalyst::Runtime","Module::Pluggable", "namespace::clean", "Test::More", "Type::Library", "With::Roles"]
ignore_modules_filename = ""
ignore_modules_pattern = "" # regex like "^(Foo|Foo::Bar)"
ignore_modules_pattern_filename = ""
libs = ["lib", "t/lib"]
log_filename = ""
log_level = "warn"
never_export_modules = []
never_export_modules_filename = ""
padding = true
preserve_duplicates = false
preserve_unused = false
tidy_whitespace = true
44 changes: 44 additions & 0 deletions precious.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
excludes = [
".build/**",
"blib/**",
"root/assets/**",
]

[commands.perlimports]
type = "both"
include = [ "**/*.{pl,pm,t,psgi}" ]
cmd = [ "perlimports" ]
lint-flags = ["--lint" ]
tidy-flags = ["-i" ]
ok-exit-codes = 0
expect-stderr = true

[commands.perlcritic]
type = "lint"
include = [ "**/*.{pl,pm,t,psgi}" ]
cmd = [ "perlcritic", "--profile=$PRECIOUS_ROOT/.perlcriticrc" ]
ok-exit-codes = 0
lint-failure-exit-codes = 2

[commands.perltidy]
type = "both"
include = [ "**/*.{pl,pm,t,psgi}" ]
cmd = [ "perltidy", "--profile=$PRECIOUS_ROOT/.perltidyrc" ]
lint-flags = [ "--assert-tidy", "--no-standard-output", "--outfile=/dev/null" ]
tidy-flags = [ "--backup-and-modify-in-place", "--backup-file-extension=/" ]
ok-exit-codes = 0
lint-failure-exit-codes = 2
ignore-stderr = "Begin Error Output Stream"

[commands.omegasort-gitignore]
type = "both"
include = "**/.gitignore"
cmd = [ "omegasort", "--sort", "path", "--unique" ]
lint-flags = "--check"
tidy-flags = "--in-place"
ok-exit-codes = 0
lint-failure-exit-codes = 1
ignore-stderr = [
"The .+ file is not sorted",
"The .+ file is not unique",
]
4 changes: 1 addition & 3 deletions t/00_setup.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ use lib 't/lib';
use CPAN::Faker 0.010 ();
use Devel::Confess;
use MetaCPAN::Script::Tickets ();
use MetaCPAN::Server::Test;
use MetaCPAN::TestHelpers qw(
use MetaCPAN::TestHelpers qw(
fakecpan_configs_dir
fakecpan_dir
get_config
tmp_dir
write_find_ls
);
use MetaCPAN::TestServer ();
use Module::Faker 0.015 (); # Generates META.json.
use Test::More 0.96;
use URI::FromHash qw( uri );

Expand Down
6 changes: 3 additions & 3 deletions t/01_darkpan.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use warnings;
use lib 't/lib';

use Devel::Confess;
use MetaCPAN::DarkPAN ();
use MetaCPAN::TestServer;
use MetaCPAN::Tests::Controller::Search::DownloadURL;
use MetaCPAN::DarkPAN ();
use MetaCPAN::TestServer ();
use MetaCPAN::Tests::Controller::Search::DownloadURL ();
use Test::More;
use Test::RequiresInternet ( 'cpan.metacpan.org' => 80 );

Expand Down
3 changes: 1 addition & 2 deletions t/api/controller/cover.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use Mojo::Base -strict;

use lib 't/lib';

use MetaCPAN::Model::Search ();
use MetaCPAN::TestServer ();
use MetaCPAN::TestServer ();
use Test::More;
use Test::Mojo ();

Expand Down
11 changes: 5 additions & 6 deletions t/lib/MetaCPAN/DarkPAN.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ package MetaCPAN::DarkPAN;

use MetaCPAN::Moose;

use CPAN::Repository::Perms;
use MetaCPAN::TestHelpers qw( get_config write_find_ls );
use CPAN::Repository::Perms ();
use MetaCPAN::TestHelpers qw( write_find_ls );
use MetaCPAN::Types::TypeTiny qw( Path );
use MetaCPAN::Util qw( author_dir );
use OrePAN2::Indexer;
use OrePAN2::Injector;
use Path::Tiny qw( path );
use URI::FromHash qw( uri_object );
use OrePAN2::Indexer ();
use OrePAN2::Injector ();
use URI::FromHash qw( uri_object );

has base_dir => (
is => 'ro',
Expand Down
6 changes: 3 additions & 3 deletions t/lib/MetaCPAN/Server/Test.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package MetaCPAN::Server::Test;
use strict;
use warnings;

use HTTP::Request::Common qw(POST GET DELETE);
use HTTP::Request::Common qw( DELETE GET POST );
use MetaCPAN::Server ();
use Plack::Test;
use Plack::Test qw( test_psgi );
use Test::More;

use base 'Exporter';
Expand Down Expand Up @@ -37,7 +37,7 @@ sub app {
return $app;
}

require MetaCPAN::Model;
use MetaCPAN::Model ();

sub model {
MetaCPAN::Model->new( es => ( $ENV{ES_TEST} ||= 'localhost:9200' ) );
Expand Down
18 changes: 9 additions & 9 deletions t/lib/MetaCPAN/TestHelpers.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ use warnings;
package # no_index
MetaCPAN::TestHelpers;

use Cpanel::JSON::XS;
use File::Copy qw( copy );
use File::pushd qw( pushd );
use FindBin;
use MetaCPAN::Util qw( checkout_root );
use MetaCPAN::Script::Runner;
use Path::Tiny qw( path );
use Cpanel::JSON::XS qw( decode_json encode_json );
use File::Copy qw( copy );
use File::pushd qw( pushd );
use FindBin ();
use MetaCPAN::Util qw( checkout_root );
use MetaCPAN::Script::Runner ();
use Path::Tiny qw( path );
use Test::More;
use Test::Routine::Util;
use Try::Tiny qw( catch try );
use Test::Routine::Util qw( run_tests );
use Try::Tiny qw( catch finally try );

use base 'Exporter';
our @EXPORT = qw(
Expand Down
35 changes: 17 additions & 18 deletions t/lib/MetaCPAN/TestServer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,23 @@ package MetaCPAN::TestServer;

use MetaCPAN::Moose;

use MetaCPAN::DarkPAN ();
use MetaCPAN::Script::Author ();
use MetaCPAN::Script::Cover ();
use MetaCPAN::Script::CPANTestersAPI ();
use MetaCPAN::Script::Favorite ();
use MetaCPAN::Script::First ();
use MetaCPAN::Script::Latest ();
use MetaCPAN::Script::Mapping ();
use MetaCPAN::Script::Mapping::Cover ();
use MetaCPAN::Script::Mirrors ();
use MetaCPAN::Script::Package ();
use MetaCPAN::Script::Permission ();
use MetaCPAN::Script::Release ();
use MetaCPAN::Server ();
use MetaCPAN::TestHelpers qw( fakecpan_dir );
use MetaCPAN::Types::TypeTiny qw( Path HashRef Str );
use Search::Elasticsearch;
use Search::Elasticsearch::TestServer;
use MetaCPAN::Script::Author ();
use MetaCPAN::Script::Cover ();
use MetaCPAN::Script::CPANTestersAPI ();
use MetaCPAN::Script::Favorite ();
use MetaCPAN::Script::First ();
use MetaCPAN::Script::Latest ();
use MetaCPAN::Script::Mapping ();
use MetaCPAN::Script::Mapping::Cover ();
use MetaCPAN::Script::Mirrors ();
use MetaCPAN::Script::Package ();
use MetaCPAN::Script::Permission ();
use MetaCPAN::Script::Release ();
use MetaCPAN::Server ();
use MetaCPAN::TestHelpers qw( fakecpan_dir );
use MetaCPAN::Types::TypeTiny qw( HashRef Path Str );
use Search::Elasticsearch ();
use Search::Elasticsearch::TestServer ();
use Test::More;
use Try::Tiny qw( catch try );

Expand Down
4 changes: 2 additions & 2 deletions t/lib/MetaCPAN/Tests/Controller/Search/DownloadURL.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package MetaCPAN::Tests::Controller::Search::DownloadURL;
use strict;
use warnings;

use MetaCPAN::Server::Test;
use MetaCPAN::TestHelpers;
use MetaCPAN::Server::Test qw( app GET test_psgi );
use MetaCPAN::TestHelpers qw( decode_json_ok );
use Moose;
use Test::More;

Expand Down
2 changes: 1 addition & 1 deletion t/lib/MetaCPAN/Tests/Model.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use Test::Routine;
use MetaCPAN::Server::Test ();
use MetaCPAN::Types::TypeTiny qw( ArrayRef HashRef Str );
use Test::More;
use Try::Tiny qw( catch try );
use Try::Tiny qw( try );

with qw(
MetaCPAN::Tests::Extra
Expand Down
4 changes: 2 additions & 2 deletions t/lib/MetaCPAN/Tests/Release.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use Test::Routine;

use version;

use HTTP::Request::Common;
use List::Util ();
use HTTP::Request::Common qw( GET );
use List::Util ();
use Test::More;
use MetaCPAN::Types::TypeTiny qw( ArrayRef HashRef Str );

Expand Down
6 changes: 3 additions & 3 deletions t/lib/MetaCPAN/Tests/UserAgent.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ package MetaCPAN::Tests::UserAgent;
use Test::Routine;
use Test::More;

use LWP::UserAgent;
use HTTP::Cookies;
use HTTP::Request;
use LWP::UserAgent ();
use HTTP::Cookies ();
use HTTP::Request ();

has cb => (
is => 'ro',
Expand Down
2 changes: 1 addition & 1 deletion t/lib/Module/Faker/Dist/WithPerl.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package # no_index
use Moose;
extends 'Module::Faker::Dist';

use Encode;
use Encode qw( encode_utf8 );

around append_for => sub {
my ( $orig, $self, $filename ) = @_;
Expand Down
4 changes: 2 additions & 2 deletions t/model/archive.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use lib 't/lib';
use Digest::SHA qw( sha1_hex );
use MetaCPAN::TestHelpers qw( fakecpan_dir );
use Test::More;
use Test::Fatal;
use Test::Deep qw(cmp_bag);
use Test::Fatal qw( exception );
use Test::Deep qw( cmp_bag );

my $CLASS = 'MetaCPAN::Model::Archive';
require_ok $CLASS;
Expand Down
3 changes: 1 addition & 2 deletions t/model/release.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use lib 't/lib';
use File::Temp ();
use LWP::Simple qw( getstore );
use MetaCPAN::Model::Release ();
use MetaCPAN::Script::Runner;
use MetaCPAN::TestHelpers qw( get_config );
use MetaCPAN::TestHelpers qw( get_config );
use Test::More;
use Test::RequiresInternet( 'metacpan.org' => 'https' );

Expand Down
5 changes: 2 additions & 3 deletions t/model/release/dependencies.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ use warnings;
use lib 't/lib';

use MetaCPAN::Model::Release ();
use MetaCPAN::Script::Runner;
use MetaCPAN::TestHelpers qw( fakecpan_dir get_config );
use MetaCPAN::TestHelpers qw( fakecpan_dir get_config );
use Test::More;
use Test::Deep qw(cmp_bag);
use Test::Deep qw( cmp_bag );

my $config = get_config();

Expand Down
3 changes: 2 additions & 1 deletion t/model/release/reverse_dependencies.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ use warnings;
use lib 't/lib';

use MetaCPAN::Server ();

use Test::More;

my $c = 'MetaCPAN::Server';
my $c = MetaCPAN::Server::;

subtest 'distribution reverse_dependencies' => sub {
my $data = [
Expand Down
2 changes: 1 addition & 1 deletion t/package.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use warnings;
use lib 't/lib';

use Test::More;
use MetaCPAN::Script::Runner;
use MetaCPAN::Script::Runner ();

local @ARGV = ('package');

Expand Down
2 changes: 1 addition & 1 deletion t/permission.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use warnings;
use lib 't/lib';

use Test::More;
use MetaCPAN::Script::Runner;
use MetaCPAN::Script::Runner ();

local @ARGV = ('permission');

Expand Down
1 change: 0 additions & 1 deletion t/release/bugs.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use strict;
use warnings;
use lib 't/lib';

use MetaCPAN::Server::Test;
use MetaCPAN::TestHelpers qw( test_distribution );
use Test::More;

Expand Down
2 changes: 1 addition & 1 deletion t/release/documentation-hide.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use strict;
use warnings;
use lib 't/lib';

use MetaCPAN::Server::Test;
use MetaCPAN::Server::Test qw( model );
use Test::More;

my $model = model();
Expand Down
1 change: 0 additions & 1 deletion t/release/documentation-not-readme.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use strict;
use warnings;
use lib 't/lib';

use MetaCPAN::Server::Test;
use MetaCPAN::TestHelpers qw( test_release );
use Test::More;

Expand Down
2 changes: 1 addition & 1 deletion t/release/file-changes.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use strict;
use warnings;
use lib 't/lib';

use MetaCPAN::Server::Test;
use MetaCPAN::Server::Test qw( model );
use Test::More;

my $model = model();
Expand Down
3 changes: 1 addition & 2 deletions t/release/file-duplicates.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use strict;
use warnings;
use lib 't/lib';

use Cpanel::JSON::XS ();
use MetaCPAN::Server::Test;
use Cpanel::JSON::XS ();
use MetaCPAN::TestHelpers qw( test_release );
use Test::More;

Expand Down
1 change: 0 additions & 1 deletion t/release/meta-license.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use strict;
use warnings;
use lib 't/lib';

use MetaCPAN::Server::Test;
use MetaCPAN::TestHelpers qw( test_release );
use Test::More;

Expand Down
Loading