# Example command to run a single policy on single module:
# perlcritic --single-policy Subroutines::ProhibitSubroutinePrototypes Module.pm
-# This file lists the policies which must be turned off for Perl::Tidy. Many
-# of the policies are excellent starting points for new code, but important
-# exceptions often exist which make it impossible to use them as rigid rules.
+# This file lists the policies which must be adjusted or deactivated for
+# Perl::Tidy. Many of the policies are excellent starting points for new code,
+# but important exceptions often exist which make it impossible to use them as
+# rigid rules.
+
+# I have found the '## no critic' method for locally deactivating specific
+# policies with comments to be too troublesome to use. So unfortunately
+# policies are either on or off.
# severity = 1 gives the most strict checking.
severity = 1
# my editor uses color to make it clear if interpolation is in effect.
[-ValuesAndExpressions::RequireQuotedHeredocTerminator]
-# Perlcritic doesn't know that ARGV in Perl::Tidy actually is localized.
-# Localization of @ARGV could be avoided by calling GetOptionsFromArray
-# instead of GetOptions, but that is not available before perl 5.10, and
-# we want to continue supporting Perl 5.8. So we have to skip this for now.
-# When the time comes to make perl 5.10 the earliest version supported,
-# this restriction can be deleted
+# Perlcritic doesn't seem to know that @ARGV in Perl::Tidy actually **is**
+# localized. Localization of @ARGV could be avoided by calling
+# GetOptionsFromArray instead of GetOptions, but that is not available before
+# perl 5.10, and we want to continue supporting Perl 5.8. So we have to skip
+# this for now. When the time comes to make perl 5.10 the earliest version
+# supported, this restriction can be deleted
[-Variables::RequireLocalizedPunctuationVars]
# sub 'backup_method_copy' in Perl::Tidy.pm has about 25 lines between open
[ControlStructures::ProhibitDeepNests]
max_nests=9
-# This would be nice, but there are many cases where this is really impossible.
+# This would be nice, but in reality there are many cases where these cannot be
+# avoided.
[-ControlStructures::ProhibitCascadingIfElse]
# This is a reasonable starting point but does not work well as a rigid rule.
## 2023 07 01.03
+ - The syntax of the parameter --use-feature=class, or -uf=class, which
+ new in the previous release, has been changed slightly for clarity.
+ The default behavior, which occurs if this flag is not entered, is
+ to automatically try to handle both old and new uses of the keywords
+ 'class', 'method', 'field', and 'ADJUST'.
+ To force these keywords to only follow the -use feature 'class' syntax,
+ enter --use-feature=class.
+ To force perltidy to ignore the -use feature 'class' syntax, enter
+ --use-feature=noclass.
+
- Issue git #122. Added parameter -lrt=n1:n2, or --line-range-tidy=n1:n2
to limit tidy operations to a limited line range. Line numbers start
with 1. The man pages have details.
=item B<-uf=s>, B<--use-feature=s>
-This flag tells perltidy to allow the syntax associated a pragma in string
-B<s>. The current possible settings are:
+This flag tells perltidy to allow or disallow the syntax associated a pragma in
+string B<s>. The current possible settings are:
=over 4
=item *
-B<--use-feature=' '>. This tells perltidy not to treat words B<class>, B<method>, B<field>, B<ADJUST> specially.
+B<--use-feature='noclass'>. This tells perltidy B<not> to treat words B<class>, B<method>, B<field>, B<ADJUST> specially.
=item *
-B<--use-feature> not defined B<[DEFAULT]>. In this case perltidy will try to handle both the newer --use-feature 'class' syntax as well as some older overlapping uses, in particular for the keyword 'method'.
+B<Neither of these> (B<--use-feature> not defined). This is the DEFAULT and
+recommended setting. In this case perltidy will try to automatically handle
+both the newer --use-feature 'class' syntax as well as some conflicting
+uses of some of these special words by exisiting modules.
=back
push @words, 'sub';
}
- # Also include 'method' if necessary for '--use-feature=class':
- # - if user does NOT set 'use-feature', assume 'use-feature=class':
- if ( !defined( $rOpts->{'use-feature'} ) ) {
+ # add 'method' unless use-feature='noclass' is set.
+ if ( !defined( $rOpts->{'use-feature'} )
+ || $rOpts->{'use-feature'} !~ /\bnoclass\b/ )
+ {
push @words, 'method';
}
- # - if user sets 'use-feature', then only add 'method' if
- # use-feature=class is set.
- else {
- if ( $rOpts->{'use-feature'} =~ /\bclass\b/ ) {
- push @words, 'method';
- }
- }
-
# Note (see also RT #133130): These patterns are used by
# sub make_block_pattern, which is used for making most patterns.
# So this sub needs to be called before other pattern-making routines.
my $use_feature_class = 1;
if ( $rOpts->{'use-feature'} ) {
- if ( $rOpts->{'use-feature'} =~ /\bclass\b/ ) {
- $guess_if_method = 0;
- }
- else {
+ if ( $rOpts->{'use-feature'} =~ /\bnoclass\b/ ) {
$use_feature_class = 0;
}
+ elsif ( $rOpts->{'use-feature'} =~ /\bclass\b/ ) {
+ $guess_if_method = 0;
+ }
}
# These are the main updates for this option. There are additional