pnoltes opened a new issue, #508:
URL: https://github.com/apache/celix/issues/508

   Currently Apache Celix has a mix of styles in its code base, ideally this 
should be align to a single and clear coding style.
   
   A first step could be to introduce a clang-format style supported with some 
cmake / shell support to apply the clang-format.
   
   For example, something like the following clang-format can be used as 
starting point: 
   ```
   #.clang-format
   Language: Cpp
   BasedOnStyle: Google
   PointerAlignment: Left
   DerivePointerAlignment: false
   InsertBraces: true
   AlignEscapedNewlines: Right
   UseTab: Never
   IndentWidth: 4
   ```
   
   And a small shell command or cmake command can be created to apply the 
format to all Apache Celix c, h, cc and cpp files:
   ```
   find bundles -iname "*.h" -exec clang-format -i {} \; 
   find bundles -iname "*.c" -exec clang-format -i {} \; 
   find bundles -iname "*.cc" -exec clang-format -i {} \; 
   find bundles -iname "*.cpp" -exec clang-format -i {} \; 
   find libs -iname "*.h" -exec clang-format -i {} \; 
   find libs -iname "*.c" -exec clang-format -i {} \; 
   find libs -iname "*.cc" -exec clang-format -i {} \; 
   find libs -iname "*.cpp" -exec clang-format -i {} \; 
   ```
   
   A shell command to only apply the format to git staged files can also be 
created, something like:
   ```
   git diff --name-only --cached --diff-filter=d -- '*.h' | xargs -I {} 
clang-format -i {}
   git diff --name-only --cached --diff-filter=d -- '*.c' | xargs -I {} 
clang-format -i {}
   git diff --name-only --cached --diff-filter=d -- '*.cc' | xargs -I {} 
clang-format -i {}
   git diff --name-only --cached --diff-filter=d -- '*.cpp' | xargs -I {} 
clang-format -i {}
   ```
   
   The creating of the .clang-format file and the applying of format should be 
separate pull requests. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@celix.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to