From: Peter Rabbitson Date: Fri, 17 Jan 2014 01:55:06 +0000 (+0100) Subject: Fix trailing whitespace X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FData-Query.git;a=commitdiff_plain;h=49299143a1b2c91a8c8a13cb8c5be930ccc24465 Fix trailing whitespace --- diff --git a/lib/Data/Query/ExprBuilder.pm b/lib/Data/Query/ExprBuilder.pm index 35c0187..997ff27 100644 --- a/lib/Data/Query/ExprBuilder.pm +++ b/lib/Data/Query/ExprBuilder.pm @@ -44,7 +44,7 @@ use overload ( } qw(<=> cmp x ^ ~) ), fallback => 1, -); +); sub new { bless({ %{$_[1]} }, (ref($_[0])||$_[0])); diff --git a/lib/Data/Query/ExprBuilder/Identifier.pm b/lib/Data/Query/ExprBuilder/Identifier.pm index b62875f..d194b9e 100644 --- a/lib/Data/Query/ExprBuilder/Identifier.pm +++ b/lib/Data/Query/ExprBuilder/Identifier.pm @@ -7,7 +7,7 @@ use Data::Query::Constants qw(DQ_IDENTIFIER); sub DESTROY { } -sub can { +sub can { my $name = $_[1]; sub { return (ref($_[0])||$_[0])->new({ diff --git a/lib/Data/Query/ExprDeclare.pm b/lib/Data/Query/ExprDeclare.pm index d3689a1..b6896bd 100644 --- a/lib/Data/Query/ExprDeclare.pm +++ b/lib/Data/Query/ExprDeclare.pm @@ -55,7 +55,7 @@ sub SELECT (&;@) { : $e ); } - + my $final = Select(\@final, shift); if (is_Slice($_[0])) { diff --git a/lib/Data/Query/Renderer/SQL/Dialect/ReturnInto.pm b/lib/Data/Query/Renderer/SQL/Dialect/ReturnInto.pm index 2d3b621..cd773aa 100644 --- a/lib/Data/Query/Renderer/SQL/Dialect/ReturnInto.pm +++ b/lib/Data/Query/Renderer/SQL/Dialect/ReturnInto.pm @@ -9,7 +9,7 @@ around _render_insert => sub { if (my $into = $dq->{__PACKAGE__.'.into'}) { my @ret = @{$self->$orig(@_)}; return [ - @ret, $self->_format_keyword('INTO'), + @ret, $self->_format_keyword('INTO'), intersperse(',', map $self->_render($_), @$into) ]; } else { diff --git a/lib/Data/Query/Renderer/SQL/Naive.pm b/lib/Data/Query/Renderer/SQL/Naive.pm index a84981b..c6af643 100644 --- a/lib/Data/Query/Renderer/SQL/Naive.pm +++ b/lib/Data/Query/Renderer/SQL/Naive.pm @@ -200,7 +200,7 @@ sub _handle_op_type_flatten { unless (exists $op->{$self->_operator_type}) { $op->{$self->_operator_type} = $self->_convert_op($arg); } - + if ($op->{$self->_operator_type} eq $op_name) { unshift @argq, @{$arg->{args}}; } else { @@ -423,7 +423,7 @@ sub _render_group { sub _render_delete { my ($self, $dq) = @_; my ($target, $where) = @{$dq}{qw(target where)}; - [ $self->_format_keyword('DELETE FROM'), + [ $self->_format_keyword('DELETE FROM'), $self->_render($target), ($where ? ($self->_format_keyword('WHERE'), $self->_render($where)) diff --git a/lib/Data/Query/Renderer/SQL/Slice/GenericSubquery.pm b/lib/Data/Query/Renderer/SQL/Slice/GenericSubquery.pm index 41d1f37..b3793e2 100644 --- a/lib/Data/Query/Renderer/SQL/Slice/GenericSubquery.pm +++ b/lib/Data/Query/Renderer/SQL/Slice/GenericSubquery.pm @@ -53,7 +53,7 @@ sub _render_slice { last; } } - + my $count_alias = 'rownum__emulation'; my ($op_and, $op_or) = map +{ 'SQL.Naive' => $_ }, qw(AND OR); my $count_cond = compose { diff --git a/t/example.t b/t/example.t index e436d42..c160b34 100644 --- a/t/example.t +++ b/t/example.t @@ -56,7 +56,7 @@ DwarnL to_sql( SELECT { $_->cd->name } FROM { $_->cds, AS 'cd' } ORDER BY { $_->year } DESC NULLS LAST ); -my $lo = +my $lo = SELECT { $_->cd->name } FROM { $_->cds, AS 'cd' } ORDER BY { $_->year } diff --git a/xt/whitespace.t b/xt/whitespace.t new file mode 100644 index 0000000..34d63f5 --- /dev/null +++ b/xt/whitespace.t @@ -0,0 +1,54 @@ +use warnings; +use strict; + +use Test::More; +use File::Glob 'bsd_glob'; +use lib 't/lib'; + +eval "use Test::EOL 1.0 ()"; +plan skip_all => 'Test::EOL 1.0 required' if $@; +eval "use Test::NoTabs 0.9 ()"; +plan skip_all => 'Test::NoTabs 0.9 required' if $@; + +# FIXME - temporary workaround for RT#82032, RT#82033 +# also add all scripts (no extension) and some extra extensions +# we want to check +{ + no warnings 'redefine'; + my $is_pm = sub { + $_[0] !~ /\./ || $_[0] =~ /\.(?:pm|pod|skip|bash|sql|json|proto)$/i || $_[0] =~ /::/; + }; + + *Test::EOL::_is_perl_module = $is_pm; + *Test::NoTabs::_is_perl_module = $is_pm; +} + +my @pl_targets = qw/t xt lib/; +Test::EOL::all_perl_files_ok({ trailing_whitespace => 1 }, @pl_targets); +Test::NoTabs::all_perl_files_ok(@pl_targets); + +# check some non-"perl files" in the root separately +# use .gitignore as a guide of what to skip +# (or do not test at all if no .gitignore is found) +if (open(my $gi, '<', '.gitignore')) { + my $skipnames; + while (my $ln = <$gi>) { + next if $ln =~ /^\s*$/; + chomp $ln; + $skipnames->{$_}++ for bsd_glob($ln); + } + + # that we want to check anyway + delete $skipnames->{'META.yml'}; + + for my $fn (bsd_glob('*')) { + next if $skipnames->{$fn}; + next unless -f $fn; + Test::EOL::eol_unix_ok($fn, { trailing_whitespace => 1 }); + Test::NoTabs::notabs_ok($fn); + } +} + +# FIXME - Test::NoTabs and Test::EOL declare 'no_plan' which conflicts with done_testing +# https://github.com/schwern/test-more/issues/14 +#done_testing;