Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Perl::Critic cleanup

  • Loading branch information...
commit 6e895c0c1618b33f4d147dfffec6a56f5d63ec7f 1 parent 8729b9c
Andy Lester authored
28  lib/WWW/Mechanize.pm
@@ -620,7 +620,7 @@ sub follow_link {
620 620
 
621 621
     if ( $parms{n} eq 'all' ) {
622 622
         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} );
624 624
     }
625 625
 
626 626
     my $link = $self->find_link(%parms);
@@ -1608,7 +1608,7 @@ sub submit_form {
1608 1608
 
1609 1609
     if ($args{'with_fields'}) {
1610 1610
         $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;
1612 1612
     }
1613 1613
     elsif ( my $form_number = $args{'form_number'} ) {
1614 1614
         $self->form_number( $form_number ) or die;
@@ -1621,7 +1621,7 @@ sub submit_form {
1621 1621
         # Maybe a form was set separately, or we'll default to the first form.
1622 1622
     }
1623 1623
 
1624  
-    $self->set_fields( %$fields ) if $fields;
  1624
+    $self->set_fields( %{$fields} ) if $fields;
1625 1625
 
1626 1626
     my $response;
1627 1627
     if ( $args{button} ) {
@@ -1745,7 +1745,7 @@ sub save_content {
1745 1745
     my $filename = shift;
1746 1746
 
1747 1747
     open( my $fh, '>', $filename ) or $self->die( "Unable to create $filename: $!" );
1748  
-    print $fh $self->content;
  1748
+    print {$fh} $self->content;
1749 1749
     close $fh;
1750 1750
 }
1751 1751
 
@@ -1887,7 +1887,7 @@ The four argument form described in L<LWP::UserAgent> is still supported.
1887 1887
 
1888 1888
     sub credentials {
1889 1889
         my $self = shift;
1890  
-        no warnings 'redefine';
  1890
+        no warnings 'redefine'; ## no critic
1891 1891
 
1892 1892
         if (@_ == 4) {
1893 1893
             $saved_method
@@ -2190,10 +2190,10 @@ sub _push_page_stack {
2190 2190
         $self->{page_stack} = [];
2191 2191
 
2192 2192
         my $clone = $self->clone;
2193  
-        push( @$save_stack, $clone );
  2193
+        push( @{$save_stack}, $clone );
2194 2194
 
2195  
-        while ( @$save_stack > $self->stack_depth ) {
2196  
-            shift @$save_stack;
  2195
+        while ( @{$save_stack} > $self->stack_depth ) {
  2196
+            shift @{$save_stack};
2197 2197
         }
2198 2198
         $self->{page_stack} = $save_stack;
2199 2199
     }
@@ -2208,12 +2208,12 @@ sub _pop_page_stack {
2208 2208
         my $popped = pop @{$self->{page_stack}};
2209 2209
 
2210 2210
         # eliminate everything in self
2211  
-        foreach my $key ( keys %$self ) {
  2211
+        foreach my $key ( keys %{$self} ) {
2212 2212
             delete $self->{ $key }              unless $key eq 'page_stack';
2213 2213
         }
2214 2214
 
2215 2215
         # make self just like the popped object
2216  
-        foreach my $key ( keys %$popped ) {
  2216
+        foreach my $key ( keys %{$popped} ) {
2217 2217
             $self->{ $key } = $popped->{ $key } unless $key eq 'page_stack';
2218 2218
         }
2219 2219
     }
@@ -2236,7 +2236,7 @@ sub warn {
2236 2236
 
2237 2237
     return if $self->quiet;
2238 2238
 
2239  
-    $handler->(@_);
  2239
+    return $handler->(@_);
2240 2240
 }
2241 2241
 
2242 2242
 =head2 die( @messages )
@@ -2251,20 +2251,20 @@ sub die {
2251 2251
 
2252 2252
     return unless my $handler = $self->{onerror};
2253 2253
 
2254  
-    $handler->(@_);
  2254
+    return $handler->(@_);
2255 2255
 }
2256 2256
 
2257 2257
 
2258 2258
 # NOT an object method!
2259 2259
 sub _warn {
2260 2260
     require Carp;
2261  
-    &Carp::carp; # pass thru
  2261
+    &Carp::carp; ## no critic
2262 2262
 }
2263 2263
 
2264 2264
 # NOT an object method!
2265 2265
 sub _die {
2266 2266
     require Carp;
2267  
-    &Carp::croak; # pass thru
  2267
+    &Carp::croak; ## no critic
2268 2268
 }
2269 2269
 
2270 2270
 1; # End of module
1  perlcriticrc
@@ -22,6 +22,7 @@ allow_leading_tabs = 0
22 22
 [-RegularExpressions::RequireExtendedFormatting]
23 23
 [-RegularExpressions::RequireLineBoundaryMatching]
24 24
 
  25
+[-ValuesAndExpressions::ProhibitConstantPragma]
25 26
 [-ValuesAndExpressions::ProhibitEmptyQuotes]
26 27
 
27 28
 [-Variables::ProhibitPunctuationVars]
4  t/aliases.t
@@ -9,8 +9,8 @@ BEGIN {
9 9
 }
10 10
 
11 11
 my @aliases = WWW::Mechanize::known_agent_aliases();
12  
-is( scalar @aliases, 6 );
  12
+is( scalar @aliases, 6, 'All aliases accounted for' );
13 13
 
14 14
 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' );
16 16
 }
6  t/local/reload.t
@@ -27,7 +27,7 @@ FIRST_GET: {
27 27
     my $r = $agent->get($server->url);
28 28
     isa_ok( $r, 'HTTP::Response' );
29 29
     ok( $r->is_success, 'Get google webpage');
30  
-    ok( $agent->is_html );
  30
+    ok( $agent->is_html, 'Valid HTML' );
31 31
     is( $agent->title, 'WWW::Mechanize::Shell test page' );
32 32
 }
33 33
 
@@ -35,13 +35,13 @@ INVALIDATE: {
35 35
     undef $agent->{content};
36 36
     undef $agent->{ct};
37 37
     isnt( $agent->title, 'WWW::Mechanize::Shell test page' );
38  
-    ok( !$agent->is_html );
  38
+    ok( !$agent->is_html, 'Not HTML' );
39 39
 }
40 40
 
41 41
 RELOAD: {
42 42
     my $r = $agent->reload;
43 43
     isa_ok( $r, 'HTTP::Response' );
44  
-    ok( $agent->is_html );
  44
+    ok( $agent->is_html, 'Valid HTML' );
45 45
     ok( $agent->title, 'WWW::Mechanize::Shell test page' );
46 46
 }
47 47
 

0 notes on commit 6e895c0

Please sign in to comment.
Something went wrong with that request. Please try again.