X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lib%2FPerl%2FTidy%2FFileWriter.pm;h=f16a41126c341c6ed0138ee18a8efa418f41955b;hb=c514d57dc8088e1f4d3f51857b1155c20085c296;hp=934d960981682affe31c9282a921073539ce9c62;hpb=880633cc084e9d787eb9f760d3851c5d660db17c;p=perltidy.git diff --git a/lib/Perl/Tidy/FileWriter.pm b/lib/Perl/Tidy/FileWriter.pm index 934d960..f16a411 100644 --- a/lib/Perl/Tidy/FileWriter.pm +++ b/lib/Perl/Tidy/FileWriter.pm @@ -7,9 +7,10 @@ package Perl::Tidy::FileWriter; use strict; use warnings; -our $VERSION = '20220217'; +our $VERSION = '20220613'; -use constant DEVEL_MODE => 0; +use constant DEVEL_MODE => 0; +use constant EMPTY_STRING => q{}; sub AUTOLOAD { @@ -37,10 +38,10 @@ sub DESTROY { # required to avoid call to AUTOLOAD in some versions of perl } -my $input_stream_name = ""; +my $input_stream_name = EMPTY_STRING; # Maximum number of little messages; probably need not be changed. -my $MAX_NAG_MESSAGES = 6; +use constant MAX_NAG_MESSAGES => 6; BEGIN { @@ -142,11 +143,11 @@ sub new { $self->[_max_output_line_length_at_] = 0; $self->[_rK_checklist_] = []; $self->[_K_arrival_order_matches_] = 0; - $self->[_K_sequence_error_msg_] = ""; + $self->[_K_sequence_error_msg_] = EMPTY_STRING; $self->[_K_last_arrival_] = -1; # save input stream name for local error messages - $input_stream_name = ""; + $input_stream_name = EMPTY_STRING; if ($logger_object) { $input_stream_name = $logger_object->get_input_stream_name(); } @@ -168,7 +169,7 @@ sub setup_convergence_test { $self->[_rK_checklist_] = \@list; } $self->[_K_arrival_order_matches_] = 1; - $self->[_K_sequence_error_msg_] = ""; + $self->[_K_sequence_error_msg_] = EMPTY_STRING; $self->[_K_last_arrival_] = -1; return; } @@ -256,6 +257,8 @@ sub write_blank_code_line { return; } +use constant MAX_PRINTED_CHARS => 80; + sub write_code_line { my ( $self, $str, $K ) = @_; @@ -290,8 +293,8 @@ sub write_code_line { my $K_prev = $self->[_K_last_arrival_]; if ( $K < $K_prev ) { chomp $str; - if ( length($str) > 80 ) { - $str = substr( $str, 0, 80 ) . "..."; + if ( length($str) > MAX_PRINTED_CHARS ) { + $str = substr( $str, 0, MAX_PRINTED_CHARS ) . "..."; } my $msg = <[_max_line_length_error_at_] = $output_line_number - 1; } - if ( $self->[_line_length_error_count_] < $MAX_NAG_MESSAGES ) { + if ( $self->[_line_length_error_count_] < MAX_NAG_MESSAGES ) { $self->write_logfile_entry( "Line length exceeded by $exceed characters\n"); } @@ -380,12 +383,12 @@ sub report_line_length_errors { } else { - my $word = ( $line_length_error_count > 1 ) ? "s" : ""; + my $word = ( $line_length_error_count > 1 ) ? "s" : EMPTY_STRING; $self->write_logfile_entry( "$line_length_error_count output line$word exceeded $rOpts->{'maximum-line-length'} characters:\n" ); - $word = ( $line_length_error_count > 1 ) ? "First" : ""; + $word = ( $line_length_error_count > 1 ) ? "First" : EMPTY_STRING; my $first_line_length_error = $self->[_first_line_length_error_]; my $first_line_length_error_at = $self->[_first_line_length_error_at_]; $self->write_logfile_entry(