Subject: | Allow Perl::Critic::Policy::CodeLayout::RequireTidyCode to configure source formatter class |
Perl::Critic::Policy::CodeLayout::RequireTidyCode uses Perl::Tidy to verify code tidiness. Now with modules like Method::Signatures (or others) you can extend Perl's syntax to add more sugar.
Those enhancements don't get along well with Perl::Tidy, there are Tidy's sub-classes that take into account the syntax suggar.
The suggested change allow user to configure which class to be used as source formatter.
Subject: | formatter_class.patch |
18,19d17
< use Perl::Tidy qw< >;
<
27,28c25,27
< Readonly::Scalar my $DESC => q{Code is not tidy};
< Readonly::Scalar my $EXPL => [ 33 ];
---
> Readonly::Scalar my $DESC => q{Code is not tidy};
> Readonly::Scalar my $EXPL => [ 33 ];
> Readonly::Scalar my $DEFAULT_FORMATTER_CLASS => 'Perl::Tidy';
38a38,42
> {
> name => 'formatter_class',
> description => 'Source formatter class name. Default Perl::Tidy.',
> default_string => $DEFAULT_FORMATTER_CLASS,
> }
50a55,57
> eval "use $self->{_formatter_class} qw< >";
> return $FALSE if $@;
>
114c121,123
< Perl::Tidy::perltidy(
---
> my $code = $self->{_formatter_class}->can('perltidy');
>
> $code->(
183a193,198
> You can also configure the Source Formatter Class, to specify a different
> class other than Perl::Tidy (i.e. Perl::Tidy::Sweetened ). By default it
> uses Perl::Tidy.
>
> [CodeLayout::RequireTidyCode]
> formatter_class = Perl::Tidy::Sweetened