Issues in lambda indentation with 3.3.1
For this block of code: https://github.com/CleverRaven/Cataclysm-DDA/blob/f209d2abd65552da6f0a534e122c5210cfbee291/src/avatar_action.cpp#L699-L715
With Astyle 3.1:
critters.erase( std::remove_if( critters.begin(), critters.end(), [&you,
reach]( const Creature * c ) {
if( reach == 1 && !you.is_adjacent( c, true ) ) {
return true;
}
if( !c->is_npc() ) {
return false;
}
return !dynamic_cast<const npc &>( *c ).is_enemy();
} ), critters.end() );With Astyle 3.3.1:
critters.erase( std::remove_if( critters.begin(), critters.end(), [&you,
reach]( const Creature * c ) {
if( reach == 1 && !you.is_adjacent( c, true ) ) {
return true;
}
if( !c->is_npc() ) {
return false;
}
return !dynamic_cast<const npc &>( *c ).is_enemy();
} ), critters.end() );For this block of code: https://github.com/CleverRaven/Cataclysm-DDA/blob/f209d2abd65552da6f0a534e122c5210cfbee291/src/achievement.cpp#L361-L396
With Astyle 3.1:
std::string message = [&]() {
switch( comp ) {
case achievement_completion::pending:
return string_format( _( "At least %s from %s (%s remaining)" ),
to_string( period_ ), translate_epoch( epoch_ ),
to_string( target() - now ) );
case achievement_completion::completed:
switch( comparison_ ) {
case achievement_comparison::equal:
return string_format( _( "Exactly %s from %s" ),
to_string( period_ ), translate_epoch( epoch_ ) );
case achievement_comparison::less_equal:
return string_format( _( "Within %s of %s (%s remaining)" ),
to_string( period_ ), translate_epoch( epoch_ ),
to_string( target() - now ) );
case achievement_comparison::greater_equal:
return string_format( _( "At least %s from %s (passed)" ),
to_string( period_ ), translate_epoch( epoch_ ) );
case achievement_comparison::anything:
return std::string();
case achievement_comparison::last:
break;
}
cata_fatal( "Invalid achievement_comparison" );
case achievement_completion::failed:
return string_format( _( "Within %s of %s (passed)" ),
to_string( period_ ), translate_epoch( epoch_ ) );
case achievement_completion::last:
break;
}
cata_fatal( "Invalid achievement_completion" );
}
();With Astyle 3.3.1:
std::string message = [&]() {
switch( comp ) {
case achievement_completion::pending:
return string_format( _( "At least %s from %s (%s remaining)" ),
to_string( period_ ), translate_epoch( epoch_ ),
to_string( target() - now ) );
case achievement_completion::completed:
switch( comparison_ ) {
case achievement_comparison::equal:
return string_format( _( "Exactly %s from %s" ),
to_string( period_ ), translate_epoch( epoch_ ) );
case achievement_comparison::less_equal:
return string_format( _( "Within %s of %s (%s remaining)" ),
to_string( period_ ), translate_epoch( epoch_ ),
to_string( target() - now ) );
case achievement_comparison::greater_equal:
return string_format( _( "At least %s from %s (passed)" ),
to_string( period_ ), translate_epoch( epoch_ ) );
case achievement_comparison::anything:
return std::string();
case achievement_comparison::last:
break;
}
cata_fatal( "Invalid achievement_comparison" );
case achievement_completion::failed:
return string_format( _( "Within %s of %s (passed)" ),
to_string( period_ ), translate_epoch( epoch_ ) );
case achievement_completion::last:
break;
}
cata_fatal( "Invalid achievement_completion" );
}
();astylerc
# These options are mirrored in .astylerc and doc/CODE_STYLE.txt
# "One True Brace Style"
--style=1tbs
# Attach brackets to class and struct inline function definitions.
--attach-inlines
# 4 spaces per indentation level and per tab stop
--indent=spaces=4
# 'char *foo' instead of 'char* foo'
--align-pointer=name
# maximum length for a single unbroken line
--max-code-length=100
# 'foo ||\nbar' instead of 'foo\n|| bar'
--break-after-logical
# indent 'public:' 'protected:' 'private:' deeper than 'class' or 'struct'
--indent-classes
# indent 'case' lines deeper than 'switch'
--indent-switches
# indent later lines of multi-line preprocessor directives
--indent-preproc-define
# indent comments on column 1 to match the code block they are in
--indent-col1-comments
# indent multi-line control block headers like 'if (foo\nbar)'
--min-conditional-indent=0
# add space around operators with two operands
--pad-oper
# add brackets to unbracketed one line conditional statements
--add-braces
# replaces tabs with spaces in non-indent sections, except in strings
--convert-tabs
# remove extra space padding around parentheses
--unpad-paren
# insert space padding around parentheses on the inside only
--pad-paren-in
# exclude src/third-party
--exclude=src/third-party
# but don't be sad about no tests/src/third-party
--ignore-exclude-errors-xI've only looked at the results briefly but I can link a few more examples for each issue.
It'd also be nice to have an option to use the old lambda indentation. It was pretty bad, but running the new astyle on the CDDA codebase results in a little too much lambda churn.