RetroPie / EmulationStation

A Fork of Emulation Station for RetroPie. Emulation Station is a flexible emulator front-end supporting keyboardless navigation and custom system themes.
Other
860 stars 344 forks source link

C++/C Source Code Formatting #657

Open Gemba opened 4 years ago

Gemba commented 4 years ago

I am proposing some suggestions for the source code formatting.

Rationale here. Used tools and configs here.

Again, these are suggestions and do not be ment cast in stone atm. I would be happy to have some consensus on code formatting to make everyones life (maintainers and contributors) easiser with an unified code style. When agreed on, everyone can use the set.

I am filing an issue because it may be easier to track the changes.

The differences to the default settings uncrustify/universalindentgui uses are:

eat_blanks_after_open_brace=true eat_blanks_before_close_brace=true indent_case_shift=0 indent_columns=4 indent_switch_case=4 indent_with_tabs=0 input_tab_size=4 mod_add_long_ifdef_else_comment=16 mod_add_long_ifdef_endif_comment=16 mod_full_brace_do=add mod_full_brace_for=add mod_full_brace_function=add mod_full_brace_if=add mod_full_brace_using=add mod_full_brace_while=add mod_full_paren_if_bool=true mod_remove_empty_return=true mod_remove_extra_semicolon=true nl_after_brace_close=true nl_after_brace_open=true nl_assign_leave_one_liners=true nl_brace_else=remove nl_brace_while=remove nl_class_brace=add nl_class_leave_one_liners=true nl_do_brace=remove nl_else_brace=remove nl_elseif_brace=remove nl_else_if=remove nl_end_of_file=add nl_enum_leave_one_liners=true nl_fcall_brace=remove nl_for_brace=remove nl_func_leave_one_liners=true nl_getset_leave_one_liners=true nl_if_brace=remove nl_if_leave_one_liners=true nl_start_of_file=remove nl_switch_brace=remove nl_while_brace=remove output_tab_size=4 pos_arith=lead pos_bool=lead pos_conditional=lead sp_after_assign=force sp_after_cast=remove sp_after_operator=add sp_after_sparen=add sp_arith=add sp_assign=add sp_before_assign=force sp_before_sparen=add sp_bool=add sp_brace_else=force sp_compare=add sp_cond_colon=add sp_cond_question=add sp_else_brace=force sp_enum_assign=add sp_inside_paren=remove sp_inside_sparen=remove sp_paren_paren=remove sp_sparen_brace=add

Gemba commented 3 years ago

Was rethinking this. Maybe clang-format is easier to use (also available as extension for Visual Studio) and it has some ready-made formatting templates which are well known in the open source community.

Will also reduce the stress on PRs regarding formatting (for the reviewer and submitter).

nlsdg commented 3 years ago

Consider adding .editorconfig as well. Many editors support it. While the number of supported properties is nowhere near the level of clang-format, its wide support would mean more editors would be able to at least get the basics enforced.