Skip to content

Commit 5d9913d

Browse files
committed
Perl Tidy
1 parent f7a528f commit 5d9913d

55 files changed

Lines changed: 628 additions & 713 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.perltidyrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-l=400
2+
-i=4
3+
-dt=4
4+
-it=4
5+
-bar
6+
-nsfs
7+
-nolq
8+
--break-at-old-comma-breakpoints
9+
--format-skipping
10+
--format-skipping-begin='#\s*tidyoff'
11+
--format-skipping-end='#\s*tidyon'

dist.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ copyright_holder = cPanel, Inc.
1717

1818
[PruneFiles]
1919
; don't include Dist::Zilla build file
20-
filenames = dist.ini
20+
filenames = dist.ini .perltidyrc
2121

2222
[AutoPrereqs]
2323
skip = ^Mock|Fake|^English$

lib/cPanel/TaskQueue.pm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ END { undef %valid_processors } # case CPANEL-10871 to avoid a SEGV during gl
257257
[qw(max_task_timeout max_timeout)],
258258
[qw(max_in_process max_running)],
259259
[qw(default_child_timeout default_child_timeout)],
260-
) {
260+
) {
261261
my ( $internal_name, $arg_name ) = @$settings;
262262
if ( exists $args_ref->{$arg_name} && $self->{$internal_name} ne $args_ref->{$arg_name} ) {
263263
$self->{$internal_name} = $args_ref->{$arg_name};
@@ -335,9 +335,9 @@ END { undef %valid_processors } # case CPANEL-10871 to avoid a SEGV during gl
335335
grep {
336336
defined $_
337337
and eval { $_->isa('cPanel::TaskQueue::Task') }
338-
} map {
338+
} map {
339339
eval { cPanel::TaskQueue::Task->reconstitute($_) }
340-
} @{$task_list}
340+
} @{$task_list}
341341
];
342342
}
343343

lib/cPanel/TaskQueue/Cookbook.pod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
=head1 NAME
23

34
cPanel::TaskQueue::Cookbook - some tasty uses of the cPanel::TaskQueue modules.

lib/cPanel/TaskQueue/Ctrl.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ my %commands = (
3333
and each will be queued in turn.',
3434
},
3535
pause => {
36-
code => sub { $_[2]->pause_processing(); return; },
36+
code => sub { $_[2]->pause_processing(); return; },
3737
synopsis => 'pause',
3838
help => ' Pause the processing of waiting tasks from the TaskQueue.',
3939
},
4040
resume => {
41-
code => sub { $_[2]->resume_processing(); return; },
41+
code => sub { $_[2]->resume_processing(); return; },
4242
synopsis => 'resume',
4343
help => ' Resume the processing of waiting tasks from the TaskQueue.',
4444
},

t/00.load.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use Test::More tests => 1;
22

33
BEGIN {
4-
use_ok( 'cPanel::TaskQueue' );
4+
use_ok('cPanel::TaskQueue');
55
}
66

7-
diag( "Testing cPanel::TaskQueue $cPanel::TaskQueue::VERSION" );
7+
diag("Testing cPanel::TaskQueue $cPanel::TaskQueue::VERSION");

t/statefile_bad_call_unlocked.t

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ use warnings;
1212
use cPanel::StateFile;
1313
use MockCacheable;
1414

15-
my $tmpdir = './tmp';
16-
my $dir = "$tmpdir/state_test";
17-
my $file = "$dir/state_dir/state_file";
15+
my $tmpdir = './tmp';
16+
my $dir = "$tmpdir/state_test";
17+
my $file = "$dir/state_dir/state_file";
1818
my $lockname = "$file.lock";
1919

2020
cleanup();
21-
File::Path::mkpath( $tmpdir ) or die "Unable to create temporary directory: $!";
21+
File::Path::mkpath($tmpdir) or die "Unable to create temporary directory: $!";
2222

