Skip to content

Commit d593eba

Browse files
authored
Merge pull request #42 from atoomic/tidy++
Mass Tidy files using current policy
2 parents 26ae9a6 + 200ecea commit d593eba

21 files changed

Lines changed: 69 additions & 67 deletions

lib/cPanel/StateFile.pm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ my $are_policies_set = 0;
9494
sub import {
9595
my ( $class, @args ) = @_;
9696
die 'Not an even number of arguments to the $pkg module' if @args % 2;
97-
die 'Policies already set elsewhere' if $are_policies_set;
97+
die 'Policies already set elsewhere' if $are_policies_set;
9898
return 1 unless @args; # Don't set the policies flag.
9999

100100
while (@args) {
@@ -146,7 +146,7 @@ sub import {
146146
sub new {
147147
my ( $class, $args_ref ) = @_;
148148
$pkg->throw('Args parameter must be a hash reference.') unless 'HASH' eq ref $args_ref;
149-
$pkg->throw('No StateFile.') unless exists $args_ref->{state};
149+
$pkg->throw('No StateFile.') unless exists $args_ref->{state};
150150

151151
my $self = bless { state_file => $args_ref->{state} }, $class;
152152

@@ -340,7 +340,7 @@ sub import {
340340
my $data_obj = $args_ref->{data_obj};
341341
$self->throw('Data object does not have required interface.')
342342
unless eval { $data_obj->can('load_from_cache') }
343-
and eval { $data_obj->can('save_to_cache') };
343+
and eval { $data_obj->can('save_to_cache') };
344344

345345
my ( $dirname, $file ) = ( $args_ref->{state_file} =~ m{^(.*)/([^/]*)$}g );
346346
$dirname =~ s{[^/]+/\.\./}{/}g; # resolve parent references

lib/cPanel/StateFile/FileLocker.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ sub new {
88
my ( $class, $args_hr ) = @_;
99
$args_hr = {} unless defined $args_hr;
1010
die "Argument to new must be a hash reference.\n" unless 'HASH' eq ref $args_hr;
11-
die "Required logger argument is missing.\n" unless exists $args_hr->{logger};
11+
die "Required logger argument is missing.\n" unless exists $args_hr->{logger};
1212
my %args = (
1313
attempts => 5,
1414
max_wait => 300, # five minutes
@@ -192,7 +192,7 @@ sub _read_lock_file {
192192

193193
chomp( $pid, $name, $wait_time );
194194
$self->_throw("Invalid lock file: '$pid' is not a PID.") if $pid =~ /\D/;
195-
$name = '<unknown>' unless length $name;
195+
$name = '<unknown>' unless length $name;
196196
$wait_time = 0 if $wait_time =~ /\D/;
197197
return ( $pid, $name, $wait_time );
198198
}

lib/cPanel/TaskQueue.pm

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ my $the_serializer;
4040
sub import {
4141
my $class = shift;
4242
die 'Not an even number of arguments to the ' . __PACKAGE__ . " module\n" if @_ % 2;
43-
die "Policies already set elsewhere\n" if $are_policies_set;
43+
die "Policies already set elsewhere\n" if $are_policies_set;
4444
return 1 unless @_; # Don't set the policies flag.
4545

4646
while (@_) {
@@ -91,7 +91,7 @@ sub _get_serializer {
9191
}
9292

9393
# Replacement for List::Util::first, so I don't need to bring in the whole module.
94-
sub _first (&@) { ## no critic(ProhibitSubroutinePrototypes)
94+
sub _first (&@) { ## no critic(ProhibitSubroutinePrototypes)
9595
my $pred = shift;
9696
local $_;
9797
foreach (@_) {
@@ -319,8 +319,8 @@ END { undef %valid_processors } # case CPANEL-10871 to avoid a SEGV during gl
319319
$self->{default_child_timeout} = $meta->{def_child_to} if $meta->{def_child_to} > 0;
320320
$self->{_bump_size} = $meta->{_bump_size} // '';
321321

322-
$self->{paused} = ( exists $meta->{paused} && $meta->{paused} ) ? 1 : 0;
323-
$self->{defer_obj} = exists $meta->{defer_obj} ? $meta->{defer_obj} : undef;
322+
$self->{paused} = ( exists $meta->{paused} && $meta->{paused} ) ? 1 : 0;
323+
$self->{defer_obj} = exists $meta->{defer_obj} ? $meta->{defer_obj} : undef;
324324

325325
# Clean queues that have been read from disk.
326326
$self->{queue_waiting} = _clean_task_list( $meta->{waiting_queue} );
@@ -629,7 +629,7 @@ END { undef %valid_processors } # case CPANEL-10871 to avoid a SEGV during gl
629629
eval {
630630
local $SIG{'ALRM'} = sub { die "time out reached\n"; };
631631
$orig_alarm = alarm( $self->_timeout($processor) );
632-
$pid = $processor->process_task( $task->clone(), $self->{disk_state}->get_logger() );
632+
$pid = $processor->process_task( $task->clone(), $self->{disk_state}->get_logger() );
633633
alarm $orig_alarm;
634634
1;
635635
} or do {
@@ -639,6 +639,7 @@ END { undef %valid_processors } # case CPANEL-10871 to avoid a SEGV during gl
639639
}
640640
);
641641
}
642+
642643
# Deal with a child process or remove from processing.
643644
if ($pid) {
644645
$task->set_pid($pid);

lib/cPanel/TaskQueue/Ctrl.pm

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ my %commands = (
127127
sub new {
128128
my ( $class, $args ) = @_;
129129

130-
$args = {} unless defined $args;
130+
$args = {} unless defined $args;
131131
die "Argument to new is not a hashref.\n" unless 'HASH' eq ref $args;
132132
foreach my $arg (@required) {
133133
die "Missing required '$arg' argument.\n" unless defined $args->{$arg} and length $args->{$arg};
@@ -140,14 +140,14 @@ sub new {
140140
$self->{$arg} = $args->{$arg};
141141
}
142142
$self->{sdir} ||= $self->{qdir} if $self->{sname};
143-
$self->{out} ||= \*STDOUT;
143+
$self->{out} ||= \*STDOUT;
144144

145145
return bless $self, $class;
146146
}
147147

148148
sub run {
149149
my ( $self, $cmd, @args ) = @_;
150-
die "No command supplied to run.\n" unless $cmd;
150+
die "No command supplied to run.\n" unless $cmd;
151151
die "Unrecognized command '$cmd' to run.\n" unless exists $commands{$cmd};
152152

153153
$commands{$cmd}->{code}->( $self, $self->{out}, $self->_get_queue(), $self->_get_scheduler(), @args );
@@ -177,7 +177,7 @@ sub _get_queue {
177177
{
178178
name => $self->{qname},
179179
state_dir => $self->{qdir},
180-
( exists $self->{logger} ? ( logger => $self->{logger} ) : () ),
180+
( exists $self->{logger} ? ( logger => $self->{logger} ) : () ),
181181
( defined $self->{serial} ? ( serial => $format{ lc $self->{serial} } ) : () ),
182182
}
183183
);
@@ -194,7 +194,7 @@ sub _get_scheduler {
194194
{
195195
name => $self->{sname},
196196
state_dir => $self->{sdir},
197-
( exists $self->{logger} ? ( logger => $self->{logger} ) : () ),
197+
( exists $self->{logger} ? ( logger => $self->{logger} ) : () ),
198198
( defined $self->{serial} ? ( serial => $format{ lc $self->{serial} } ) : () ),
199199
}
200200
);
@@ -318,7 +318,7 @@ sub list_tasks {
318318
my ( $ctrl, $fh, $queue, $sched, @subcmds ) = @_;
319319
my $print = \&_print_task;
320320
if ( _any_is( 'verbose', @subcmds ) ) {
321-
$print = \&_verbosely_print_task;
321+
$print = \&_verbosely_print_task;
322322
@subcmds = grep { $_ ne 'verbose' } @subcmds;
323323
}
324324

@@ -451,7 +451,7 @@ sub _convert_a_state_file {
451451
my $curr_serial = $q->_serializer();
452452
if ( $new_serial ne $curr_serial ) {
453453
my $curr_state_file = $q->_state_file();
454-
my $new_state_file = $new_serial->filename( substr( $curr_state_file, 0, rindex( $curr_state_file, '.' ) ) );
454+
my $new_state_file = $new_serial->filename( substr( $curr_state_file, 0, rindex( $curr_state_file, '.' ) ) );
455455
open my $ifh, '<', $curr_state_file or die "Unable to read '$curr_state_file': $!\n";
456456
open my $ofh, '>', $new_state_file or die "Unable to write '$new_state_file': $!\n";
457457
$new_serial->save( $ofh, $curr_serial->load($ifh) );
@@ -541,9 +541,9 @@ sub delete_unprocessed_tasks {
541541

542542
sub _print_task {
543543
my ( $fh, $task ) = @_;
544-
print $fh '[', $task->uuid, ']: ', $task->full_command, "\n";
544+
print $fh '[', $task->uuid, ']: ', $task->full_command, "\n";
545545
print $fh "\tQueued: ", scalar( localtime $task->timestamp ), "\n";
546-
print $fh "\tStarted: ", scalar( localtime $task->started ), "\n" if defined $task->started;
546+
print $fh "\tStarted: ", scalar( localtime $task->started ), "\n" if defined $task->started;
547547
return;
548548
}
549549

lib/cPanel/TaskQueue/PluginManager.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ sub load_all_plugins {
2020
sub load_plugins {
2121
my ( $root_dir, $namespace ) = @_;
2222

23-
die "No directory supplied for finding plugins.\n" unless defined $root_dir and length $root_dir;
24-
die "Supplied directory '$root_dir' does not exist.\n" unless -d $root_dir;
23+
die "No directory supplied for finding plugins.\n" unless defined $root_dir and length $root_dir;
24+
die "Supplied directory '$root_dir' does not exist.\n" unless -d $root_dir;
2525
die "Supplied directory '$root_dir' not part of Perl's include path.\n" unless grep { $_ eq $root_dir } @INC;
2626

2727
die "No namespace for plugins specified.\n" unless defined $namespace and length $namespace;

lib/cPanel/TaskQueue/Processor.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ use strict;
7373
# Utility functions
7474
sub checked_system {
7575
my ( $self, $args ) = @_;
76-
die "Argument must be a hashref." unless ref $args eq 'HASH';
76+
die "Argument must be a hashref." unless ref $args eq 'HASH';
7777
die "Missing required 'logger' argument." unless $args->{'logger'};
7878
$args->{'logger'}->throw("Missing required 'cmd' argument.")
7979
unless defined $args->{'cmd'} && length $args->{'cmd'};

lib/cPanel/TaskQueue/Scheduler.pm

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ my $pkg = __PACKAGE__;
3030
sub import {
3131
my $class = shift;
3232
die "Not an even number of arguments to the $pkg module\n" if @_ % 2;
33-
die "Policies already set elsewhere\n" if $are_policies_set;
33+
die "Policies already set elsewhere\n" if $are_policies_set;
3434
return 1 unless @_; # Don't set the policies flag.
3535

3636
while (@_) {
@@ -80,7 +80,7 @@ sub _get_serializer {
8080
}
8181

8282
# Replacement for List::Util::first, so I don't need to bring in the whole module.
83-
sub _first (&@) { ## no critic(ProhibitSubroutinePrototypes)
83+
sub _first (&@) { ## no critic(ProhibitSubroutinePrototypes)
8484
my $pred = shift;
8585
local $_;
8686
foreach (@_) {
@@ -236,11 +236,11 @@ my $tasksched_uuid = 'TaskQueue-Scheduler';
236236
my ( $self, $command, $args ) = @_;
237237

238238
$self->throw('Cannot queue an empty command.') unless defined $command;
239-
$self->throw('Args is not a hash ref.') unless defined $args and 'HASH' eq ref $args;
239+
$self->throw('Args is not a hash ref.') unless defined $args and 'HASH' eq ref $args;
240240

241241
my $time = time;
242242
$time += $args->{delay_seconds} if exists $args->{delay_seconds};
243-
$time = $args->{at_time} if exists $args->{at_time};
243+
$time = $args->{at_time} if exists $args->{at_time};
244244

245245
if ( eval { $command->isa('cPanel::TaskQueue::Task') } ) {
246246
if ( 0 == $command->retries_remaining() ) {
@@ -378,7 +378,7 @@ my $tasksched_uuid = 'TaskQueue-Scheduler';
378378
};
379379
my $ex = $@;
380380
$guard->update_file() if $count && $guard;
381-
$self->throw($ex) if $ex;
381+
$self->throw($ex) if $ex;
382382

383383
return $count;
384384
}
@@ -406,7 +406,7 @@ my $tasksched_uuid = 'TaskQueue-Scheduler';
406406
};
407407
my $ex = $@;
408408
$guard->update_file() if @ids;
409-
$self->throw($ex) if $ex;
409+
$self->throw($ex) if $ex;
410410

411411
return @ids;
412412
}
@@ -441,7 +441,7 @@ my $tasksched_uuid = 'TaskQueue-Scheduler';
441441
my ( $self, $time, $task ) = @_;
442442

443443
my $guard = $self->{disk_state}->synch();
444-
my $item = { time => $time, task => $task };
444+
my $item = { time => $time, task => $task };
445445

446446
# if the list is empty, or time after all in list.
447447
if ( !@{ $self->{time_queue} } or $time >= $self->{time_queue}->[-1]->{time} ) {

lib/cPanel/TaskQueue/Task.pm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use strict;
77
# Namespace for the ids created by this class.
88
my $task_uuid = 'TaskQueue-Task';
99

10-
my @fields = qw/_command _argstring _args _timestamp _uuid _child_timeout _started _pid _retries _userdata/;
10+
my @fields = qw/_command _argstring _args _timestamp _uuid _child_timeout _started _pid _retries _userdata/;
1111
my @must_be_defined_fields = grep { $_ ne '_pid' && $_ ne '_started' } @fields;
1212

1313
# These methods are intended to help document the importance of the message and to supply 'seam' that
@@ -92,7 +92,7 @@ sub reconstitute {
9292
}
9393
$class->_throw("Missing '_pid' field in supplied hash") unless exists $hash->{_pid};
9494
$class->_throw("Missing '_started' field in supplied hash") unless exists $hash->{_started};
95-
$class->_throw(q{The '_args' field must be an array}) unless ref [] eq ref $hash->{_args};
95+
$class->_throw(q{The '_args' field must be an array}) unless ref [] eq ref $hash->{_args};
9696

9797
return bless {
9898
%$hash,
@@ -166,7 +166,7 @@ sub get_userdata {
166166
my $self = shift;
167167
my $key = shift;
168168
$self->_throw('No userdata key specified') unless defined $key;
169-
return unless exists $self->{_userdata}->{$key};
169+
return unless exists $self->{_userdata}->{$key};
170170
return $self->{_userdata}->{$key};
171171
}
172172

t/statefile_filelocker_abandoned.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ my $lockfile = "$filename.lock";
3838
print $fh 65537, "\nFred\n", time + 5, "\n";
3939
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();

t/statefile_filelocker_empty_lockfile.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ my $lockfile = "$filename.lock";
4343
like( $msgs[0], qr/info: .*?Old, but empty/, 'Empty: Empty file message detected.' );
4444

4545
my $diff = time - $start;
46-
ok( $diff < 10, "Very old lockfile taken out quickly." );
46+
ok( $diff < 10, "Very old lockfile taken out quickly." );
4747
ok( open( my $fh, '<', $lockfile ), 'Lockfile readable' );
4848
chomp( my ( $pid, $name, $wait_time ) = <$fh> );
4949
close($fh);

0 commit comments

Comments
 (0)