# This policy is very useful in locating complex code which might benefit from
# simplification. The max value has to be set rather high here because there
# are some routines in Formatter.pm with high mccabe values. In particular,
-# sub "check_options" has a value of 126 but is a very straightforward sub.
+# sub "check_options" has a value of 133 but is a very straightforward sub.
# Nothing would be gained by modifying it.
[Subroutines::ProhibitExcessComplexity]
-max_mccabe=130
+max_mccabe=140
# This policy can be very helpful for locating complex code, but sometimes
# deep nests are the best option, especially in error handling and debug
--keep-old-breakpoints-after=':'
--maximum-line-length=34
+==> b1436.in <==
+ if (
+ $included{'gold'}
+ && $yes_andor =~ /any/
+ && $not_andor !~ /all/
+ && (
+ grep ( { $included{$_} } @COLORS ) +
+ grep ( { $excluded{$_} } @COLORS ) ) == 5
+ )
+ {
+ }
+
+ if (
+ $included{'gold'}
+ && $yes_andor =~ /any/
+ && $not_andor !~ /all/
+ && ( grep ( { $included{$_} } @COLORS )
+ + grep ( { $excluded{$_} } @COLORS ) ) == 5
+ )
+ {
+ }
+
+==> b1436.par <==
+--continuation-indentation=8
+--extended-continuation-indentation
+--keep-old-breakpoints-after='+'
+--variable-maximum-line-length
+--want-break-before='+'
+
+==> b1439.in <==
+ $pt +=
+ ( 0.1734 - 0.000393 * $t ) * dsin($m) +
+ 0.0021 * dsin( 2 * $m )
+ - 0.4068 * dsin($mprime) +
+ 0.0161 * dsin( 2 * $mprime )
+ - 0.0004 * dsin( 3 * $mprime ) +
+ 0.0104 * dsin( 2 * $f )
+ - 0.0051 * dsin( $m + $mprime )
+ - 0.0074 * dsin( $m - $mprime ) +
+ 0.0004 * dsin( 2 * $f + $m )
+ - 0.0004 * dsin( 2 * $f - $m )
+ - 0.0006 * dsin( 2 * $f + $mprime ) +
+ 0.0010 * dsin( 2 * $f - $mprime ) +
+ 0.0005 * dsin( $m + 2 * $mprime );
+
+ $pt +=
+ ( 0.1734 - 0.000393 * $t ) * dsin($m) +
+ 0.0021 * dsin( 2 * $m ) -
+ 0.4068 * dsin($mprime) +
+ 0.0161 * dsin( 2 * $mprime ) -
+ 0.0004 * dsin( 3 * $mprime ) +
+ 0.0104 * dsin( 2 * $f ) -
+ 0.0051 * dsin( $m + $mprime )
+ - 0.0074 * dsin( $m - $mprime ) +
+ 0.0004 * dsin( 2 * $f + $m ) -
+ 0.0004 * dsin( 2 * $f - $m )
+ - 0.0006 * dsin( 2 * $f + $mprime ) +
+ 0.0010 * dsin( 2 * $f - $mprime ) +
+ 0.0005 * dsin( $m + 2 * $mprime );
+
+==> b1439.par <==
+--keep-old-breakpoints-after='-'
+--want-break-before='-'
+
==> b146.in <==
# State 1
%is_container_label_type,
%is_die_confess_croak_warn,
%is_my_our_local,
+ %is_soft_keep_break_type,
@all_operators,
push @q, ',';
@is_counted_type{@q} = (1) x scalar(@q);
+ # Tokens where --keep-old-break-xxx flags make soft breaks instead
+ # of hard breaks. See b1433 and b1436.
+ # NOTE: $type is used as the hash key for now; if other container tokens
+ # are added it might be necessary to use a token/type mixture.
+ @q = qw# -> ? : && || + - / * #;
+ @is_soft_keep_break_type{@q} = (1) x scalar(@q);
+
}
{ ## begin closure to count instances
initialize_keep_old_breakpoints( $rOpts->{'keep-old-breakpoints-after'},
'kba', \%keep_break_after_type );
+ # Modify %keep_break_before and %keep_break_after to avoid conflicts
+ # with %want_break_before; fixes b1436.
+ # This became necessary after breaks for some tokens were converted
+ # from hard to soft (see b1433).
+ # We could do this for all tokens, but to minimize changes to existing
+ # code we currently only do this for the soft break tokens.
+ foreach my $key ( keys %keep_break_before_type ) {
+ if ( defined( $want_break_before{$key} )
+ && !$want_break_before{$key}
+ && $is_soft_keep_break_type{$key} )
+ {
+ $keep_break_after_type{$key} = $keep_break_before_type{$key};
+ delete $keep_break_before_type{$key};
+ }
+ }
+ foreach my $key ( keys %keep_break_after_type ) {
+ if ( defined( $want_break_before{$key} )
+ && $want_break_before{$key}
+ && $is_soft_keep_break_type{$key} )
+ {
+ $keep_break_before_type{$key} = $keep_break_after_type{$key};
+ delete $keep_break_after_type{$key};
+ }
+ }
+
$controlled_comma_style ||= $keep_break_before_type{','};
$controlled_comma_style ||= $keep_break_after_type{','};
return ( $severe_error, $rqw_lines );
} ## end sub resync_lines_and_tokens
-my %is_soft_break_type;
-
-BEGIN {
-
- # Soft breaks are needed to avoid conflicts for token types which might be
- # treated with special logic for chains. Fixes b1433, 1434, 1435.
- # NOTE: $type is used as the hash key for now; if other container tokens
- # are added it might be necessary to use a token/type mixture.
- my @q = qw# -> ? : && || + - / * #;
- @is_soft_break_type{@q} = (1) x scalar(@q);
-
-}
-
sub keep_old_line_breaks {
# Called once per file to find and mark any old line breaks which
if ( !$seqno ) {
my $type = $rLL->[$KK]->[_TYPE_];
if ( $rkeep_break_hash->{$type} ) {
- $rbreak_hash->{$KK} = $is_soft_break_type{$type} ? 2 : 1;
+ $rbreak_hash->{$KK} = $is_soft_keep_break_type{$type} ? 2 : 1;
}
}
}
if ($match) {
my $type = $rLL->[$KK]->[_TYPE_];
- $rbreak_hash->{$KK} = $is_soft_break_type{$type} ? 2 : 1;
+ $rbreak_hash->{$KK} =
+ $is_soft_keep_break_type{$type} ? 2 : 1;
}
}
}