From b6b27c51027aca333e92c4d6cf6877c462748439 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Wed, 2 Sep 2020 16:26:30 -0700 Subject: [PATCH] turn off --asert-tidy and --assert-untidy if format not 'tidy' --- lib/Perl/Tidy.pm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/Perl/Tidy.pm b/lib/Perl/Tidy.pm index 9c30a8ad..81fa3cd5 100644 --- a/lib/Perl/Tidy.pm +++ b/lib/Perl/Tidy.pm @@ -718,6 +718,18 @@ EOM } } + # Turn off assert-tidy and assert-untidy unless we are tidying files + if ( $rOpts->{'format'} ne 'tidy' ) { + if ( $rOpts->{'assert-tidy'} ) { + $rOpts->{'assert-tidy'} = 0; + Warn("ignoring --assert-tidy, --format is not 'tidy'\n"); + } + if ( $rOpts->{'assert-untidy'} ) { + $rOpts->{'assert-untidy'} = 0; + Warn("ignoring --assert-untidy, --format is not 'tidy'\n"); + } + } + Perl::Tidy::Formatter::check_options($rOpts); Perl::Tidy::Tokenizer::check_options($rOpts); if ( $rOpts->{'format'} eq 'html' ) { @@ -1744,7 +1756,7 @@ sub compare_string_buffers { my ( $bufi, $bufo, $is_encoded_data ) = @_; my $leni = length($bufi); - my $leno = length($bufo); + my $leno = defined($bufo) ? length($bufo) : 0; my $msg = "Input file length is $leni chars\nOutput file length is $leno chars\n"; return $msg unless $leni && $leno; -- 2.39.5