Permalink
Browse files

retidy a few files, add make_immutable where missing

  • Loading branch information...
1 parent 446af2d commit 31ad27340fa96c27b0ec358f31990791dd599b0c @jonswar committed Jul 12, 2012
View
@@ -1 +0,0 @@
--noll -l=100
View
@@ -22,9 +22,11 @@
^lib/Pod
^localcpan
^misc
+^perlcritic
^profile
^release
^t/make
+^tidyall.ini
^tmp
^weaver.ini
^wiki
View
@@ -735,14 +735,18 @@ method _output_cmeta () {
class => 'CLASS',
interp => '$interp',
);
- return join( "\n",
+ return join(
+ "\n",
"method _set_class_cmeta (\$interp) {",
"\$_class_cmeta = \$interp->component_class_meta_class->new(",
- ( map { sprintf( "'%s' => %s,", $_, $cmeta_info{$_} ) } sort( keys(%cmeta_info) ) ),
- ');',
- '}',
+ (
+ map { sprintf( "'%s' => %s,", $_, $cmeta_info{$_} ) }
+ sort( keys(%cmeta_info) )
+ ),
+ ');', '}',
'sub _unset_class_cmeta { undef $_class_cmeta }',
- 'sub _class_cmeta { $_class_cmeta }' );
+ 'sub _class_cmeta { $_class_cmeta }'
+ );
}
method _output_compiled_component () {
@@ -825,8 +829,8 @@ method _output_methods () {
# Sort methods so that modifiers come after
#
- my @sorted_methods_keys = sort { ( index( $a, ' ' ) <=> index( $b, ' ' ) ) || $a cmp $b }
- keys( %{ $self->{methods} } );
+ my @sorted_methods_keys =
+ sort { ( index( $a, ' ' ) <=> index( $b, ' ' ) ) || $a cmp $b } keys( %{ $self->{methods} } );
return
join( "\n", map { $self->_output_method( $self->{methods}->{$_} ) } @sorted_methods_keys );
}
@@ -1,4 +1,4 @@
-package Mason::Component::Moose;
+package Mason::Component::Moose; ## no critic (Moose::RequireMakeImmutable)
use Moose ();
use MooseX::HasDefaults::RW ();
use Method::Signatures::Simple ();
@@ -142,8 +142,8 @@ which is transformed by L<DollarDot|Mason::Plugin::DollarDot> to
$self->foo
-In the rest of this documentation we will use C<$.> notation, but feel free to
-substitute C<< $self-> >> conceptually and/or in reality.
+In the rest of this documentation we will use C<$.> notation, but feel
+free to substitute C<< $self-> >> conceptually and/or in reality.
To set the attribute, you must use:
@@ -25,9 +25,9 @@ A double open brace (C<< {{ >>) at the end of a C<< %-line >> denotes a filter
call. The filtered content begins just afterwards and ends at the C<< }} >>.
Both C<< {{ >> and C<< }} >> may be followed by a comment.
-The expression C<< $.Trim >>, aka C<< $self->Trim >>, is a method call on the
-component object which returns a filter. In general everything before the C<<
-{{ >> is evaluated and is expected to return a filter or list of filters.
+The expression C<< $.Trim >>, aka C<< $self->Trim >>, is a method call on
+the component object which returns a filter. In general everything before the
+C<< {{ >> is evaluated and is expected to return a filter or list of filters.
By convention, and to avoid name clashes with other component methods, filters
use CamelCase rather than traditional underscore names.
@@ -42,7 +42,8 @@ Filters can take arguments:
There's no place like home.
There's no place like home.
-Since the expression C<< $.Repeat(3) >> returns a filter, it can be curried:
+Since the expression C<< $.Repeat(3) >> returns a filter, it can be
+curried:
% my $repeat_three = $.Repeat(3);
% $repeat_three {{
View
@@ -1,4 +1,4 @@
-package Mason::Moose;
+package Mason::Moose; ## no critic (Moose::RequireMakeImmutable)
use Moose ();
use MooseX::HasDefaults::RO ();
use MooseX::StrictConstructor ();
@@ -2,6 +2,8 @@ package Mason::Plugin::Defer;
use Moose;
with 'Mason::Plugin';
+__PACKAGE__->meta->make_immutable();
+
1;
__END__
@@ -2,6 +2,8 @@ package Mason::Plugin::DollarDot;
use Moose;
with 'Mason::Plugin';
+__PACKAGE__->meta->make_immutable();
+
1;
__END__
@@ -36,9 +38,10 @@ attribute names
=head1 DESCRIPTION
-This plugin substitutes C<< $.I<identifier> >> for C<< $self->I<identifier> >>
-in all Perl code inside components, so that C<< $. >> can be used when
-referring to attributes and calling methods. The actual regex is
+This plugin substitutes C<< $.I<identifier> >> for C<<
+$self->I<identifier> >> in all Perl code inside components, so that C<< $.
+>> can be used when referring to attributes and calling methods. The actual
+regex is
s/ \$\.([^\W\d]\w*) / \$self->$1 /gx;
@@ -50,8 +53,8 @@ C<< $. >> was chosen because of its similar use in Perl 6.
This plugin falls under the heading of gratuitous source filtering, which the
author generally agrees is Evil. That said, this is a very limited filter, and
-seems unlikely to break any legitimate Perl syntax other than use of the C<< $.
->> special variable (input line number).
+seems unlikely to break any legitimate Perl syntax other than use of the C<<
+$. >> special variable (input line number).
=head1 BUGS
@@ -2,6 +2,8 @@ package Mason::Plugin::LvalueAttributes;
use Moose;
with 'Mason::Plugin';
+__PACKAGE__->meta->make_immutable();
+
1;
__END__
@@ -2,6 +2,8 @@ package Mason::Plugin::TidyObjectFiles;
use Moose;
with 'Mason::Plugin';
+__PACKAGE__->meta->make_immutable();
+
1;
__END__
View
@@ -82,7 +82,7 @@ method capture ($code) {
my $output;
{
$self->_push_buffer;
- scope_guard { $output = ${ $self->_current_buffer }; $self->_pop_buffer };
+ scope_guard { $output = ${ $self->_current_buffer }; $self->_pop_buffer; };
$code->();
}
return $output;
View
@@ -22,7 +22,7 @@ sub temp_root { $_[0]->{temp_root} }
# RW class accessors
my $default_plugins = [];
-sub default_plugins { $default_plugins = $_[1] if defined( $_[1] ); $default_plugins }
+sub default_plugins { $default_plugins = $_[1] if defined( $_[1] ); $default_plugins; }
my $gen_path_count = 0;
my $parse_count = 0;
@@ -2,6 +2,9 @@ package Mason::Test::Overrides::Component::StrictMoose;
use Moose::Exporter;
use MooseX::StrictConstructor ();
use base qw(Mason::Component::Moose);
+use strict;
+use warnings;
+
Moose::Exporter->setup_import_methods();
sub init_meta {
@@ -7,4 +7,6 @@ before 'parse' => sub {
print STDERR "starting compilation parse - " . $self->path . "\n";
};
+__PACKAGE__->meta->make_immutable();
+
1;
@@ -9,4 +9,6 @@ extends 'Mason::Component';
# print STDERR "starting component render - " . $self->cmeta->path . "\n";
# };
+__PACKAGE__->meta->make_immutable();
+
1;
@@ -6,4 +6,6 @@ before 'run' => sub {
print STDERR "starting interp run\n";
};
+__PACKAGE__->meta->make_immutable();
+
1;
@@ -12,4 +12,6 @@ before 'comp' => sub {
print STDERR "starting request comp - $path\n";
};
+__PACKAGE__->meta->make_immutable();
+
1;
View
@@ -2,7 +2,7 @@ package Mason::t::Interp;
use Test::Class::Most parent => 'Mason::Test::Class';
use Capture::Tiny qw(capture);
-{ package MyInterp; use Moose; extends 'Mason::Interp' }
+{ package MyInterp; use Moose; extends 'Mason::Interp'; __PACKAGE__->meta->make_immutable() }
sub test_base_interp_class : Tests {
my $self = shift;
View
@@ -1,4 +1,4 @@
-package Mason::t::Plugins;
+package Mason::t::Plugins; ## no critic (Moose::RequireMakeImmutable)
use Test::Class::Most parent => 'Mason::Test::Class';
use Capture::Tiny qw(capture_merged);
use Mason::Util qw(dump_one_line);
@@ -27,5 +27,6 @@ sub weave_section {
);
}
-no Moose;
+__PACKAGE__->meta->make_immutable();
+
1;
View
@@ -0,0 +1,8 @@
+only = 1
+severity = 1
+verbose = %m at %f line %l [%p]\n
+
+[Moose::RequireMakeImmutable]
+[TestingAndDebugging::RequireUseStrict]
+equivalent_modules = Test::Class::Most Mason::Moose Mason::PluginRole
+[Variables::ProhibitConditionalDeclarations]
View
@@ -8,6 +8,7 @@ use strict;
my $tempdir = tempdir( 'mason-app-XXXX', TMPDIR => 1, CLEANUP => 1 );
my $comp_file = "$tempdir/hello.mc";
write_file( $comp_file, "%% has 'd';\nd * 2 = <% \$.d * 2 %>" );
+
# This string escaping may look ugly, but it is only way to make it work under
# Windows
my $output = `$^X bin/mason.pl $comp_file --data-dir $tempdir/data --args "{\\"d\\":\\"4\\"}"`;
View
@@ -0,0 +1,14 @@
+tidyall_class = JS::Code::TidyAll
+
+[PerlTidy]
+argv = -noll -l=100
+select = {bin,lib,t}/**/*.{pl,pm,t}
+modes = editor
+
+[PodTidy]
+select = {bin,lib}/**/*.{pl,pm,pod}
+modes = editor
+
+[PerlCritic]
+select = lib/**/*.pm
+argv = --profile $ROOT/perlcriticrc

0 comments on commit 31ad273

Please sign in to comment.