Skip to content

Commit 6e895c0

Browse files
committedMar 2, 2007
Perl::Critic cleanup
1 parent 8729b9c commit 6e895c0

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed
 

‎lib/WWW/Mechanize.pm

+14-14
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ sub follow_link {
620620

621621
if ( $parms{n} eq 'all' ) {
622622
delete $parms{n};
623-
$self->warn( qq{follow_link(n=>"all") is not valid} );
623+
$self->warn( q{follow_link(n=>"all") is not valid} );
624624
}
625625

626626
my $link = $self->find_link(%parms);
@@ -1608,7 +1608,7 @@ sub submit_form {
16081608

16091609
if ($args{'with_fields'}) {
16101610
$fields || die q{must submit some 'fields' with with_fields};
1611-
$self->form_with_fields(keys %$fields) or die;
1611+
$self->form_with_fields(keys %{$fields}) or die;
16121612
}
16131613
elsif ( my $form_number = $args{'form_number'} ) {
16141614
$self->form_number( $form_number ) or die;
@@ -1621,7 +1621,7 @@ sub submit_form {
16211621
# Maybe a form was set separately, or we'll default to the first form.
16221622
}
16231623

1624-
$self->set_fields( %$fields ) if $fields;
1624+
$self->set_fields( %{$fields} ) if $fields;
16251625

16261626
my $response;
16271627
if ( $args{button} ) {
@@ -1745,7 +1745,7 @@ sub save_content {
17451745
my $filename = shift;
17461746

17471747
open( my $fh, '>', $filename ) or $self->die( "Unable to create $filename: $!" );
1748-
print $fh $self->content;
1748+
print {$fh} $self->content;
17491749
close $fh;
17501750
}
17511751

@@ -1887,7 +1887,7 @@ The four argument form described in L<LWP::UserAgent> is still supported.
18871887

18881888
sub credentials {
18891889
my $self = shift;
1890-
no warnings 'redefine';
1890+
no warnings 'redefine'; ## no critic
18911891

18921892
if (@_ == 4) {
18931893
$saved_method
@@ -2190,10 +2190,10 @@ sub _push_page_stack {
21902190
$self->{page_stack} = [];
21912191

21922192
my $clone = $self->clone;
2193-
push( @$save_stack, $clone );
2193+
push( @{$save_stack}, $clone );
21942194

2195-
while ( @$save_stack > $self->stack_depth ) {
2196-
shift @$save_stack;
2195+
while ( @{$save_stack} > $self->stack_depth ) {
2196+
shift @{$save_stack};
21972197
}
21982198
$self->{page_stack} = $save_stack;
21992199
}
@@ -2208,12 +2208,12 @@ sub _pop_page_stack {
22082208
my $popped = pop @{$self->{page_stack}};
22092209

22102210
# eliminate everything in self
2211-
foreach my $key ( keys %$self ) {
2211+
foreach my $key ( keys %{$self} ) {
22122212
delete $self->{ $key } unless $key eq 'page_stack';
22132213
}
22142214

22152215
# make self just like the popped object
2216-
foreach my $key ( keys %$popped ) {
2216+
foreach my $key ( keys %{$popped} ) {
22172217
$self->{ $key } = $popped->{ $key } unless $key eq 'page_stack';
22182218
}
22192219
}
@@ -2236,7 +2236,7 @@ sub warn {
22362236

22372237
return if $self->quiet;
22382238

2239-
$handler->(@_);
2239+
return $handler->(@_);
22402240
}
22412241

22422242
=head2 die( @messages )
@@ -2251,20 +2251,20 @@ sub die {
22512251

22522252
return unless my $handler = $self->{onerror};
22532253

2254-
$handler->(@_);
2254+
return $handler->(@_);
22552255
}
22562256

22572257

22582258
# NOT an object method!
22592259
sub _warn {
22602260
require Carp;
2261-
&Carp::carp; # pass thru
2261+
&Carp::carp; ## no critic
22622262
}
22632263

22642264
# NOT an object method!
22652265
sub _die {
22662266
require Carp;
2267-
&Carp::croak; # pass thru
2267+
&Carp::croak; ## no critic
22682268
}
22692269

22702270
1; # End of module

‎perlcriticrc

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ allow_leading_tabs = 0
2222
[-RegularExpressions::RequireExtendedFormatting]
2323
[-RegularExpressions::RequireLineBoundaryMatching]
2424

25+
[-ValuesAndExpressions::ProhibitConstantPragma]
2526
[-ValuesAndExpressions::ProhibitEmptyQuotes]
2627

2728
[-Variables::ProhibitPunctuationVars]

‎t/aliases.t

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ BEGIN {
99
}
1010

1111
my @aliases = WWW::Mechanize::known_agent_aliases();
12-
is( scalar @aliases, 6 );
12+
is( scalar @aliases, 6, 'All aliases accounted for' );
1313

1414
for my $alias ( @aliases ) {
15-
like( $alias, qr/^(Mac|Windows|Linux) /, "We only know Mac, Windows or Linux" );
15+
like( $alias, qr/^(Mac|Windows|Linux) /, 'We only know Mac, Windows or Linux' );
1616
}

‎t/local/reload.t

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,21 @@ FIRST_GET: {
2727
my $r = $agent->get($server->url);
2828
isa_ok( $r, 'HTTP::Response' );
2929
ok( $r->is_success, 'Get google webpage');
30-
ok( $agent->is_html );
30+
ok( $agent->is_html, 'Valid HTML' );
3131
is( $agent->title, 'WWW::Mechanize::Shell test page' );
3232
}
3333

3434
INVALIDATE: {
3535
undef $agent->{content};
3636
undef $agent->{ct};
3737
isnt( $agent->title, 'WWW::Mechanize::Shell test page' );
38-
ok( !$agent->is_html );
38+
ok( !$agent->is_html, 'Not HTML' );
3939
}
4040

4141
RELOAD: {
4242
my $r = $agent->reload;
4343
isa_ok( $r, 'HTTP::Response' );
44-
ok( $agent->is_html );
44+
ok( $agent->is_html, 'Valid HTML' );
4545
ok( $agent->title, 'WWW::Mechanize::Shell test page' );
4646
}
4747

0 commit comments

Comments
 (0)
Please sign in to comment.