Skip to content

Commit 9781510

Browse files
committed
perltidy
1 parent 4abe8f6 commit 9781510

File tree

21 files changed

+129
-108
lines changed

21 files changed

+129
-108
lines changed

etc/metacpan.pl

+12-5
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,31 @@
66
# ElasticSearch instance, can be either a single server
77
# or an arrayref of servers
88
es => ':9200',
9+
910
# the port of the api server
1011
port => '5000',
12+
1113
# log level
1214
level => 'info',
15+
1316
# appender for Log4perl
1417
# default layout is "%d %p{1} %c: %m{chomp}%n"
1518
# can be overridden using the layout key
1619
# defining logger in metacpan_local.pl will
1720
# override and not append to this configuration
1821
logger => [
1922
{
20-
class => 'Log::Log4perl::Appender::File',
23+
class => 'Log::Log4perl::Appender::File',
2124
filename => $FindBin::RealBin . '/../var/log/metacpan.log',
2225
syswrite => 1,
2326
},
24-
(-t *STDERR ? ({
25-
class => 'Log::Log4perl::Appender::ScreenColoredLevels',
26-
stdout => 0,
27-
}) : ()),
27+
(
28+
-t *STDERR
29+
? ( {
30+
class => 'Log::Log4perl::Appender::ScreenColoredLevels',
31+
stdout => 0,
32+
} )
33+
: ()
34+
),
2835
],
2936
}

etc/metacpan_testing.pl

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
2-
es => ($ENV{ES_TEST} || 'localhost:9900'),
3-
port => '5900',
2+
es => ( $ENV{ES_TEST} || 'localhost:9900' ),
3+
port => '5900',
44
die_on_error => 1,
5-
level => ($ENV{TEST_VERBOSE} ? 'info' : 'warn'),
6-
cpan => 'var/t/tmp/fakecpan',
7-
source_base => 'var/t/tmp/source',
8-
logger => [{
5+
level => ( $ENV{TEST_VERBOSE} ? 'info' : 'warn' ),
6+
cpan => 'var/t/tmp/fakecpan',
7+
source_base => 'var/t/tmp/source',
8+
logger => [ {
99
class => 'Log::Log4perl::Appender::Screen',
10-
name => 'testing'
11-
}]
10+
name => 'testing'
11+
} ]
1212
}

improve-search-results/app.pl

+45-41
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use Mojolicious::Lite;
22

33
use Mojo::Pg;
4-
use List::Util qw(first);
4+
use List::Util qw( first );
55

6-
my $user = getpwuid($<); # for vagrant user on dev box
6+
my $user = getpwuid($<); # for vagrant user on dev box
77

88
# carton exec /opt/perl-5.22.2/bin/perl ./app.pl daemon -m production -l http://*:5000
99

@@ -12,22 +12,22 @@
1212
app->pg->auto_migrate(1)->migrations->from_data;
1313

1414
helper insert_search => sub {
15-
my ($c, $search, $expect) = @_;
16-
return !!$c->pg->db->query(<<' SQL', $search, $expect)->rows;
15+
my ( $c, $search, $expect ) = @_;
16+
return !!$c->pg->db->query( <<' SQL', $search, $expect )->rows;
1717
insert into searches (search, expect) values (?, ?)
1818
SQL
1919
};
2020

2121
helper insert_source => sub {
22-
my ($c, $name, $query) = @_;
23-
return !!$c->pg->db->query(<<' SQL', $name, $query)->rows;
22+
my ( $c, $name, $query ) = @_;
23+
return !!$c->pg->db->query( <<' SQL', $name, $query )->rows;
2424
insert into sources (name, query) values (?, ?, ?)
2525
SQL
2626
};
2727

