| 1 | package Perl::Tidy::FileWriter; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | ##################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # The Perl::Tidy::FileWriter class writes the output file created | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # by the formatter. It receives each output line and performs some | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # important monitoring services. These include: | ||||||||||||||||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||||||||||||||||
| 9 | # - Verifying that lines do not go out with tokens in the wrong order | ||||||||||||||||||||||||||||||||||||||||||
| 10 | # - Checking for obvious iteration convergence when all output tokens | ||||||||||||||||||||||||||||||||||||||||||
| 11 | # match all input tokens | ||||||||||||||||||||||||||||||||||||||||||
| 12 | # - Keeping track of consecutive blank and non-blank lines | ||||||||||||||||||||||||||||||||||||||||||
| 13 | # - Looking for line lengths which exceed the maximum requested length | ||||||||||||||||||||||||||||||||||||||||||
| 14 | # - Reporting results to the log file | ||||||||||||||||||||||||||||||||||||||||||
| 15 | # | ||||||||||||||||||||||||||||||||||||||||||
| 16 | ##################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 44 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 44 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 44 | our $VERSION = '20260705'; | |||||||||||||||||||||||||||||||||||||||||
| 21 | 44 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 44 | ▶ | use constant DEVEL_MODE => 0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 44 | ▶ | use constant EMPTY_STRING => q{}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | # Maximum number of little messages; probably need not be changed. | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 44 | ▶ | use constant MAX_NAG_MESSAGES => 6; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | # List of hash keys to prevent -duk from listing them. | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 44 | my @unique_hash_keys_uu = qw( indent-columns ); | |||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | sub AUTOLOAD { | ||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | # Catch any undefined sub calls so that we are sure to get | ||||||||||||||||||||||||||||||||||||||||||
| 35 | # some diagnostic information. This sub should never be called | ||||||||||||||||||||||||||||||||||||||||||
| 36 | # except for a programming error. | ||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | our $AUTOLOAD; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | return if ( $AUTOLOAD =~ /\bDESTROY$/ ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | my ( $pkg, $fname, $lno ) = caller(); | |||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my $my_package = __PACKAGE__; | |||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | print {*STDERR} <<EOM; | |||||||||||||||||||||||||||||||||||||||||
| 42 | ====================================================================== | ||||||||||||||||||||||||||||||||||||||||||
| 43 | Error detected in package '$my_package', version $VERSION | ||||||||||||||||||||||||||||||||||||||||||
| 44 | Received unexpected AUTOLOAD call for sub '$AUTOLOAD' | ||||||||||||||||||||||||||||||||||||||||||
| 45 | Called from package: '$pkg' | ||||||||||||||||||||||||||||||||||||||||||
| 46 | Called from File '$fname' at line '$lno' | ||||||||||||||||||||||||||||||||||||||||||
| 47 | This error is probably due to a recent programming change | ||||||||||||||||||||||||||||||||||||||||||
| 48 | ====================================================================== | ||||||||||||||||||||||||||||||||||||||||||
| 49 | EOM | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | exit 1; | |||||||||||||||||||||||||||||||||||||||||
| 51 | } ## end sub AUTOLOAD | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | ▶ | sub DESTROY { | |||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | # required to avoid call to AUTOLOAD in some versions of perl | ||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | # Array index names for variables. | ||||||||||||||||||||||||||||||||||||||||||
| 61 | # Do not combine with other BEGIN blocks (c101). | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 44 | ▶ | my $i = 0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | use constant { | ||||||||||||||||||||||||||||||||||||||||||
| 64 | 44 | _logger_object_ => $i++, | |||||||||||||||||||||||||||||||||||||||||
| 65 | _rOpts_ => $i++, | ||||||||||||||||||||||||||||||||||||||||||
| 66 | _output_line_number_ => $i++, | ||||||||||||||||||||||||||||||||||||||||||
| 67 | _consecutive_blank_lines_ => $i++, | ||||||||||||||||||||||||||||||||||||||||||
| 68 | _consecutive_nonblank_lines_ => $i++, | ||||||||||||||||||||||||||||||||||||||||||
| 69 | _consecutive_new_blank_lines_ => $i++, | ||||||||||||||||||||||||||||||||||||||||||
| 70 | _first_line_length_error_ => $i++, | ||||||||||||||||||||||||||||||||||||||||||
| 71 | _max_line_length_error_ => $i++, | ||||||||||||||||||||||||||||||||||||||||||
| 72 | _last_line_length_error_ => $i++, | ||||||||||||||||||||||||||||||||||||||||||
| 73 | _first_line_length_error_at_ => $i++, | ||||||||||||||||||||||||||||||||||||||||||
| 74 | _max_line_length_error_at_ => $i++, | ||||||||||||||||||||||||||||||||||||||||||
| 75 | _last_line_length_error_at_ => $i++, | ||||||||||||||||||||||||||||||||||||||||||
| 76 | _line_length_error_count_ => $i++, | ||||||||||||||||||||||||||||||||||||||||||
| 77 | _max_output_line_length_ => $i++, | ||||||||||||||||||||||||||||||||||||||||||
| 78 | _max_output_line_length_at_ => $i++, | ||||||||||||||||||||||||||||||||||||||||||
| 79 | _rK_checklist_ => $i++, | ||||||||||||||||||||||||||||||||||||||||||
| 80 | _K_arrival_order_matches_ => $i++, | ||||||||||||||||||||||||||||||||||||||||||
| 81 | _K_sequence_error_msg_ => $i++, | ||||||||||||||||||||||||||||||||||||||||||
| 82 | _K_last_arrival_ => $i++, | ||||||||||||||||||||||||||||||||||||||||||
| 83 | _save_logfile_ => $i++, | ||||||||||||||||||||||||||||||||||||||||||
| 84 | _routput_string_ => $i++, | ||||||||||||||||||||||||||||||||||||||||||
| 85 | 44 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | } ## end BEGIN | ||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | sub Die { | ||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | my ($msg) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Die: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | Perl::Tidy::Die($msg); | |||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | croak "unexpected return from Perl::Tidy::Die"; | |||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | sub Fault { | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | my ($msg) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Fault: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | # This routine is called for errors that really should not occur | ||||||||||||||||||||||||||||||||||||||||||
| 98 | # except if there has been a bug introduced by a recent program change. | ||||||||||||||||||||||||||||||||||||||||||
| 99 | # Please add comments at calls to Fault to explain why the call | ||||||||||||||||||||||||||||||||||||||||||
| 100 | # should not occur, and where to look to fix it. | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | my ( $package0_uu, $filename0_uu, $line0, $subroutine0_uu ) = caller(0); | |||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | my ( $package1_uu, $filename1, $line1, $subroutine1 ) = caller(1); | |||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | my ( $package2_uu, $filename2_uu, $line2_uu, $subroutine2 ) = caller(2); | |||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | my $pkg = __PACKAGE__; | |||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | my $input_stream_name = Perl::Tidy::get_input_stream_name(); | |||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | Die(<<EOM); | |||||||||||||||||||||||||||||||||||||||||
| 108 | ============================================================================== | ||||||||||||||||||||||||||||||||||||||||||
| 109 | While operating on input stream with name: '$input_stream_name' | ||||||||||||||||||||||||||||||||||||||||||
| 110 | A fault was detected at line $line0 of sub '$subroutine1' | ||||||||||||||||||||||||||||||||||||||||||
| 111 | in file '$filename1' | ||||||||||||||||||||||||||||||||||||||||||
| 112 | which was called from line $line1 of sub '$subroutine2' | ||||||||||||||||||||||||||||||||||||||||||
| 113 | Message: '$msg' | ||||||||||||||||||||||||||||||||||||||||||
| 114 | This is probably an error introduced by a recent programming change. | ||||||||||||||||||||||||||||||||||||||||||
| 115 | $pkg reports VERSION='$VERSION'. | ||||||||||||||||||||||||||||||||||||||||||
| 116 | ============================================================================== | ||||||||||||||||||||||||||||||||||||||||||
| 117 | EOM | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | croak "unexpected return from sub Die"; | |||||||||||||||||||||||||||||||||||||||||
| 120 | } ## end sub Fault | ||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | sub warning { | ||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | my ( $self, $msg ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
warning: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | # log a warning message from any caller | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | my $logger_object = $self->[_logger_object_]; | |||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | if ($logger_object) { $logger_object->warning($msg); } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 129 | } ## end sub warning | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | sub write_logfile_entry { | ||||||||||||||||||||||||||||||||||||||||||
| 132 | 1316 | ▶ | my ( $self, $msg ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_logfile_entry: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | 1316 | my $logger_object = $self->[_logger_object_]; | |||||||||||||||||||||||||||||||||||||||||
| 134 | 1316 | ▶ | if ($logger_object) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | 1312 | $logger_object->write_logfile_entry($msg); | |||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||
| 137 | 1316 | return; | |||||||||||||||||||||||||||||||||||||||||
| 138 | } ## end sub write_logfile_entry | ||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | sub new { | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 658 | ▶ | my ( $class, $line_sink_object, $rOpts, $logger_object ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=16.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | 658 | my $self = []; | |||||||||||||||||||||||||||||||||||||||||
| 144 | 658 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||
| 145 | 658 | $self->[_logger_object_] = $logger_object; | |||||||||||||||||||||||||||||||||||||||||
| 146 | 658 | $self->[_rOpts_] = $rOpts; | |||||||||||||||||||||||||||||||||||||||||
| 147 | 658 | $self->[_output_line_number_] = 1; | |||||||||||||||||||||||||||||||||||||||||
| 148 | 658 | $self->[_consecutive_blank_lines_] = 0; | |||||||||||||||||||||||||||||||||||||||||
| 149 | 658 | $self->[_consecutive_nonblank_lines_] = 0; | |||||||||||||||||||||||||||||||||||||||||
| 150 | 658 | $self->[_consecutive_new_blank_lines_] = 0; | |||||||||||||||||||||||||||||||||||||||||
| 151 | 658 | $self->[_first_line_length_error_] = 0; | |||||||||||||||||||||||||||||||||||||||||
| 152 | 658 | $self->[_max_line_length_error_] = 0; | |||||||||||||||||||||||||||||||||||||||||
| 153 | 658 | $self->[_last_line_length_error_] = 0; | |||||||||||||||||||||||||||||||||||||||||
| 154 | 658 | $self->[_first_line_length_error_at_] = 0; | |||||||||||||||||||||||||||||||||||||||||
| 155 | 658 | $self->[_max_line_length_error_at_] = 0; | |||||||||||||||||||||||||||||||||||||||||
| 156 | 658 | $self->[_last_line_length_error_at_] = 0; | |||||||||||||||||||||||||||||||||||||||||
| 157 | 658 | $self->[_line_length_error_count_] = 0; | |||||||||||||||||||||||||||||||||||||||||
| 158 | 658 | $self->[_max_output_line_length_] = 0; | |||||||||||||||||||||||||||||||||||||||||
| 159 | 658 | $self->[_max_output_line_length_at_] = 0; | |||||||||||||||||||||||||||||||||||||||||
| 160 | 658 | $self->[_rK_checklist_] = []; | |||||||||||||||||||||||||||||||||||||||||
| 161 | 658 | $self->[_K_arrival_order_matches_] = 0; | |||||||||||||||||||||||||||||||||||||||||
| 162 | 658 | $self->[_K_sequence_error_msg_] = EMPTY_STRING; | |||||||||||||||||||||||||||||||||||||||||
| 163 | 658 | $self->[_K_last_arrival_] = -1; | |||||||||||||||||||||||||||||||||||||||||
| 164 | 658 | ▶ | $self->[_save_logfile_] = | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
defined $logger_object && $logger_object->get_save_logfile
MC/DC100%2/2
defined $logger_object && $logger_object->get_save_logfile
defined $logger_object
$logger_object->get_save_logfile
Truth table100%3/3
A && B
A= defined $logger_objectB= $logger_object->get_save_logfile
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | defined($logger_object) && $logger_object->get_save_logfile(); | ||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | # '$line_sink_object' is a SCALAR ref which receives the lines. | ||||||||||||||||||||||||||||||||||||||||||
| 168 | 658 | my $ref = ref($line_sink_object); | |||||||||||||||||||||||||||||||||||||||||
| 169 | 658 | ▶ | if ( !$ref ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | Fault("FileWriter expects line_sink_object to be a ref\n"); | |||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||
| 172 | elsif ( $ref eq 'SCALAR' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 658 | $self->[_routput_string_] = $line_sink_object; | |||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||
| 175 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | my $str = $ref; | |||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | if ( length($str) > 63 ) { $str = substr( $str, 0, 60 ) . '...' } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | Fault(<<EOM); | |||||||||||||||||||||||||||||||||||||||||
| 179 | FileWriter expects 'line_sink_object' to be ref to SCALAR but it is ref to: | ||||||||||||||||||||||||||||||||||||||||||
| 180 | $str | ||||||||||||||||||||||||||||||||||||||||||
| 181 | EOM | ||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | 658 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 185 | } ## end sub new | ||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | sub setup_convergence_test { | ||||||||||||||||||||||||||||||||||||||||||
| 188 | 655 | ▶ | my ( $self, $rlist ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setup_convergence_test: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | # Setup the convergence test, | ||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | # Given: | ||||||||||||||||||||||||||||||||||||||||||
| 193 | # $rlist = a reference to a list of line-ending token indexes 'K' of | ||||||||||||||||||||||||||||||||||||||||||
| 194 | # the input stream. We will compare these with the line-ending token | ||||||||||||||||||||||||||||||||||||||||||
| 195 | # indexes of the output stream. If they are identical, then we have | ||||||||||||||||||||||||||||||||||||||||||
| 196 | # convergence. | ||||||||||||||||||||||||||||||||||||||||||
| 197 | 655 | ▶ | if ( @{$rlist} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | # We are going to destroy the list, so make a copy and put in | ||||||||||||||||||||||||||||||||||||||||||
| 200 | # reverse order so we can pop values as they arrive | ||||||||||||||||||||||||||||||||||||||||||
| 201 | 644 | my @list = @{$rlist}; | |||||||||||||||||||||||||||||||||||||||||
| 202 | 644 | ▶ | if ( $list[0] < $list[-1] ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 567 | @list = reverse(@list); | |||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||
| 205 | 644 | $self->[_rK_checklist_] = \@list; | |||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | # We will zero this flag on any error in arrival order: | ||||||||||||||||||||||||||||||||||||||||||
| 209 | 655 | $self->[_K_arrival_order_matches_] = 1; | |||||||||||||||||||||||||||||||||||||||||
| 210 | 655 | $self->[_K_sequence_error_msg_] = EMPTY_STRING; | |||||||||||||||||||||||||||||||||||||||||
| 211 | 655 | $self->[_K_last_arrival_] = -1; | |||||||||||||||||||||||||||||||||||||||||
| 212 | 655 | return; | |||||||||||||||||||||||||||||||||||||||||
| 213 | } ## end sub setup_convergence_test | ||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | sub get_convergence_check { | ||||||||||||||||||||||||||||||||||||||||||
| 216 | 658 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_convergence_check: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | # converged if: | ||||||||||||||||||||||||||||||||||||||||||
| 219 | # - all expected indexes arrived | ||||||||||||||||||||||||||||||||||||||||||
| 220 | # - and in correct order | ||||||||||||||||||||||||||||||||||||||||||
| 221 | 658 | ▶ | return !@{ $self->[_rK_checklist_] } | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
!@{$self->[15];} && $self->[16]
MC/DC100%2/2
!@{$self->[15];} && $self->[16]
!@{$self->[15];}
$self->[16]
Truth table100%3/3
not(A) && B
A= !@{$self->[15];}B= $self->[16]
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | && $self->[_K_arrival_order_matches_]; | ||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | } ## end sub get_convergence_check | ||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | sub get_output_line_number { | ||||||||||||||||||||||||||||||||||||||||||
| 227 | 562 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_output_line_number: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | 562 | return $self->[_output_line_number_]; | |||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | sub decrement_output_line_number { | ||||||||||||||||||||||||||||||||||||||||||
| 232 | 658 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decrement_output_line_number: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 233 | 658 | $self->[_output_line_number_]--; | |||||||||||||||||||||||||||||||||||||||||
| 234 | 658 | return; | |||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | sub get_consecutive_nonblank_lines { | ||||||||||||||||||||||||||||||||||||||||||
| 238 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_consecutive_nonblank_lines: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | 1 | return $self->[_consecutive_nonblank_lines_]; | |||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | sub get_consecutive_blank_lines { | ||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_consecutive_blank_lines: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | return $self->[_consecutive_blank_lines_]; | |||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | sub reset_consecutive_blank_lines { | ||||||||||||||||||||||||||||||||||||||||||
| 248 | 175 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset_consecutive_blank_lines: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | 175 | $self->[_consecutive_blank_lines_] = 0; | |||||||||||||||||||||||||||||||||||||||||
| 250 | 175 | return; | |||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | sub want_blank_line { | ||||||||||||||||||||||||||||||||||||||||||
| 254 | 22 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
want_blank_line: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | 22 | ▶ | if ( !$self->[_consecutive_blank_lines_] ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | 13 | $self->write_blank_code_line(); | |||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||
| 258 | 22 | return; | |||||||||||||||||||||||||||||||||||||||||
| 259 | } ## end sub want_blank_line | ||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | sub require_blank_code_lines { | ||||||||||||||||||||||||||||||||||||||||||
| 262 | 51 | ▶ | my ( $self, $count ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
require_blank_code_lines: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | # Given: | ||||||||||||||||||||||||||||||||||||||||||
| 265 | # $count = number of blank lines to write | ||||||||||||||||||||||||||||||||||||||||||
| 266 | # Write out $count blank lines regardless of the value of -mbl | ||||||||||||||||||||||||||||||||||||||||||
| 267 | # unless -mbl=0. This allows extra blank lines to be written for subs and | ||||||||||||||||||||||||||||||||||||||||||
| 268 | # packages even with the default -mbl=1 | ||||||||||||||||||||||||||||||||||||||||||
| 269 | 51 | my $need = $count - $self->[_consecutive_blank_lines_]; | |||||||||||||||||||||||||||||||||||||||||
| 270 | 51 | my $rOpts = $self->[_rOpts_]; | |||||||||||||||||||||||||||||||||||||||||
| 271 | 51 | my $forced = $rOpts->{'maximum-consecutive-blank-lines'} > 0; | |||||||||||||||||||||||||||||||||||||||||
| 272 | 51 | foreach ( 0 .. $need - 1 ) { | |||||||||||||||||||||||||||||||||||||||||
| 273 | 32 | $self->write_blank_code_line($forced); | |||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||
| 275 | 51 | return; | |||||||||||||||||||||||||||||||||||||||||
| 276 | } ## end sub require_blank_code_lines | ||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | sub write_blank_code_line { | ||||||||||||||||||||||||||||||||||||||||||
| 279 | 1113 | ▶ | my ( $self, ($forced) ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_blank_code_line: called CC=6 SCAR=18.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | # Write a blank line of code, given: | ||||||||||||||||||||||||||||||||||||||||||
| 282 | # $forced = optional flag which, if set, forces the blank line | ||||||||||||||||||||||||||||||||||||||||||
| 283 | # to be written. This allows the -mbl flag to be temporarily | ||||||||||||||||||||||||||||||||||||||||||
| 284 | # exceeded. | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | 1113 | my $rOpts = $self->[_rOpts_]; | |||||||||||||||||||||||||||||||||||||||||
| 287 | return | ||||||||||||||||||||||||||||||||||||||||||
| 288 | if (!$forced | ||||||||||||||||||||||||||||||||||||||||||
| 289 | && $self->[_consecutive_blank_lines_] >= | ||||||||||||||||||||||||||||||||||||||||||
| 290 | 1113 | ▶ | $rOpts->{'maximum-consecutive-blank-lines'} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $forced and $self->[3] >= $rOpts->{"maximum-consecutive-blank-lines"}
MC/DC100%2/2
not $forced and $self->[3] >= $rOpts->{"maximum-consecutive-blank-lines"}
not $forced
$self->[3] >= $rOpts->{"maximum-consecutive-blank-lines"}
Truth table100%3/3
not(A) and B
A= not $forcedB= $self->[3] >= $rOpts->{"maximum-consecutive-blank-lines"}
| |||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | 999 | $self->[_consecutive_nonblank_lines_] = 0; | |||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||
| 294 | # Balance old blanks against new (forced) blanks instead of writing them. | ||||||||||||||||||||||||||||||||||||||||||
| 295 | # This fixes case b1073. | ||||||||||||||||||||||||||||||||||||||||||
| 296 | 999 | ▶ | if ( !$forced && $self->[_consecutive_new_blank_lines_] > 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $forced and $self->[5] > 0
MC/DC0%0/2
not $forced and $self->[5] > 0
not $forced
$self->[5] > 0
Truth table66%2/3
not(A) and B
A= not $forcedB= $self->[5] > 0
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | $self->[_consecutive_new_blank_lines_]--; | |||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||
| 301 | 999 | ${ $self->[_routput_string_] } .= "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | 999 | $self->[_output_line_number_]++; | |||||||||||||||||||||||||||||||||||||||||
| 304 | 999 | $self->[_consecutive_blank_lines_]++; | |||||||||||||||||||||||||||||||||||||||||
| 305 | 999 | ▶ | $self->[_consecutive_new_blank_lines_]++ if ($forced); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | 999 | return; | |||||||||||||||||||||||||||||||||||||||||
| 308 | } ## end sub write_blank_code_line | ||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | 44 | ▶ | use constant MAX_PRINTED_CHARS => 80; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | sub write_code_line { | ||||||||||||||||||||||||||||||||||||||||||
| 313 | 8512 | ▶ | my ( $self, $str, $K ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_code_line: called CC=10 SCAR=26.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||
| 315 | # Write a line of code, given | ||||||||||||||||||||||||||||||||||||||||||
| 316 | # $str = the line of code | ||||||||||||||||||||||||||||||||||||||||||
| 317 | # $K = an optional check integer which, if given, must | ||||||||||||||||||||||||||||||||||||||||||
| 318 | # increase monotonically. This was added to catch cache | ||||||||||||||||||||||||||||||||||||||||||
| 319 | # sequence errors in the vertical aligner. | ||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||
| 321 | 8512 | $self->[_consecutive_blank_lines_] = 0; | |||||||||||||||||||||||||||||||||||||||||
| 322 | 8512 | $self->[_consecutive_new_blank_lines_] = 0; | |||||||||||||||||||||||||||||||||||||||||
| 323 | 8512 | $self->[_consecutive_nonblank_lines_]++; | |||||||||||||||||||||||||||||||||||||||||
| 324 | 8512 | $self->[_output_line_number_]++; | |||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | 8512 | ${ $self->[_routput_string_] } .= $str; | |||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | 8512 | ▶ | if ( $self->[_save_logfile_] ) { $self->check_line_lengths($str) } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||
| 330 | #---------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 331 | # Convergence and error check | ||||||||||||||||||||||||||||||||||||||||||
| 332 | #---------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 333 | 8512 | ▶ | if ( defined($K) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | # Convergence check: we are checking if all defined K values arrive in | ||||||||||||||||||||||||||||||||||||||||||
| 336 | # the order which was defined by the caller. Quit checking if any | ||||||||||||||||||||||||||||||||||||||||||
| 337 | # unexpected K value arrives. | ||||||||||||||||||||||||||||||||||||||||||
| 338 | 7618 | ▶ | if ( $self->[_K_arrival_order_matches_] ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | 4048 | my $Kt = pop @{ $self->[_rK_checklist_] }; | |||||||||||||||||||||||||||||||||||||||||
| 340 | 4048 | ▶ | if ( !defined($Kt) || $Kt != $K ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $Kt or $Kt != $K
MC/DC50%1/2
not defined $Kt or $Kt != $K
not defined $Kt
$Kt != $K
Truth table66%2/3
not(A) or B
A= not defined $KtB= $Kt != $K
| |||||||||||||||||||||||||||||||||||||||||||
| 341 | 295 | $self->[_K_arrival_order_matches_] = 0; | |||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | # Check for out-of-order arrivals of index K. The K values are the | ||||||||||||||||||||||||||||||||||||||||||
| 346 | # token indexes of the last token of code lines, and they should come | ||||||||||||||||||||||||||||||||||||||||||
| 347 | # out in increasing order. Otherwise something is seriously wrong. | ||||||||||||||||||||||||||||||||||||||||||
| 348 | # Most likely a recent programming change to VerticalAligner.pm has | ||||||||||||||||||||||||||||||||||||||||||
| 349 | # caused lines to go out in the wrong order. This could happen if | ||||||||||||||||||||||||||||||||||||||||||
| 350 | # either the cache or buffer that it uses are emptied in the wrong | ||||||||||||||||||||||||||||||||||||||||||
| 351 | # order. | ||||||||||||||||||||||||||||||||||||||||||
| 352 | 7618 | ▶ | if ( $K < $self->[_K_last_arrival_] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$K < $self->[18] and not $self->[17]
MC/DC0%0/2
$K < $self->[18] and not $self->[17]
$K < $self->[18]
not $self->[17]
Truth table33%1/3
A and not(B)
A= $K < $self->[18]B= not $self->[17]
| |||||||||||||||||||||||||||||||||||||||||||
| 353 | && !$self->[_K_sequence_error_msg_] ) | ||||||||||||||||||||||||||||||||||||||||||
| 354 | { | ||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | my $K_prev = $self->[_K_last_arrival_]; | |||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | chomp $str; | |||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | if ( length($str) > MAX_PRINTED_CHARS ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | $str = substr( $str, 0, MAX_PRINTED_CHARS ) . "..."; | |||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | my $msg = <<EOM; | |||||||||||||||||||||||||||||||||||||||||
| 363 | Lines have arrived out of order in sub 'write_code_line' | ||||||||||||||||||||||||||||||||||||||||||
| 364 | as detected by token index K=$K arriving after index K=$K_prev in the following line: | ||||||||||||||||||||||||||||||||||||||||||
| 365 | $str | ||||||||||||||||||||||||||||||||||||||||||
| 366 | This is probably due to a recent programming change and needs to be fixed. | ||||||||||||||||||||||||||||||||||||||||||
| 367 | EOM | ||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||
| 369 | # Always die during development, this needs to be fixed | ||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | if (DEVEL_MODE) { Fault($msg) } | |||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | # Otherwise warn if string is not empty (added for b1378) | ||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | $self->warning($msg) if ( length($str) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||
| 375 | # Only issue this warning once | ||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | $self->[_K_sequence_error_msg_] = $msg; | |||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||
| 379 | 7618 | $self->[_K_last_arrival_] = $K; | |||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||
| 381 | 8512 | return; | |||||||||||||||||||||||||||||||||||||||||
| 382 | } ## end sub write_code_line | ||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||
| 384 | sub write_line { | ||||||||||||||||||||||||||||||||||||||||||
| 385 | 399 | ▶ | my ( $self, $str ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_line: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||
| 387 | # Write a line directly to the output, without any counting of blank or | ||||||||||||||||||||||||||||||||||||||||||
| 388 | # non-blank lines. | ||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | # Given: | ||||||||||||||||||||||||||||||||||||||||||
| 391 | # $str = line of text to write | ||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||
| 393 | 399 | ${ $self->[_routput_string_] } .= $str; | |||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||
| 395 | 399 | ▶ | if ( chomp $str ) { $self->[_output_line_number_]++; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 396 | 399 | ▶ | if ( $self->[_save_logfile_] ) { $self->check_line_lengths($str) } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||
| 398 | 399 | return; | |||||||||||||||||||||||||||||||||||||||||
| 399 | } ## end sub write_line | ||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | sub check_line_lengths { | ||||||||||||||||||||||||||||||||||||||||||
| 402 | 2 | ▶ | my ( $self, $str ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_line_lengths: called CC=9 SCAR=32.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||
| 404 | # Collect info on line lengths for logfile | ||||||||||||||||||||||||||||||||||||||||||
| 405 | # Given: | ||||||||||||||||||||||||||||||||||||||||||
| 406 | # $str = line of text being written | ||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||
| 408 | # This calculation of excess line length ignores any internal tabs | ||||||||||||||||||||||||||||||||||||||||||
| 409 | 2 | my $rOpts = $self->[_rOpts_]; | |||||||||||||||||||||||||||||||||||||||||
| 410 | 2 | chomp $str; | |||||||||||||||||||||||||||||||||||||||||
| 411 | 2 | my $len_str = length($str); | |||||||||||||||||||||||||||||||||||||||||
| 412 | 2 | my $exceed = $len_str - $rOpts->{'maximum-line-length'}; | |||||||||||||||||||||||||||||||||||||||||
| 413 | 2 | ▶ | if ( $str && substr( $str, 0, 1 ) eq "\t" && $str =~ /^\t+/g ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$str and substr($str, 0, 1) eq "\t" and $str =~ /^\t+/g
$str and substr($str, 0, 1) eq "\t"
MC/DC0%0/3
$str and substr($str, 0, 1) eq "\t" and $str =~ /^\t+/g
$str
substr($str, 0, 1) eq "\t"
$str =~ /^\t+/g
Truth table25%1/4
A and B and C
A= $strB= substr($str, 0, 1) eq "\t"C= $str =~ /^\t+/g
| |||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | $exceed += pos($str) * $rOpts->{'indent-columns'}; | |||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||
| 417 | # Note that we just incremented output line number to future value | ||||||||||||||||||||||||||||||||||||||||||
| 418 | # so we must subtract 1 for current line number | ||||||||||||||||||||||||||||||||||||||||||
| 419 | 2 | ▶ | if ( $len_str > $self->[_max_output_line_length_] ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 420 | 1 | $self->[_max_output_line_length_] = $len_str; | |||||||||||||||||||||||||||||||||||||||||
| 421 | 1 | $self->[_max_output_line_length_at_] = | |||||||||||||||||||||||||||||||||||||||||
| 422 | $self->[_output_line_number_] - 1; | ||||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||
| 425 | 2 | ▶ | if ( $exceed > 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | my $output_line_number = $self->[_output_line_number_]; | |||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | $self->[_last_line_length_error_] = $exceed; | |||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | $self->[_last_line_length_error_at_] = $output_line_number - 1; | |||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | ▶ | if ( $self->[_line_length_error_count_] == 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | $self->[_first_line_length_error_] = $exceed; | |||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | $self->[_first_line_length_error_at_] = $output_line_number - 1; | |||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | ▶ | if ( $self->[_last_line_length_error_] > | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 435 | $self->[_max_line_length_error_] ) | ||||||||||||||||||||||||||||||||||||||||||
| 436 | { | ||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | $self->[_max_line_length_error_] = $exceed; | |||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | $self->[_max_line_length_error_at_] = $output_line_number - 1; | |||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | ▶ | if ( $self->[_line_length_error_count_] < MAX_NAG_MESSAGES ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | $self->write_logfile_entry( | |||||||||||||||||||||||||||||||||||||||||
| 443 | "Line length exceeded by $exceed characters\n"); | ||||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | $self->[_line_length_error_count_]++; | |||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||
| 447 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||
| 448 | } ## end sub check_line_lengths | ||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||
| 450 | sub report_line_length_errors { | ||||||||||||||||||||||||||||||||||||||||||
| 451 | 658 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
report_line_length_errors: called CC=5 SCAR=25.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||
| 453 | # Write summary info about line lengths to the log file | ||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||
| 455 | 658 | my $rOpts = $self->[_rOpts_]; | |||||||||||||||||||||||||||||||||||||||||
| 456 | 658 | my $line_length_error_count = $self->[_line_length_error_count_]; | |||||||||||||||||||||||||||||||||||||||||
| 457 | 658 | ▶ | if ( $line_length_error_count == 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 458 | 658 | $self->write_logfile_entry( | |||||||||||||||||||||||||||||||||||||||||
| 459 | "No lines exceeded $rOpts->{'maximum-line-length'} characters\n"); | ||||||||||||||||||||||||||||||||||||||||||
| 460 | 658 | my $max_output_line_length = $self->[_max_output_line_length_]; | |||||||||||||||||||||||||||||||||||||||||
| 461 | 658 | my $max_output_line_length_at = $self->[_max_output_line_length_at_]; | |||||||||||||||||||||||||||||||||||||||||
| 462 | 658 | $self->write_logfile_entry( | |||||||||||||||||||||||||||||||||||||||||
| 463 | " Maximum output line length was $max_output_line_length at line $max_output_line_length_at\n" | ||||||||||||||||||||||||||||||||||||||||||
| 464 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||||||
| 467 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | ▶ | my $word = ( $line_length_error_count > 1 ) ? "s" : EMPTY_STRING; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | $self->write_logfile_entry( | |||||||||||||||||||||||||||||||||||||||||
| 471 | "$line_length_error_count output line$word exceeded $rOpts->{'maximum-line-length'} characters:\n" | ||||||||||||||||||||||||||||||||||||||||||
| 472 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | ▶ | $word = ( $line_length_error_count > 1 ) ? "First" : EMPTY_STRING; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | my $first_line_length_error = $self->[_first_line_length_error_]; | |||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | my $first_line_length_error_at = $self->[_first_line_length_error_at_]; | |||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | $self->write_logfile_entry( | |||||||||||||||||||||||||||||||||||||||||
| 478 | " $word at line $first_line_length_error_at by $first_line_length_error characters\n" | ||||||||||||||||||||||||||||||||||||||||||
| 479 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | ▶ | if ( $line_length_error_count > 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | my $max_line_length_error = $self->[_max_line_length_error_]; | |||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | my $max_line_length_error_at = $self->[_max_line_length_error_at_]; | |||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | my $last_line_length_error = $self->[_last_line_length_error_]; | |||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | my $last_line_length_error_at = | |||||||||||||||||||||||||||||||||||||||||
| 486 | $self->[_last_line_length_error_at_]; | ||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | $self->write_logfile_entry( | |||||||||||||||||||||||||||||||||||||||||
| 488 | " Maximum at line $max_line_length_error_at by $max_line_length_error characters\n" | ||||||||||||||||||||||||||||||||||||||||||
| 489 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | $self->write_logfile_entry( | |||||||||||||||||||||||||||||||||||||||||
| 491 | " Last at line $last_line_length_error_at by $last_line_length_error characters\n" | ||||||||||||||||||||||||||||||||||||||||||
| 492 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||
| 495 | 658 | return; | |||||||||||||||||||||||||||||||||||||||||
| 496 | } ## end sub report_line_length_errors | ||||||||||||||||||||||||||||||||||||||||||
| 497 | 44 | 1; | |||||||||||||||||||||||||||||||||||||||||