Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
use consistent line length
  • Loading branch information
kraih committed Aug 28, 2015
1 parent 38f5fe4 commit a6382fd
Show file tree
Hide file tree
Showing 61 changed files with 301 additions and 426 deletions.
2 changes: 1 addition & 1 deletion .perltidyrc
@@ -1,7 +1,7 @@
-pbp # Start with Perl Best Practices
-w # Show all warnings
-iob # Ignore old breakpoints
-l=79 # 79 characters per line
-l=80 # 80 characters per line
-mbl=2 # No more than 2 blank lines
-i=2 # Indentation is 2 columns
-ci=2 # Continuation indentation is 2 columns
Expand Down
3 changes: 1 addition & 2 deletions lib/Mojo/Asset/Memory.pm
Expand Up @@ -16,8 +16,7 @@ sub add_chunk {

# Upgrade if necessary
$self->{content} .= $chunk // '';
return $self
if !$self->auto_upgrade || $self->size <= $self->max_memory_size;
return $self if !$self->auto_upgrade || $self->size <= $self->max_memory_size;
my $file = Mojo::Asset::File->new;
return $file->add_chunk($self->emit(upgrade => $file)->slurp);
}
Expand Down
3 changes: 1 addition & 2 deletions lib/Mojo/IOLoop/Client.pm
Expand Up @@ -145,8 +145,7 @@ sub _try_socks {
error => 'IO::Socket::Socks 0.64+ required for SOCKS support')
unless SOCKS;