2828
helper get_results => sub {
29-
my $c = shift;
30-
return $c->pg->db->query(<<' SQL')->expand->hash->{results};
29+
my $c = shift;
30+
return $c->pg->db->query(<<' SQL')->expand->hash->{results};
3131
select json_object_agg(search, results) as results
3232
from (
3333
select
@@ -42,8 +42,8 @@
4242
};
4343

4444
helper perform_all_searches => sub {
45-
my ($c) = @_;
46-
my $queries = $c->pg->db->query(<<' SQL');
45+
my ($c) = @_;
46+
my $queries = $c->pg->db->query(<<' SQL');
4747
select
4848
searches.id as search_id,
4949
sources.id as source_id,
@@ -56,54 +56,58 @@
5656
left join results on searches.id = results.search_id
5757
and sources.id = results.source_id
5858
SQL
59-
my $db = $c->pg->db;
60-
my $sql = 'insert into results (search_id, source_id, rank) values (?, ?, ?)';
61-
$queries->hashes->each(sub{
62-
my $query = shift;
63-
return if $query->{rank};
64-
my $rank = $c->perform_one_search(@{$query}{qw/search expect name query/});
65-
$db->query($sql, @{$query}{qw/search_id source_id/}, $rank);
66-
});
59+
my $db = $c->pg->db;
60+
my $sql
61+
= 'insert into results (search_id, source_id, rank) values (?, ?, ?)';
62+
$queries->hashes->each( sub {
63+
my $query = shift;
64+
return if $query->{rank};
65+
my $rank = $c->perform_one_search(
66+
@{$query}{qw/search expect name query/} );
67+
$db->query( $sql, @{$query}{qw/search_id source_id/}, $rank );
68+
} );
6769
};
6870

6971
helper perform_one_search => sub {
70-
my ($c, $search, $expect, $name, $query) = @_;
72+
my ( $c, $search, $expect, $name, $query ) = @_;
7173

72-
my $rank =
73-
$name eq 'SCO' ? _perform_sco($c, $search, $expect) :
74-
$name eq 'MWEB' ? _perform_mweb($c, $search, $expect) :
75-
_perform_mquery($c, $search, $expect, $query);
74+
my $rank
75+
= $name eq 'SCO' ? _perform_sco( $c, $search, $expect )
76+
: $name eq 'MWEB' ? _perform_mweb( $c, $search, $expect )
77+
: _perform_mquery( $c, $search, $expect, $query );
7678

77-
return $rank // 100;
79+
return $rank // 100;
7880
};
7981

8082
sub _perform_sco {
81-
my ($c, $search, $expect) = @_;
82-
my $url = Mojo::URL->new('http://search.cpan.org/search?mode=all&n=100');
83-
$url->query([query => $search]);
84-
my $tx = $c->app->ua->get($url);
85-
my $res = $tx->res->dom->find('.sr')->map('all_text')->to_array;
86-
my $idx = first { $res->[$_] eq $expect } @{$res->to_array};
87-
return $idx < 0 ? undef : $idx + 1;
83+
my ( $c, $search, $expect ) = @_;
84+
my $url = Mojo::URL->new('http://search.cpan.org/search?mode=all&n=100');
85+
$url->query( [ query => $search ] );
86+
my $tx = $c->app->ua->get($url);
87+
my $res = $tx->res->dom->find('.sr')->map('all_text')->to_array;
88+
my $idx = first { $res->[$_] eq $expect } @{ $res->to_array };
89+
return $idx < 0 ? undef : $idx + 1;
8890
}
8991

9092
sub _perform_mweb {
91-
my ($c, $search, $expect) = @_;
92-
my $url = Mojo::URL->new('https://metacpan.org/search?size=100');
93-
$url->query([q => $search]);
94-
my $tx = $c->app->ua->get($url);
95-
my $res = $tx->res->dom->find('.module-result big strong a')->map('all_text')->to_array;
96-
my $idx = first { $res->[$_] eq $expect } 0 .. $#{$res};
97-
return $idx < 0 ? undef : $idx + 1;
93+
my ( $c, $search, $expect ) = @_;
94+
my $url = Mojo::URL->new('https://metacpan.org/search?size=100');
95+
$url->query( [ q => $search ] );
96+
my $tx = $c->app->ua->get($url);
97+
my $res
98+
= $tx->res->dom->find('.module-result big strong a')->map('all_text')
99+
->to_array;
100+
my $idx = first { $res->[$_] eq $expect } 0 .. $#{$res};
101+
return $idx < 0 ? undef : $idx + 1;
98102
}
99103

100-
sub _perform_mquery {}
104+
sub _perform_mquery { }
101105

102106
get '/' => 'index';
103107

104108
get '/results' => sub {
105-
my $c = shift;
106-
$c->render(json => $c->get_results);
109+
my $c = shift;
110+
$c->render( json => $c->get_results );
107111
};
108112

109113
app->start;

lib/MetaCPAN/Script/Backpan.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ sub build_release_status_map {
8080
(
8181
$self->undo
8282
or exists $self->cpan_file_map->{$author}{$archive}
83-
)
83+
)
8484
? 'cpan'
8585
: 'backpan',
8686
$release->{_id}

lib/MetaCPAN/Script/First.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ sub run {
3131
$release
3232
? log_debug {
3333
"@{[ $release->name ]} by @{[ $release->author ]} was first";
34-
}
34+
}
3535
: log_warn {
3636
"no release found for distribution @{[$distribution->name]}";
3737
};

lib/MetaCPAN/Script/Role/External/Cygwin.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ MIRROR: {
6565

6666
log_debug {
6767
sprintf "Found %d cygwin-CPAN packages",
68-
scalar keys %{ $ret->{dist} }
68+
scalar keys %{ $ret->{dist} }
6969
};
7070

7171
return $ret;

precious.toml

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ tidy-flags = [ "--backup-and-modify-in-place", "--backup-file-extension=/" ]
2929
ok-exit-codes = 0
3030
lint-failure-exit-codes = 2
3131
ignore-stderr = "Begin Error Output Stream"
32+
label = ["perltidy"]
3233

3334
[commands.omegasort-gitignore]
3435
type = "both"

t/lib/Module/Faker/Dist/WithPerl.pm

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ around append_for => sub {
1515
utf8::is_utf8( $_->{content} )
1616
? encode_utf8( $_->{content} )
1717
: $_->{content}
18-
}
19-
grep { $filename eq $_->{file} } @{ $self->append }
18+
}
19+
grep { $filename eq $_->{file} } @{ $self->append }
2020
];
2121
};
2222