2323
my $mock_obj = MockCacheable->new;
2424
my $state = cPanel::StateFile->new( { state_file => $file, data_obj => $mock_obj } );
@@ -28,22 +28,31 @@ my $state = cPanel::StateFile->new( { state_file => $file, data_obj => $mock_obj
2828
eval { $guard->call_unlocked(); };
2929
like( $@, qr/Missing coderef/, 'Correctly handle missing arg to call_unlocked' );
3030

31-
eval { $guard->call_unlocked( 'fred' ); };
31+
eval { $guard->call_unlocked('fred'); };
3232
like( $@, qr/Missing coderef/, 'Correctly handle wrong argument to call_unlocked' );
3333

34-
$guard->call_unlocked( sub {
35-
eval { $guard->call_unlocked( sub {} ) };
36-
like( $@, qr/Cannot nest call_unlocked/, 'Correctly identify nested call_unlocked calls.' );
37-
});
34+
$guard->call_unlocked(
35+
sub {
36+
eval {
37+
$guard->call_unlocked( sub { } );
38+
};
39+
like( $@, qr/Cannot nest call_unlocked/, 'Correctly identify nested call_unlocked calls.' );
40+
}
41+
);
3842

39-
$guard->call_unlocked( sub {
40-
eval { $guard->update_file() };
41-
like( $@, qr/Cannot update_file/, 'Cannot relock inside unlock call.' );
42-
});
43+
$guard->call_unlocked(
44+
sub {
45+
eval { $guard->update_file() };
46+
like( $@, qr/Cannot update_file/, 'Cannot relock inside unlock call.' );
47+
}
48+
);
4349

44-
eval { $guard->call_unlocked( sub {
50+
eval {
51+
$guard->call_unlocked(
52+
sub {
4553
die 'test exception';
46-
});
54+
}
55+
);
4756
};
4857
like( $@, qr/test exception/, 'Exceptions are passed out of call correctly.' );
4958
}
@@ -52,5 +61,5 @@ cleanup();
5261

5362
# Discard temporary files that we don't need any more.
5463
sub cleanup {
55-
File::Path::rmtree( $tmpdir ) if -d $tmpdir;
64+
File::Path::rmtree($tmpdir) if -d $tmpdir;
5665
}

t/statefile_bad_policy.t

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,21 @@ use strict;
66
use warnings;
77
use cPanel::StateFile ();
88

9-
eval {
10-
cPanel::StateFile->import( '-logger' );
11-
};
9+
eval { cPanel::StateFile->import('-logger'); };
1210
like( $@, qr/even number/, 'Must have argument pairs.' );
1311

14-
eval {
15-
cPanel::StateFile->import( '-other' => 'one' );
16-
};
12+
eval { cPanel::StateFile->import( '-other' => 'one' ); };
1713
like( $@, qr/Unrecognized/, 'Unknown policy handled.' );
1814

19-
eval {
20-
cPanel::StateFile->import( '-logger' => 'Fred::UnknownLogger' );
21-
};
15+
eval { cPanel::StateFile->import( '-logger' => 'Fred::UnknownLogger' ); };
2216
like( $@, qr/Can't locate/, 'Bad logger module.' );
2317

24-
eval {
25-
cPanel::StateFile->import( '-logger' => {} );
26-
};
18+
eval { cPanel::StateFile->import( '-logger' => {} ); };
2719
like( $@, qr/correct interface/, 'Bad logger object.' );
2820

29-
eval {
30-
cPanel::StateFile->import( '-filelock' => 'Fred::UnknownLocker' );
31-
};
21+
eval { cPanel::StateFile->import( '-filelock' => 'Fred::UnknownLocker' ); };
3222
like( $@, qr/Can't locate/, 'Bad filelock module.' );
3323

34-
eval {
35-
cPanel::StateFile->import( '-filelock' => {} );
36-
};
24+
eval { cPanel::StateFile->import( '-filelock' => {} ); };
3725
like( $@, qr/correct interface/, 'Bad locker object.' );
3826

t/statefile_filelocker_abandoned.t

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use lib "$FindBin::Bin/mocks";
1111

1212
use POSIX qw(strftime);
1313
use File::Path ();
14-
use Test::More tests=>4;
14+
use Test::More tests => 4;
1515

1616
use cPanel::FakeLogger;
1717
use cPanel::StateFile::FileLocker ();
@@ -23,22 +23,22 @@ use cPanel::StateFile::FileLocker ();
2323
my $tmpdir = './tmp';
2424

2525
# Make sure we are clean to start with.
26-
File::Path::rmtree( $tmpdir );
26+
File::Path::rmtree($tmpdir);
2727
my $filename = "$tmpdir/fake.file";
2828
my $lockfile = "$filename.lock";
2929

3030
{
31-
File::Path::mkpath( $tmpdir ) or die "Unable to create tmpdir: $!";
31+
File::Path::mkpath($tmpdir) or die "Unable to create tmpdir: $!";
3232
my $logger = cPanel::FakeLogger->new;
33-
my $locker = cPanel::StateFile::FileLocker->new({logger => $logger, max_age=>120, max_wait=>120});
33+
my $locker = cPanel::StateFile::FileLocker->new( { logger => $logger, max_age => 120, max_wait => 120 } );
3434

3535
# create abandoned lockfile
3636
{
3737
open( my $fh, '>', $lockfile ) or die "Cannot create lockfile.";
38-
print $fh 65537, "\nFred\n", time+5, "\n";
39-
close( $fh );
38+
print $fh 65537, "\nFred\n", time + 5, "\n";
39+
close($fh);
4040
my $start = time;
41-
my $lock = eval { $locker->file_lock( $filename ); };
41+
my $lock = eval { $locker->file_lock($filename); };
4242
ok( $lock, 'Lock returned successfully' );
4343
my @msgs = $logger->get_msgs();
4444
$logger->reset_msgs();
@@ -47,7 +47,7 @@ my $lockfile = "$filename.lock";
4747

4848
my $diff = time - $start;
4949
ok( $diff < 10, "Abandoned: Did not wait too long." );
50-
$locker->file_unlock( $lock ) if $lock;
50+
$locker->file_unlock($lock) if $lock;
5151
}
5252
}
53-
File::Path::rmtree( $tmpdir );
53+
File::Path::rmtree($tmpdir);

t/statefile_filelocker_bad_locks.t

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use lib "$FindBin::Bin/mocks";
1111

1212
use POSIX qw(strftime);
1313
use File::Path ();
14-
use Test::More tests=>4;
14+
use Test::More tests => 4;
1515

1616
use cPanel::FakeLogger;
1717
use cPanel::StateFile::FileLocker ();
@@ -23,39 +23,39 @@ use cPanel::StateFile::FileLocker ();
2323
my $tmpdir = './tmp';
2424

2525
# Make sure we are clean to start with.
26-
File::Path::rmtree( $tmpdir );
27-
File::Path::mkpath( $tmpdir ) or die "Unable to create temporary directory: $!";
26+
File::Path::rmtree($tmpdir);
27+
File::Path::mkpath($tmpdir) or die "Unable to create temporary directory: $!";
2828
my $filename = "$tmpdir/fake.file";
2929
my $lockfile = "$filename.lock";
3030

3131
my $logger = cPanel::FakeLogger->new;
32-
my $locker = cPanel::StateFile::FileLocker->new({logger => $logger, max_age=>120, max_wait=>120});
32+
my $locker = cPanel::StateFile::FileLocker->new( { logger => $logger, max_age => 120, max_wait => 120 } );
3333

3434
# Someone else's lockfile
3535
{
3636
open( my $fh, '>', $lockfile ) or die "Cannot create lockfile.";
37-
print $fh "1\n$0\n", time+200, "\n";
38-
close( $fh );
39-
eval { $locker->file_unlock( $lockfile ) };
37+
print $fh "1\n$0\n", time + 200, "\n";
38+
close($fh);
39+
eval { $locker->file_unlock($lockfile) };
4040
like( $@, qr/locked by another/, 'Did not unlock belonging to someone else' );
4141
ok( -e $lockfile, 'Empty: lockfile not removed' );
4242
unlink $lockfile;
4343
}
4444

4545
# Attempt to double lock a file
4646
{
47-
my $lock = $locker->file_lock( $filename );
48-
eval { $locker->file_lock( $filename ); };
47+
my $lock = $locker->file_lock($filename);
48+
eval { $locker->file_lock($filename); };
4949
like( $@, qr/relock/, 'Not allowed to double-lock' );
50-
$locker->file_unlock( $lock );
50+
$locker->file_unlock($lock);
5151
}
5252

5353
{
5454
open( my $fh, '>', $lockfile ) or die "Unable to create fake lockfile: $!\n";
5555
print $fh "This is not actually a lock file\n";
5656
close $fh;
5757

58-
eval { $locker->file_lock( $filename ); };
58+
eval { $locker->file_lock($filename); };
5959
like( $@, qr/Invalid lock file/, 'Correctly handle invalid lock file.' );
6060
}
61-
File::Path::rmtree( $tmpdir );
61+
File::Path::rmtree($tmpdir);

0 commit comments

Comments
 (0)