# Initialize constant hashes ...
my @q;
- @q = qw(
- = **= += *= &= <<= &&=
- -= /= |= >>= ||= //=
- .= %= ^=
- x=
- );
+ @q = qw( = **= += *= &= <<= &&= -= /= |= >>= ||= //= .= %= ^= x= );
@is_assignment{@q} = (1) x scalar(@q);
# a hash needed by break_lists for efficiency:
push @q, qw{ ; < > ~ f };
@is_non_list_type{@q} = (1) x scalar(@q);
- @q = qw(is if unless and or err last next redo return);
+ @q = qw( is if unless and or err last next redo return );
@is_if_unless_and_or_last_next_redo_return{@q} = (1) x scalar(@q);
# These block types may have text between the keyword and opening
# curly. Note: 'else' does not, but must be included to allow trailing
# if/elsif text to be appended.
# patch for SWITCH/CASE: added 'case' and 'when'
- @q = qw(if elsif else unless while until for foreach case when catch);
+ @q = qw( if elsif else unless while until for foreach case when catch );
@is_if_elsif_else_unless_while_until_for_foreach{@q} =
(1) x scalar(@q);
# These can either have the BLOCK form or trailing modifier form:
- @q = qw(if unless while until for foreach);
+ @q = qw( if unless while until for foreach );
@is_if_unless_while_until_for_foreach{@q} =
(1) x scalar(@q);
# These can have several forms
- @q = qw(for foreach);
+ @q = qw( for foreach );
@is_for_foreach{@q} = (1) x scalar(@q);
- @q = qw(last next redo return);
+ @q = qw( last next redo return );
@is_last_next_redo_return{@q} = (1) x scalar(@q);
# Map related block names into a common name to allow vertical alignment
'grep' => 'map',
);
- @q = qw(if unless);
+ @q = qw( if unless );
@is_if_unless{@q} = (1) x scalar(@q);
- @q = qw(if elsif);
+ @q = qw( if elsif );
@is_if_elsif{@q} = (1) x scalar(@q);
- @q = qw(if unless elsif);
+ @q = qw( if unless elsif );
@is_if_unless_elsif{@q} = (1) x scalar(@q);
- @q = qw(if unless elsif else);
+ @q = qw( if unless elsif else );
@is_if_unless_elsif_else{@q} = (1) x scalar(@q);
- @q = qw(elsif else);
+ @q = qw( elsif else );
@is_elsif_else{@q} = (1) x scalar(@q);
- @q = qw(and or err);
+ @q = qw( and or err );
@is_and_or{@q} = (1) x scalar(@q);
# Identify certain operators which often occur in chains.
# Checkbutton => 'Transmission checked',
# -variable => \$TRANS
# This usually improves appearance so it seems ok.
- @q = qw(&& || and or : ? . + - * /);
+ @q = qw( && || and or : ? . + - * / );
@is_chain_operator{@q} = (1) x scalar(@q);
# Operators that the user can request break before or after.
# Note that some are keywords
- @all_operators = qw(% + - * / x != == >= <= =~ !~ < > | &
+ @all_operators = qw(
+ % + - * / x != == >= <= =~ !~ < > | &
= **= += *= &= <<= &&= -= /= |= >>= ||= //= .= %= ^= x=
. : ? && || and or err xor
);
# We can remove semicolons after blocks preceded by these keywords
- @q =
- qw(BEGIN END CHECK INIT AUTOLOAD DESTROY UNITCHECK continue if elsif else
- unless while until for foreach given when default);
+ @q = qw(
+ BEGIN END CHECK INIT AUTOLOAD DESTROY
+ UNITCHECK continue if elsif else unless
+ while until for foreach given when
+ default
+ );
@is_block_without_semicolon{@q} = (1) x scalar(@q);
# We will allow semicolons to be added within these block types
# 3. But not okay for other perltidy types including:
# { } ; G t
# 4. Test files: blktype.t, blktype1.t, semicolon.t
- @q =
- qw( BEGIN END CHECK INIT AUTOLOAD DESTROY UNITCHECK continue if elsif else
- unless do while until eval for foreach );
+ @q = qw( BEGIN END CHECK INIT AUTOLOAD DESTROY UNITCHECK continue if elsif
+ else unless do while until eval for foreach );
@ok_to_add_semicolon_for_block_type{@q} = (1) x scalar(@q);
# 'L' is token for opening { at hash key
@is_soft_keep_break_type{@q} = (1) x scalar(@q);
# these functions allow an identifier in the indirect object slot
- @q = qw( print printf sort exec system say);
+ @q = qw( print printf sort exec system say );
@is_indirect_object_taker{@q} = (1) x scalar(@q);
# Define here tokens which may follow the closing brace of a do statement
# on the same line, as in:
# } while ( $something);
- my @dof = qw(until while unless if ; : );
+ my @dof = qw( until while unless if ; : );
push @dof, ',';
@is_do_follower{@dof} = (1) x scalar(@dof);
# Note that it is essential to always re-initialize the hash here:
%want_one_line_block = ();
if ( !$is_olb_exclusion_word{'*'} ) {
- foreach (qw(sort map grep eval)) {
+ foreach (qw( sort map grep eval )) {
if ( !$is_olb_exclusion_word{$_} ) { $want_one_line_block{$_} = 1 }
}
}
%is_block_with_ci = %is_sort_map_grep_eval_do;
$is_block_with_ci{'sub'} = 1;
- %is_keyword_returning_list = ();
- @q = qw(
- grep
- keys
- map
- reverse
- sort
- split
- );
+ @q = qw( grep keys map reverse sort split );
push @q, @grep_aliases;
+ %is_keyword_returning_list = ();
@is_keyword_returning_list{@q} = (1) x scalar(@q);
# This code enables vertical alignment of grep aliases for testing. It has
# Default keywords for which space is introduced before an opening paren:
# (at present, including them messes up vertical alignment)
- my @sak = qw(my local our state and or xor err eq ne if else elsif until
- unless while for foreach return switch case given when catch);
+ my @sak = qw( my local our state and or xor err eq ne if else elsif until
+ unless while for foreach return switch case given when catch );
%space_after_keyword = map { $_ => 1 } @sak;
# first remove any or all of these if desired
%outdent_keyword = ();
my @okw = split_words( $rOpts->{'outdent-keyword-list'} );
if ( !@okw ) {
- @okw = qw(next last redo goto return); # defaults
+ @okw = qw( next last redo goto return ); # defaults
}
# FUTURE: if not a keyword, assume that it is an identifier
my @kpit =
split_words( $rOpts->{'keyword-paren-inner-tightness-list'} );
if ( !@kpit ) {
- @kpit = qw(if elsif unless while until for foreach); # defaults
+ @kpit = qw( if elsif unless while until for foreach ); # defaults
}
# we will allow keywords and user-defined identifiers
my @k_list = keys %is_indirect_object_taker;
# type symbols which may precede an opening block brace
- my @t_list = qw($ @ % & *);
+ my @t_list = qw( $ @ % & * );
push @t_list, '$#';
my @all = ( @k_list, @t_list );
# The following hash is used to skip over needless if tests.
# Be sure to update it when adding new checks in its block.
- my @q = qw(k w C m - Q);
+ my @q = qw( k w C m - Q );
push @q, '#';
@is_special_ws_type{@q} = (1) x scalar(@q);
# NOTE: This hash is like the global %is_sort_map_grep, but it ignores
# grep aliases on purpose, since here we are looking parens, not braces
- @q = qw(sort grep map);
+ @q = qw( sort grep map );
@is_sort_grep_map{@q} = (1) x scalar(@q);
@q = qw(
- .. :: << >> ** && || // -> => += -= .= %= &= |= ^= *= <>
- <= >= == =~ !~ != ++ -- /= x= ~~ ~. |. &. ^. ^^
+ .. :: << >> ** && || // -> => += -=
+ .= %= &= |= ^= *= <> <= >= == =~ !~
+ != ++ -- /= x= ~~ ~. |. &. ^. ^^
);
@is_digraph{@q} = (1) x scalar(@q);
- @q = qw( ... **= <<= >>= &&= ||= //= <=> !~~ &.= |.= ^.= <<~);
+ @q = qw( ... **= <<= >>= &&= ||= //= <=> !~~ &.= |.= ^.= <<~ );
@is_trigraph{@q} = (1) x scalar(@q);
# These are used as a speedup filters for sub is_essential_whitespace.
$right_bond_strength{'G'} = STRONG;
# assignment operators
- @q = qw(
- = **= += *= &= <<= &&=
- -= /= |= >>= ||= //=
- .= %= ^=
- x=
- );
+ @q = qw( = **= += *= &= <<= &&= -= /= |= >>= ||= //= .= %= ^= x= );
# Default is to break AFTER various assignment operators
@left_bond_strength{@q} = (STRONG) x scalar(@q);
$right_bond_strength{','} = VERY_WEAK;
# remaining digraphs and trigraphs not defined above
- @q = qw( :: <> ++ --);
+ @q = qw( :: <> ++ -- );
@left_bond_strength{@q} = (WEAK) x scalar(@q);
@right_bond_strength{@q} = (STRONG) x scalar(@q);
$left_bond_strength{'err'} = VERY_WEAK - 0.02;
$left_bond_strength{'xor'} = VERY_WEAK - 0.01;
- @q = qw(ne eq);
+ @q = qw( ne eq );
@left_bond_strength{@q} = (NOMINAL) x scalar(@q);
- @q = qw(lt gt le ge);
+ @q = qw( lt gt le ge );
@left_bond_strength{@q} = ( 0.9 * NOMINAL + 0.1 * STRONG ) x scalar(@q);
- @q = qw(and or err xor ne eq);
+ @q = qw( and or err xor ne eq );
@right_bond_strength{@q} = (NOMINAL) x scalar(@q);
$right_bond_strength{'{'} = WEAK;
# Add keywords here which really should not be cuddled
BEGIN {
- my @q = qw(if unless for foreach while);
+ my @q = qw( if unless for foreach while );
@no_cuddle{@q} = (1) x scalar(@q);
}
: 0;
# common filter keywords
- foreach (qw(exit print printf open system exec die)) {
+ foreach (qw( exit print printf open system exec die )) {
if ( $rkeyword_count->{$_} ) { $score += 50; last; }
}
my @sigils_to_test;
if ($check_sigil) {
if ($check_reused) {
- @sigils_to_test = (qw($ @ %));
+ @sigils_to_test = (qw( $ @ % ));
}
else {
- foreach my $sig (qw($ @ %)) {
+ foreach my $sig (qw( $ @ % )) {
if ( $sig ne $sigil ) { push @sigils_to_test, $sig; }
}
}
# $num_files = number of files on the command line
# $line_range_clipped = true if only part of a file is being formatted
- my @all_opts = qw(r s p u c);
+ my @all_opts = qw( r s p u c );
$rwarn_variable_types =
initialize_warn_hash( 'warn-variable-types', 0, \@all_opts );
my $rLL = $self->[_rLL_];
my %skip_keywords;
- my @q = qw(my our local state
+ my @q = qw( my our local state
and cmp continue do else elsif eq ge gt le lt ne not or xor );
@skip_keywords{@q} = (1) x scalar(@q);
BEGIN {
# added 'U' to fix cases b1125 b1126 b1127
- my @q = qw(w U);
+ my @q = qw( w U );
@wU{@q} = (1) x scalar(@q);
- @q = qw(w i q Q G C Z);
+ @q = qw( w i q Q G C Z );
@wiq{@q} = (1) x scalar(@q);
- @q = qw(w i t P S); # Fix for c250: added new types 'P', 'S', formerly 'i'
+ @q = qw( w i t P S ); # Fix for c250: added new types 'P', 'S', formerly 'i'
@is_witPS{@q} = (1) x scalar(@q);
- @q = qw($ & % * @);
+ @q = qw( $ & % * @ );
@is_sigil{@q} = (1) x scalar(@q);
# Parens following these keywords will not be marked as lists. Note that
# They do not produce arrays and do not consume more than one arg, so
# following parens are not required.
my @q = qw(
- abs
- and
- chr
- cmp
- continue
- cos
- defined
- delete
- do
- else
- elsif
- eq
- exp
- fc
- ge
- gt
- hex
- int
- lc
- lcfirst
- le
- length
- local
- log
- lt
- my
- ne
- not
- oct
- or
- ord
- ord
- our
- pop
- pos
- rand
- ref
- scalar
- shift
- sin
- sqrt
- srand
- state
- uc
- ucfirst
- undef
- xor
+ abs and chr cmp continue cos
+ defined delete do else elsif eq
+ exp fc ge gt hex int
+ lc lcfirst le length local log
+ lt my ne not oct or
+ ord ord our pop pos rand
+ ref scalar shift sin sqrt srand
+ state uc ucfirst undef xor
);
@is_non_interfering_keyword{@q} = (1) x scalar(@q);
# Builtin keywords possibly taking multiple parameters but returning a
# scalar value. These can be handled if the args are in parens.
- @q = qw(substr join atan2);
+ @q = qw( substr join atan2 );
@is_keyword_returning_scalar{@q} = (1) x scalar(@q);
}
my %is_array_sigil;
BEGIN {
- my @q = qw(shift pop);
+ my @q = qw( shift pop );
@is_shift_pop{@q} = (1) x scalar(@q);
@q = qw( $ * & );
@is_scalar_sigil{@q} = (1) x scalar(@q);
# o - overcount
# u - undercount
$rwarn_mismatched_arg_types =
- initialize_warn_hash( 'warn-mismatched-arg-types', 1, [qw(a o u)] );
+ initialize_warn_hash( 'warn-mismatched-arg-types', 1, [qw( a o u )] );
$ris_warn_mismatched_arg_excluded_name =
make_excluded_name_hash('warn-mismatched-arg-exclusion-list');
# y - want scalar but no return seen
# s - want scalar but only arrays with count > 1 returned
$rwarn_mismatched_return_types =
- initialize_warn_hash( 'warn-mismatched-return-types', 1,
- [qw(x o u y s)] );
+ initialize_warn_hash( 'warn-mismatched-return-types',
+ 1, [qw( x o u y s )] );
$ris_warn_mismatched_return_excluded_name =
make_excluded_name_hash('warn-mismatched-return-exclusion-list');
return;
@type_ok_after_bareword{@q} = (1) x scalar(@q);
# these types do not 'like' to be separated from a following paren
- @q = qw(w i q Q G C Z U);
+ @q = qw( w i q Q G C Z U );
@has_tight_paren{@q} = (1) x scalar(@q);
} ## end BEGIN
# Setup filters for detecting very poor breaks to ignore.
# b1097: old breaks after type 'L' and before 'R' are poor
# b1450: old breaks at 'eq' and related operators are poor
- my @q = qw(== <= >= !=);
+ my @q = qw( == <= >= != );
@poor_types{@q} = (1) x scalar(@q);
@poor_next_types{@q} = (1) x scalar(@q);
$poor_types{'L'} = 1;
$poor_next_types{'R'} = 1;
- @q = qw(eq ne le ge lt gt);
+ @q = qw( eq ne le ge lt gt );
@poor_keywords{@q} = (1) x scalar(@q);
@poor_next_keywords{@q} = (1) x scalar(@q);
} ## end BEGIN
BEGIN {
# Added 'w' to fix b1172
- my @q = qw(k w i Z ->);
+ my @q = qw( k w i Z -> );
@is_kwiZ{@q} = (1) x scalar(@q);
# added = for b1211
BEGIN {
my @q = qw< } ) ] >;
@hash_test1{@q} = (1) x scalar(@q);
- @q = qw(: ? f);
+ @q = qw( : ? f );
push @q, ',';
@hash_test2{@q} = (1) x scalar(@q);
@q = qw( . || && );
# These 'tokens' are not aligned. We need this to remove [
# from the above list because it has type ='{'
- @q = qw([);
+ @q = qw( [ );
@is_not_vertical_alignment_token{@q} = (1) x scalar(@q);
# these are the only types aligned at a line end
- @q = qw(&& || =>);
+ @q = qw( && || => );
@is_terminal_alignment_type{@q} = (1) x scalar(@q);
# these tokens only align at line level
@is_low_level_alignment_token{@q} = (1) x scalar(@q);
# eq and ne were removed from this list to improve alignment chances
- @q = qw(if unless and or err for foreach while until);
+ @q = qw( if unless and or err for foreach while until );
@is_vertical_alignment_keyword{@q} = (1) x scalar(@q);
} ## end BEGIN
@is_binary_type{@q} = (1) x scalar(@q);
# token keywords which prevent using leading word as a container name
- @q = qw(and or err eq ne cmp);
+ @q = qw( and or err eq ne cmp );
@is_binary_keyword{@q} = (1) x scalar(@q);
# Some common function calls whose args can be aligned. These do not
my %is_zero_continuation_block_type;
my @q;
@q = qw( } { BEGIN END CHECK INIT AUTOLOAD DESTROY UNITCHECK continue ;
- if elsif else unless while until for foreach switch case given when);
+ if elsif else unless while until for foreach switch case given when );
@is_zero_continuation_block_type{@q} = (1) x scalar(@q);
my %is_logical_container;
- @q = qw(if elsif unless while and or err not && ! || for foreach);
+ @q = qw( if elsif unless while and or err not && ! || for foreach );
@is_logical_container{@q} = (1) x scalar(@q);
my %is_binary_type;
- @q = qw(|| &&);
+ @q = qw( || && );
@is_binary_type{@q} = (1) x scalar(@q);
my %is_binary_keyword;
- @q = qw(and or err eq ne cmp);
+ @q = qw( and or err eq ne cmp );
@is_binary_keyword{@q} = (1) x scalar(@q);
# 'L' is token for opening { at hash key
@is_closing_or_ternary_type{@q} = (1) x scalar(@q);
my %is_redo_last_next_goto;
- @q = qw(redo last next goto);
+ @q = qw( redo last next goto );
@is_redo_last_next_goto{@q} = (1) x scalar(@q);
my %is_use_require;
- @q = qw(use require);
+ @q = qw( use require );
@is_use_require{@q} = (1) x scalar(@q);
# This hash holds the array index in $self for these keywords:
);
my %is_for_foreach;
- @q = qw(for foreach);
+ @q = qw( for foreach );
@is_for_foreach{@q} = (1) x scalar(@q);
# These keywords may introduce blocks after parenthesized expressions,
@is_blocktype_with_paren{@q} = (1) x scalar(@q);
my %is_case_default;
- @q = qw(case default);
+ @q = qw( case default );
@is_case_default{@q} = (1) x scalar(@q);
#------------------------
my @q = qw< $ & % * @ ) >;
@is_sigil_or_paren{@q} = (1) x scalar(@q);
- @q = qw(R ]);
+ @q = qw( R ] );
@is_R_closing_sb{@q} = (1) x scalar(@q);
} ## end BEGIN
BEGIN {
# Constants like 'pi' in Trig.pm are common
- my @q = qw(pi pi2 pi4 pip2 pip4);
+ my @q = qw( pi pi2 pi4 pip2 pip4 );
@is_known_constant{@q} = (1) x scalar(@q);
# parenless calls of 'ok' are common
# '&&' and '|' instead of '||'
# /(\)|\}|\;|\&\&|\|\||and|or|while|if|unless)/
- my @q = qw( & && | || ? : + - * and or while if unless);
+ my @q = qw( & && | || ? : + - * and or while if unless );
push @q, ')', '}', ']', '>', ',', ';';
@pattern_test{@q} = (1) x scalar(@q);
} ## end BEGIN
);
@can_start_digraph{@q} = (1) x scalar(@q);
- my @trigraphs = qw( ... **= <<= >>= &&= ||= //= <=> !~~ &.= |.= ^.= <<~);
+ my @trigraphs = qw( ... **= <<= >>= &&= ||= //= <=> !~~ &.= |.= ^.= <<~ );
@is_trigraph{@trigraphs} = (1) x scalar(@trigraphs);
my @tetragraphs = qw( <<>> );
# a list of file test letters, as in -e (Table 3-4 of 'camel 3')
my @file_test_operators =
- qw( A B C M O R S T W X b c d e f g k l o p r s t u w x z);
+ qw( A B C M O R S T W X b c d e f g k l o p r s t u w x z );
@is_file_test_operator{@file_test_operators} =
(1) x scalar(@file_test_operators);
@is_block_operator{@q} = (1) x scalar(@q);
# these functions allow an identifier in the indirect object slot
- @q = qw( print printf sort exec system say);
+ @q = qw( print printf sort exec system say );
@is_indirect_object_taker{@q} = (1) x scalar(@q);
# Note: 'field' will be added by sub check_options if --use-feature=class
- @q = qw(my our state);
+ @q = qw( my our state );
@is_my_our_state{@q} = (1) x scalar(@q);
# These tokens may precede a code block
# now and we could let the extended-syntax coding handle them.
# Added 'default' for Switch::Plain.
# Note: 'ADJUST' will be added by sub check_options if --use-feature=class
- @q =
- qw( BEGIN END CHECK INIT AUTOLOAD DESTROY UNITCHECK continue if elsif else
- unless do while until eval for foreach map grep sort
- switch case given when default catch try finally);
+ @q = qw(
+ BEGIN END CHECK INIT AUTOLOAD DESTROY
+ UNITCHECK continue if elsif else unless
+ do while until eval for foreach
+ map grep sort switch case given
+ when default catch try finally
+ );
@is_code_block_token{@q} = (1) x scalar(@q);
# Note: this hash was formerly named '%is_not_zero_continuation_block_type'
push( @Keywords, @value_requestor );
# These are treated the same but are not keywords:
- my @extra_vr = qw(
- constant
- vars
- );
+ my @extra_vr = qw( constant vars );
push( @value_requestor, @extra_vr );
@expecting_term_token{@value_requestor} = (1) x scalar(@value_requestor);
push( @Keywords, @operator_requestor );
# These are treated the same but are not considered keywords:
- my @extra_or = qw(
- STDERR
- STDIN
- STDOUT
- );
+ my @extra_or = qw( STDERR STDIN STDOUT );
push( @operator_requestor, @extra_or );
delete $really_want_term{'F'}; # file test works on $_ if no following term
delete $really_want_term{'Y'}; # indirect object, too risky to check syntax;
# let perl do it
- @q = qw(q qq qx qr s y tr m);
+ @q = qw( q qq qx qr s y tr m );
@is_q_qq_qx_qr_s_y_tr_m{@q} = (1) x scalar(@q);
# Note added 'qw' here
- @q = qw(q qq qw qx qr s y tr m);
+ @q = qw( q qq qw qx qr s y tr m );
@is_q_qq_qw_qx_qr_s_y_tr_m{@q} = (1) x scalar(@q);
# Quote modifiers:
);
# Note: 'class' will be added by sub check_options if -use-feature=class
- @q = qw(package);
+ @q = qw( package );
@is_package{@q} = (1) x scalar(@q);
@q = qw( if elsif unless );
@other_line_endings{@q} = (1) x scalar(@q);
# These keywords are handled specially in the tokenizer code:
- my @special_keywords = qw(
- do
- eval
- format
- m
- package
- q
- qq
- qr
- qw
- qx
- s
- sub
- tr
- y
- );
+ my @special_keywords =
+ qw( do eval format m package q qq qr qw qx s sub tr y );
push( @Keywords, @special_keywords );
# Keywords after which list formatting may be used
# This list is used to decide if a pattern delimited by slashes, /pattern/,
# can follow one of these keywords.
- @q = qw(
- chomp eof eval fc lc pop shift uc undef
- );
+ @q = qw( chomp eof eval fc lc pop shift uc undef );
@is_keyword_rejecting_slash_as_pattern_delimiter{@q} =
(1) x scalar(@q);