my %options
= (ConnectAddr => $args->{address}, ConnectPort => $args->{port});
my %options = (ConnectAddr => $args->{address}, ConnectPort => $args->{port});
@options{qw(AuthType Username Password)}
= ('userpass', @$args{qw(socks_user socks_pass)})
if $args->{socks_user};
Expand Down
3 changes: 1 addition & 2 deletions lib/Mojo/JSON.pm
Expand Up @@ -105,8 +105,7 @@ sub _decode_object {
my $key = _decode_string();

# Colon
/\G[\x20\x09\x0a\x0d]*:/gc
or _throw('Expected colon while parsing object');
/\G[\x20\x09\x0a\x0d]*:/gc or _throw('Expected colon while parsing object');

# Value
$hash{$key} = _decode_value();
Expand Down
3 changes: 1 addition & 2 deletions lib/Mojo/Server/Hypnotoad.pm
Expand Up @@ -69,8 +69,7 @@ sub run {
$self->_hot_deploy unless $ENV{HYPNOTOAD_PID};
# Daemonize as early as possible (but not for restarts)
$prefork->daemonize
if !$ENV{HYPNOTOAD_FOREGROUND} && $ENV{HYPNOTOAD_REV} < 3;
$prefork->daemonize if !$ENV{HYPNOTOAD_FOREGROUND} && $ENV{HYPNOTOAD_REV} < 3;
# Start accepting connections
local $SIG{USR2} = sub { $self->{upgrade} ||= steady_time };
Expand Down
3 changes: 1 addition & 2 deletions lib/Mojo/Server/Prefork.pm
Expand Up @@ -60,8 +60,7 @@ sub run {
my $self = shift;

# No Windows support
say 'Preforking is not available for Windows.' and exit 0
if $^O eq 'MSWin32';
say 'Preforking is not available for Windows.' and exit 0 if $^O eq 'MSWin32';

# Prepare event loop
my $loop = $self->ioloop->max_accepts($self->accepts);
Expand Down
5 changes: 3 additions & 2 deletions lib/Mojo/Transaction.pm
Expand Up @@ -51,8 +51,9 @@ sub remote_address {
return $self->original_remote_address unless $self->req->reverse_proxy;

# Reverse proxy
return ($self->req->headers->header('X-Forwarded-For') // '')
=~ /([^,\s]+)$/ ? $1 : $self->original_remote_address;
return ($self->req->headers->header('X-Forwarded-For') // '') =~ /([^,\s]+)$/
? $1
: $self->original_remote_address;
}

sub resume { shift->_state(qw(write resume)) }
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Transaction/WebSocket.pm
Expand Up @@ -82,7 +82,7 @@ sub build_message {

# Raw text or binary
if (exists $frame->{text}) { $frame = [1, 0, 0, 0, TEXT, $frame->{text}] }
else { $frame = [1, 0, 0, 0, BINARY, $frame->{binary}] }
else { $frame = [1, 0, 0, 0, BINARY, $frame->{binary}] }

# "permessage-deflate" extension
return $self->build_frame(@$frame) unless $self->compressed;
Expand Down
3 changes: 1 addition & 2 deletions lib/Mojo/UserAgent/CookieJar.pm
Expand Up @@ -49,8 +49,7 @@ sub collect {
my $host = $url->ihost;
my $domain = lc($cookie->domain // $cookie->origin($host)->origin);
$domain =~ s/^\.//;
next
if $host ne $domain && ($host !~ /\Q.$domain\E$/ || $host =~ /\.\d+$/);
next if $host ne $domain && ($host !~ /\Q.$domain\E$/ || $host =~ /\.\d+$/);

# Validate path
my $path = $cookie->path // $url->path->to_dir->to_abs_string;
Expand Down
3 changes: 1 addition & 2 deletions lib/Mojolicious/Plugin/Config.pm
Expand Up @@ -14,8 +14,7 @@ sub parse {
my ($self, $content, $file, $conf, $app) = @_;

# Run Perl code in sandbox
my $config
= eval 'package Mojolicious::Plugin::Config::Sandbox; no warnings;'
my $config = eval 'package Mojolicious::Plugin::Config::Sandbox; no warnings;'
. "sub app; local *app = sub { \$app }; use Mojo::Base -strict; $content";
die qq{Can't load configuration from file "$file": $@} if $@;
die qq{Configuration file "$file" did not return a hash reference.\n}
Expand Down
6 changes: 2 additions & 4 deletions lib/Mojolicious/Plugin/DefaultHelpers.pm
Expand Up @@ -30,8 +30,7 @@ sub register {
$app->helper(content_with => sub { _content(0, 1, @_) });

$app->helper($_ => $self->can("_$_"))
for
qw(csrf_token current_route delay inactivity_timeout is_fresh url_with);
for qw(csrf_token current_route delay inactivity_timeout is_fresh url_with);

$app->helper(dumper => sub { shift; dumper @_ });
$app->helper(include => sub { shift->render_to_string(@_) });
Expand Down Expand Up @@ -81,8 +80,7 @@ sub _delay {
my $c = shift;
my $tx = $c->render_later->tx;
my $delay = Mojo::IOLoop->delay(@_);
$delay->catch(sub { $c->helpers->reply->exception(pop) and undef $tx })
->wait;
$delay->catch(sub { $c->helpers->reply->exception(pop) and undef $tx })->wait;
}

sub _development {
Expand Down
3 changes: 1 addition & 2 deletions lib/Mojolicious/Plugin/TagHelpers.pm
Expand Up @@ -146,8 +146,7 @@ sub _select_field {
else { $groups .= _option(\%values, $group) }
}

return _validation($c, $name, 'select', name => $name, %attrs,
sub {$groups});
return _validation($c, $name, 'select', name => $name, %attrs, sub {$groups});
}

sub _stylesheet {
Expand Down
3 changes: 1 addition & 2 deletions lib/Mojolicious/Renderer.pm
Expand Up @@ -169,8 +169,7 @@ sub template_for {
sub template_handler {
my ($self, $options) = @_;
return undef unless my $file = $self->template_name($options);
return $self->default_handler
unless my $handlers = $self->{templates}{$file};
return $self->default_handler unless my $handlers = $self->{templates}{$file};
return $handlers->[0];
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Test/Mojo.pm
Expand Up @@ -71,8 +71,8 @@ sub content_type_like {
sub content_type_unlike {
my ($self, $regex, $desc) = @_;
$desc ||= 'Content-Type is not similar';
return $self->_test('unlike', $self->tx->res->headers->content_type,
$regex, $desc);
return $self->_test('unlike', $self->tx->res->headers->content_type, $regex,
$desc);
}

sub content_unlike {
Expand Down
4 changes: 2 additions & 2 deletions t/mojo/bytestream.t
Expand Up @@ -111,8 +111,8 @@ is_deeply b('')->split(qr/,/)->to_array, [], 'no elements';
$stream = b('1/2/3');
is $stream->split('/')->map(sub { $_->quote })->join(', '), '"1", "2", "3"',
'right result';
is $stream->split('/')->map(sub { shift->quote })->join(', '),
'"1", "2", "3"', 'right result';
is $stream->split('/')->map(sub { shift->quote })->join(', '), '"1", "2", "3"',
'right result';

# length
is b('foo bar baz')->size, 11, 'size is 11';
Expand Down
3 changes: 1 addition & 2 deletions t/mojo/collection.t
Expand Up @@ -42,8 +42,7 @@ is_deeply \@results, [3, 1, 2, 2, 1, 3], 'right elements';
# first
$collection = c(5, 4, [3, 2], 1);
is $collection->first, 5, 'right result';
is_deeply $collection->first(sub { ref $_ eq 'ARRAY' }), [3, 2],
'right result';
is_deeply $collection->first(sub { ref $_ eq 'ARRAY' }), [3, 2], 'right result';
is $collection->first(sub { shift() < 5 }), 4, 'right result';
is $collection->first(qr/[1-4]/), 4, 'right result';
is $collection->first(sub { ref $_ eq 'CODE' }), undef, 'no result';
Expand Down
3 changes: 1 addition & 2 deletions t/mojo/content.t
Expand Up @@ -105,7 +105,6 @@ like $@, qr/Method "body_contains" not implemented by subclass/, 'right error';
eval { Mojo::Content->body_size };
like $@, qr/Method "body_size" not implemented by subclass/, 'right error';
eval { Mojo::Content->get_body_chunk };
like $@, qr/Method "get_body_chunk" not implemented by subclass/,
'right error';
like $@, qr/Method "get_body_chunk" not implemented by subclass/, 'right error';

done_testing();
8 changes: 4 additions & 4 deletions t/mojo/daemon.t
Expand Up @@ -43,8 +43,8 @@ is $tx->res->body, 'Hello TestApp!', 'right content';

# Listen
{
is_deeply(Mojo::Server::Daemon->new->listen,
['http://*:3000'], 'right value');
is_deeply(Mojo::Server::Daemon->new->listen, ['http://*:3000'],
'right value');
local $ENV{MOJO_LISTEN} = 'http://127.0.0.1:8080';
is_deeply(Mojo::Server::Daemon->new->listen,
['http://127.0.0.1:8080'], 'right value');
Expand Down Expand Up @@ -191,8 +191,8 @@ is $tx->res->body, 'Whatever!', 'right content';
my ($tx2, $tx3);
my $delay = Mojo::IOLoop->delay(sub { (undef, $tx, $tx2, $tx3) = @_ });
$ua->get('/concurrent1/' => $delay->begin);
$ua->post('/concurrent2/' => {Expect => 'fun'} => 'bar baz foo' x 128 =>
$delay->begin);
$ua->post(
'/concurrent2/' => {Expect => 'fun'} => 'bar baz foo' x 128 => $delay->begin);
$ua->get('/concurrent3/' => $delay->begin);
$delay->wait;
ok $tx->is_finished, 'transaction is finished';
Expand Down
4 changes: 2 additions & 2 deletions t/mojo/date.t
Expand Up @@ -69,8 +69,8 @@ is(Mojo::Date->new('Sun Nov 6 08:49:37 1994 GARBAGE')->epoch,
undef, 'no epoch value');
is(Mojo::Date->new('Fri, 75 May 2011 99:99:99 GMT')->epoch,
undef, 'no epoch value');
is(Mojo::Date->new('0000-00-00T00:00:00+01:00')->epoch,
undef, 'no epoch value');
is(Mojo::Date->new('0000-00-00T00:00:00+01:00')->epoch, undef,
'no epoch value');

# to_string
$date = Mojo::Date->new(784111777);
Expand Down

0 comments on commit a6382fd

Please sign in to comment.