# Example command to run a single policy on single module:
# perlcritic --single-policy Subroutines::ProhibitSubroutinePrototypes Module.pm
-# Below is a list of policies that customize perlcritic to the needs of
-# Perl::Tidy.
+# Below is a list of policies that are skipped or customized to the needs of
+# Perl::Tidy. After experimenting with ## no critic comments, I decided that
+# they cause more trouble than the value they provide, so policies are either
+# 'on' or 'off'.
#--------------------------------------------------------------
# Following is a list of policies to be skipped for severity=4:
# There is a stringy eval in Formatter.pm and Tokenizer.pm which is essential
# for checking user input. So we have to skip this.
-[-BuiltinFunctions::ProhibitStringyEval]
+[-BuiltinFunctions::ProhibitStringyEval]
# Tidy.pm exports 'perltidy'. Changing this could break existing scripts.
[-Modules::ProhibitAutomaticExportation]
# Agree - these are in process of being converted to if's
[-ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions]
-# Agree - checks are in process of being checked
-[-ErrorHandling::RequireCheckingReturnValueOfEval]
-
# This is a good general policy but not always the best for efficiency
[-Subroutines::ProhibitManyArgs]
# but it should be safe because the pattern has been constructed
# by this program.
my ($pattern) = @_;
- eval "'##'=~/$pattern/";
- return $EVAL_ERROR;
+ my $ok = eval "'##'=~/$pattern/";
+ return !defined($ok) || $EVAL_ERROR;
}
{ ## begin closure prepare_cuddled_block_types
package Perl::Tidy::LineSource;
use strict;
use warnings;
+use English qw( -no_match_vars );
our $VERSION = '20220613';
+use constant DEVEL_MODE => 0;
+
sub AUTOLOAD {
# Catch any undefined sub calls so that we are sure to get
# Only close physical files, not STDIN and other objects
my $filename = $self->{_filename};
if ( $filename ne '-' && !ref $filename ) {
- eval { $self->{_fh}->close() };
+ my $ok = eval { $self->{_fh}->close(); 1 };
+ if ( !$ok && DEVEL_MODE ) {
+ Fault("Could not close file handle(): $EVAL_ERROR\n");
+ }
}
return;
}
our $VERSION = '20220613';
use English qw( -no_match_vars );
+use constant DEVEL_MODE => 0;
use constant EMPTY_STRING => q{};
use constant SPACE => q{ };
my $routput_array = $self->{_output_array};
foreach my $line ( @{$routput_array} ) { $fh->print($line) }
if ( $log_file ne '-' && !ref $log_file ) {
- eval { $fh->close() };
+ my $ok = eval { $fh->close(); 1 };
+ if ( !$ok && DEVEL_MODE ) {
+ Fault("Could not close file handle(): $EVAL_ERROR\n");
+ }
}
}
}
return;
}
1;
-
# but it should be safe because the pattern has been constructed
# by this program.
my ($pattern) = @_;
- eval "'##'=~/$pattern/";
- return $EVAL_ERROR;
+ my $ok = eval "'##'=~/$pattern/";
+ return !defined($ok) || $EVAL_ERROR;
}
sub make_code_skipping_pattern {