Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Perl::Critic cleanup

  • Loading branch information...
commit 6e895c0c1618b33f4d147dfffec6a56f5d63ec7f 1 parent 8729b9c
@petdance petdance authored
View
28 lib/WWW/Mechanize.pm
@@ -620,7 +620,7 @@ sub follow_link {
if ( $parms{n} eq 'all' ) {
delete $parms{n};
- $self->warn( qq{follow_link(n=>"all") is not valid} );
+ $self->warn( q{follow_link(n=>"all") is not valid} );
}
my $link = $self->find_link(%parms);
@@ -1608,7 +1608,7 @@ sub submit_form {
if ($args{'with_fields'}) {
$fields || die q{must submit some 'fields' with with_fields};
- $self->form_with_fields(keys %$fields) or die;
+ $self->form_with_fields(keys %{$fields}) or die;
}
elsif ( my $form_number = $args{'form_number'} ) {
$self->form_number( $form_number ) or die;
@@ -1621,7 +1621,7 @@ sub submit_form {
# Maybe a form was set separately, or we'll default to the first form.
}
- $self->set_fields( %$fields ) if $fields;
+ $self->set_fields( %{$fields} ) if $fields;
my $response;
if ( $args{button} ) {
@@ -1745,7 +1745,7 @@ sub save_content {
my $filename = shift;
open( my $fh, '>', $filename ) or $self->die( "Unable to create $filename: $!" );
- print $fh $self->content;
+ print {$fh} $self->content;
close $fh;
}
@@ -1887,7 +1887,7 @@ The four argument form described in L<LWP::UserAgent> is still supported.
sub credentials {
my $self = shift;
- no warnings 'redefine';
+ no warnings 'redefine'; ## no critic
if (@_ == 4) {
$saved_method
@@ -2190,10 +2190,10 @@ sub _push_page_stack {
$self->{page_stack} = [];
my $clone = $self->clone;
- push( @$save_stack, $clone );
+ push( @{$save_stack}, $clone );
- while ( @$save_stack > $self->stack_depth ) {
- shift @$save_stack;
+ while ( @{$save_stack} > $self->stack_depth ) {
+ shift @{$save_stack};
}
$self->{page_stack} = $save_stack;
}
@@ -2208,12 +2208,12 @@ sub _pop_page_stack {
my $popped = pop @{$self->{page_stack}};
# eliminate everything in self
- foreach my $key ( keys %$self ) {
+ foreach my $key ( keys %{$self} ) {
delete $self->{ $key } unless $key eq 'page_stack';
}
# make self just like the popped object
- foreach my $key ( keys %$popped ) {
+ foreach my $key ( keys %{$popped} ) {
$self->{ $key } = $popped->{ $key } unless $key eq 'page_stack';
}
}
@@ -2236,7 +2236,7 @@ sub warn {
return if $self->quiet;
- $handler->(@_);
+ return $handler->(@_);
}
=head2 die( @messages )
@@ -2251,20 +2251,20 @@ sub die {
return unless my $handler = $self->{onerror};
- $handler->(@_);
+ return $handler->(@_);
}
# NOT an object method!
sub _warn {
require Carp;
- &Carp::carp; # pass thru
+ &Carp::carp; ## no critic
}
# NOT an object method!
sub _die {
require Carp;
- &Carp::croak; # pass thru
+ &Carp::croak; ## no critic
}
1; # End of module
View
1  perlcriticrc
@@ -22,6 +22,7 @@ allow_leading_tabs = 0
[-RegularExpressions::RequireExtendedFormatting]
[-RegularExpressions::RequireLineBoundaryMatching]
+[-ValuesAndExpressions::ProhibitConstantPragma]
[-ValuesAndExpressions::ProhibitEmptyQuotes]
[-Variables::ProhibitPunctuationVars]
View
4 t/aliases.t
@@ -9,8 +9,8 @@ BEGIN {
}
my @aliases = WWW::Mechanize::known_agent_aliases();
-is( scalar @aliases, 6 );
+is( scalar @aliases, 6, 'All aliases accounted for' );
for my $alias ( @aliases ) {
- like( $alias, qr/^(Mac|Windows|Linux) /, "We only know Mac, Windows or Linux" );
+ like( $alias, qr/^(Mac|Windows|Linux) /, 'We only know Mac, Windows or Linux' );
}
View
6 t/local/reload.t
@@ -27,7 +27,7 @@ FIRST_GET: {
my $r = $agent->get($server->url);
isa_ok( $r, 'HTTP::Response' );
ok( $r->is_success, 'Get google webpage');
- ok( $agent->is_html );
+ ok( $agent->is_html, 'Valid HTML' );
is( $agent->title, 'WWW::Mechanize::Shell test page' );
}
@@ -35,13 +35,13 @@ INVALIDATE: {
undef $agent->{content};
undef $agent->{ct};
isnt( $agent->title, 'WWW::Mechanize::Shell test page' );
- ok( !$agent->is_html );
+ ok( !$agent->is_html, 'Not HTML' );
}
RELOAD: {
my $r = $agent->reload;
isa_ok( $r, 'HTTP::Response' );
- ok( $agent->is_html );
+ ok( $agent->is_html, 'Valid HTML' );
ok( $agent->title, 'WWW::Mechanize::Shell test page' );
}
Please sign in to comment.
Something went wrong with that request. Please try again.