t/server/controller/changes.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ done_testing;
128128
sub get_ok {
129129
my ( $cb, $path, $code ) = @_;
130130

131-
ok( my $res = $cb->( GET $path), "GET $path" );
131+
ok( my $res = $cb->( GET $path ), "GET $path" );
132132
is( $res->code, $code, "code $code" );
133133
is(
134134
$res->header('content-type'),

t/server/controller/distribution.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ test_psgi app, sub {
4040
my $cb = shift;
4141
for my $test (@tests) {
4242
my ( $k, $v ) = @{$test};
43-
ok( my $res = $cb->( GET $k), "GET $k" );
43+
ok( my $res = $cb->( GET $k ), "GET $k" );
4444

4545
# TRAVIS 5.18
4646
is( $res->code, $v->{code}, "code " . $v->{code} );

t/server/controller/file.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ my %tests = (
4747
test_psgi app, sub {
4848
my $cb = shift;
4949
while ( my ( $k, $v ) = each %tests ) {
50-
ok( my $res = $cb->( GET $k), "GET $k" );
50+
ok( my $res = $cb->( GET $k ), "GET $k" );
5151
is( $res->code, $v->{code}, "code " . $v->{code} );
5252
is(
5353
$res->header('content-type'),

t/server/controller/mirror.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ test_psgi app, sub {
3434
my $cb = shift;
3535
for my $k ( sort keys %tests ) {
3636
my $v = $tests{$k};
37-
ok( my $res = $cb->( GET $k), "GET $k" );
37+
ok( my $res = $cb->( GET $k ), "GET $k" );
3838
is( $res->code, $v->{code}, "code " . $v->{code} );
3939
is(
4040
$res->header('content-type'),

t/server/controller/module.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ my %tests = (
5757
test_psgi app, sub {
5858
my $cb = shift;
5959
while ( my ( $k, $v ) = each %tests ) {
60-
ok( my $res = $cb->( GET $k), "GET $k" );
60+
ok( my $res = $cb->( GET $k ), "GET $k" );
6161
is( $res->code, $v->{code}, "code " . $v->{code} );
6262
is(
6363
$res->header('content-type'),

t/server/controller/pod.t

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ my $app = MetaCPAN::Server->new->to_app();
6363
my $test = Plack::Test->create($app);
6464

6565
while ( my ( $k, $v ) = each %tests ) {
66-
my $res = $test->request( GET $k);
66+
my $res = $test->request( GET $k );
6767
ok( $res, "GET $k" );
6868
is( $res->code, $v->{code}, "code " . $v->{code} );
6969
is(
@@ -144,7 +144,7 @@ while ( my ( $k, $v ) = each %tests ) {
144144

145145
{
146146
my $path = '/pod/BadPod?show_errors=1';
147-
my $res = $test->request( GET $path);
147+
my $res = $test->request( GET $path );
148148
ok( $res, "GET $path" );
149149
is( $res->code, 200, 'code 200' );
150150
like(

t/server/controller/source.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ my %tests = (
6262
test_psgi app, sub {
6363
my $cb = shift;
6464
while ( my ( $k, $v ) = each %tests ) {
65-
ok( my $res = $cb->( GET $k), "GET $k" );
65+
ok( my $res = $cb->( GET $k ), "GET $k" );
6666
is( $res->code, $v->{code}, "code " . $v->{code} );
6767

6868
test_cache_headers( $res, $v );

t/server/not_found.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ test_psgi app, sub {
2222
for my $test (@tests) {
2323
my ( $path, $code ) = @{$test};
2424

25-
ok( my $res = $cb->( GET $path), "GET $path" );
25+
ok( my $res = $cb->( GET $path ), "GET $path" );
2626
is( $res->code, $code, "code $code" );
2727

2828
# 404 should still be json
+27-25
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
## no critic
22
{
3-
name => 'Binary-Data',
4-
abstract => 'Binary after __DATA__ token',
5-
version => '0.01',
3+
name => 'Binary-Data',
4+
abstract => 'Binary after __DATA__ token',
5+
version => '0.01',
66

7-
# Specify provides so that both modules are included
8-
# in release 'provides' list and the release will get marked as latest.
9-
provides => {
10-
'Binary::Data' => {
11-
file => 'lib/Binary/Data.pm',
12-
version => '0.01'
7+
# Specify provides so that both modules are included
8+
# in release 'provides' list and the release will get marked as latest.
9+
provides => {
10+
'Binary::Data' => {
11+
file => 'lib/Binary/Data.pm',
12+
version => '0.01'
13+
},
14+
'Binary::Data::WithPod' => {
15+
file => 'lib/Binary/Data/WithPod.pm',
16+
version => '0.02'
17+
}
1318
},
14-
'Binary::Data::WithPod' => {
15-
file => 'lib/Binary/Data/WithPod.pm',
16-
version => '0.02'
17-
}
18-
},
1919

20-
X_Module_Faker => {
21-
cpan_author => 'BORISNAT',
22-
append => [ {
23-
file => 'lib/Binary/Data.pm',
24-
content => <<EOF
20+
X_Module_Faker => {
21+
cpan_author => 'BORISNAT',
22+
append => [
23+
{
24+
file => 'lib/Binary/Data.pm',
25+
content => <<EOF
2526
# Module::Faker should prepend 3 lines above this
2627
2728
'hello';
@@ -35,10 +36,10 @@
3536
=he\x50\x00\x7b;\x{0d}=Ddhé\x{01}UÕÌ
3637
3738
EOF
38-
},
39-
{
40-
'file' => 'lib/Binary/Data/WithPod.pm',
41-
'content' => <<EOF
39+
},
40+
{
41+
'file' => 'lib/Binary/Data/WithPod.pm',
42+
'content' => <<EOF
4243
# Module::Faker should prepend 3 lines above this
4344
4445
=head1 NAME
@@ -65,6 +66,7 @@ =head1 DESCRIPTION
6566
6667
=cut
6768
EOF
68-
} ]
69-
}
69+
}
70+
]
71+
}
7072
}

0 commit comments

Comments
 (0)